#embedded-hal-async #embedded-hal #driver #touch #screen #controller #pure

no-std ft6x06-rs

A pure Rust driver for the FT6x06 capacitive touch screen controller

3 releases (breaking)

0.3.0 Oct 15, 2024
0.2.0 Oct 11, 2024
0.1.0 Oct 10, 2024

#383 in Embedded development

Download history 342/week @ 2024-10-09 92/week @ 2024-10-16 2/week @ 2024-10-23 1/week @ 2024-10-30 3/week @ 2024-11-06

157 downloads per month

Custom license

26KB
374 lines

ft6x06-rs


ft6x06-rs is a pure-Rust embedded-hal-based driver for the I2C-based ft6x06 capacitive touch screen controller. This crate aims to provide high-level functionality for most use-cases.



To-Do:

  • embedded-hal-based driver.
  • embedded-hal-async-based driver.
  • Figure out missing information for specific functionality.
  • Add tests.

Features

  • sync-driver - default, sync driver using embedded-hal.
  • async-driver - async version of the driver using embedded-hal-async.

Example

// Initialization
let mut dev = FT6x06::new(i2c);

// Configure the device.
dev.set_interrupt_mode(InterruptMode::Trigger)?;
dev.set_control_mode(ControlMode::MonitorIdle)?;
dev.set_active_idle_timeout(10)?;
dev.set_report_rates(60, 25)?;

// Read the device configuration.
let interrupt_mode = dev.get_interrupt_mode()?;
let control_mode = dev.get_control_mode()?;
let active_idle_timeout = dev.get_active_idle_timeout()?;
let (active_rate, monitor_rate) = dev.get_report_rates()?;

info!("Irq Mode: {}", interrupt_mode);
info!("Ctrl Mode: {}", control_mode);
info!("Active Idle Timeout: {}", active_idle_timeout);
info!("Active Rate: {}", active_rate);
info!("Monitor Rate: {}", monitor_rate);

// Get the latest touch data. Usually after receiving an interrupt from the device.
let touch_event = dev.get_touch_event()?;

// In the async driver, you can use additionally wait for the next touch event:
let mut irq_pin = Input::new(my_periph.GPIO_XX, Pull::Up);
let mut dev_async = FT6x06Async::new(i2c);
 
loop {
    let touch_event = dev_async.wait_for_touch(&mut irq_pin).await?;
    info!("{:?}", touch_event);
}

Dependencies

~0.5–1MB
~22K SLoC