embassy-ttp223b 0.1.0

Driver async no_std pour le capteur tactile TTP223B via GPIO, basé sur Embassy.
Documentation
  • Coverage
  • 100%
    16 out of 16 items documented1 out of 10 items with examples
  • Size
  • Source code size: 15.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.45 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 53s Average build duration of successful builds.
  • all releases: 1m 53s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • jorgeandrecastro/embassy-ttp223b
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jorgeandrecastro

crates.io docs.rs License: GPL v3

embassy-ttp223b

Driver asynchrone no_std pour le capteur tactile TTP223B via GPIO, testé sur la Pico 2 et Pico 2040.

Élimine les faux positifs par un filtrage temporel logiciel (debounce 50 ms) sans jamais bloquer le CPU, garantissant une efficacité énergétique maximale. Optimisé pour l'exécuteur embassy.


Câblage exemple Testé

Waveshare Pico 2350B

TTP223B Pico 2350B Description
GND GND Ground (masse commune)
VCC 3V3 Alimentation 3.3V
OUT GPIO16 Signal de sortie tactile

Schéma de connexion :

TTP223B     Pico 2350B
  GND  -------> GND (pin 38 ou autre GND)
  VCC  -------> 3V3 (pin 36)
  OUT  -------> GPIO16 (pin 21)

Utilisation

[dependencies]
embassy-ttp223b = "0.1.0"
use embassy_ttp223b::{Ttp223, TouchState};

let mut touch = Ttp223::new(pin);

loop {
    match touch.wait_for_change().await {
        Ok(TouchState::Pressed)  => { /* réaction au toucher */ }
        Ok(TouchState::Released) => { /* relâchement */ }
        Err(_) => { /* gestion d'erreur GPIO */ }
    }
}

Exemple avec affichage SSD1306

use embassy_ttp223b::{Ttp223, TouchState};
use embassy_ssd1306::Ssd1306;

let mut oled  = Ssd1306::new(i2c, 0x3C);
let mut touch = Ttp223::new(pin);

oled.init().await.unwrap();

loop {
    match touch.wait_for_change().await {
        Ok(TouchState::Pressed) => {
            oled.clear();
            oled.draw_str(10, 3, b"TOUCHE!");
            oled.flush().await.unwrap();
        }
        Ok(TouchState::Released) => {
            oled.clear();
            oled.draw_str(10, 3, b"RELACHE");
            oled.flush().await.unwrap();
        }
        Err(_) => {}
    }
}

Exemple Pico 2040

let mut touch = Ttp223::new(p.PIN_15.into());

loop {
    if let Ok(state) = touch.wait_for_change().await {
        match state {
            TouchState::Pressed  => led.set_high(),
            TouchState::Released => led.set_low(),
        }
    }
}

Timing personnalisé

use embassy_ttp223b::Ttp223;

// debounce 80 ms, polling toutes les 5 ms
let mut touch = Ttp223::new_with_timing(pin, 80, 5);

Fonctionnalités

  • wait_for_change : attend un changement d'état confirmé (debounce asynchrone)
  • get_state : retourne l'état mémorisé sans attendre
  • is_pressed: raccourci booléen pour l'état pressé
  • new_with_timing durées de debounce et de polling configurables
  • release : libère le pin GPIO et retourne la ressource matérielle
  • Zéro allocation, zéro unsafe, zéro blocage CPU

📋 Historique et Évolutions (Changelog)

Version : v0.1.0

  • Implémentation initiale du driver TTP223B asynchrone
  • Debounce logiciel 50 ms par défaut
  • API wait_for_change, get_state, is_pressed, release
  • Timing configurable via new_with_timing

Pour consulter le détail de toutes les versions, veuillez vous référer au fichier : 👉 CHANGELOG.md


Licence

GPL-3.0-or-later — Copyright (C) 2026 Jorge Andre Castro