Crate ft6x06_rs

Source
Expand description

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.

All interactions are through the FT6x06 or FT6x06Async struct depending on the enabled features.

Features

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

The sync and async drivers are the same except async includes wait_for_touch functionality.

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 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);
}

Structs§

FT6x06
An FT6x06 device.
FT6x06Async
An FT6x06 device.
TouchEvent
A recorded touch event.
TouchPoint
A recorded touch point.

Enums§

ControlMode
The mode that the device will use to scan for touch events.
DriverError
A driver error.
GestureType
The type of gesture detected for a touch event.
InterruptMode
The interrupt mode.
TouchType
The type of touch for a touch point.