Crate ft3x68_rs

Crate ft3x68_rs 

Source
Expand description

§FT3x68 Touch Controller Driver Crate

A driver for the FT3x68 touch controller(s), providing functionality to read touch points, gestures, and manage power modes.

There is limited public information relative to the FocalTech FT touch controllers. As such, much of the operational infromation is not documented in datasheets. This driver is largely based on the Arduino_DriveBus repo found here: https://github.com/Xk-w/Arduino_DriveBus/tree/master.

This driver is embedded-hal compatible and provides a generic interface for the implementing the device reset functionality. This is because the reset pin can be controlled via a GPIO port or an I2C I/O expander-controlled pin.

Some drivers include an INT pin indicating touch events, but this driver does not use it. If interrupts need to be supported, the user can attach the pin output to an interrupt and implement their own callback.

The driver currenlty supports both the FT3168 and FT3268 devices.

§Usage

  1. Implement the ResetInterface trait for your specific reset mechanism.
  2. Create an instance of the Ft3x68Driver.
  3. Initialize the touch driver.
  4. Use the provided methods to read touch points and/or gestures.
// Initialize GPIO Reset Pin with pin or I2C instance
// ResetDriver would be a type that implements the `ResetInterface` trait.
let reset = ResetDriver::new(PinInstance);

let mut touch = Ft3x68Driver::new(
       I2CInstace,
       FT3168_DEVICE_ADDRESS,
       reset,
       delay,
   );

   touch
       .initialize()
       .expect("Failed to initialize touch driver");

  loop {
       touch
           .touch1()
           .map(|touch| println!("Touch 1: {:?}", touch))
           .unwrap();
   }

Notes:

  • To detect gestures, the gesture mode must be enabled using the set_gesture_mode method.
  • If the reset pin is controlled via an I2C GPIO expander sharing the same bus with the touch driver, you should use the embedded_hal_bus to manage multiple instances of I2C. Refer to the examples folder to see how that looks like.

Structs§

Ft3x68Driver
FT3x68 touch driver
TouchPoint
Represents a single touch point.

Enums§

DriverError
Driver Errors
Gesture
Gesture IDs returned by the device.
PowerMode
Power modes for the touch device.
TouchState
Represents the touch state - either active with coordinates or released

Constants§

FT3168_DEVICE_ADDRESS
FT3268_DEVICE_ADDRESS

Traits§

ResetInterface
Trait for controlling the FT3x658 hardware reset pin.