[−][src]Crate AT42QT2120
A platform agnostic driver for the AT42QT2120 touch sensor IC in Rust.
It is based on the embedded-hal
traits
The device
The AT42QT2120 is a 12 channel QTouch touch sensor that also supports a touch sliders
Usage
Import this crate and an embedded_hal implementation, for example, on an stm32f103 device:
extern crate stm32f1xx_hal as hal; extern crate AT42QT2120;
The AT42QT2120 only has one address option, so to instantiate a device:
let i2c2 = BlockingI2c::i2c2(..); let mut touch_sensor = At42qt2120::new(i2c2);
The AT42QT2120, on reset, has all 12 channels setup as touch input with sane settings. If only touch buttons are needed, no extra setup is needed.
To enable a slider:
let use_wheel = false; let enable_slider = true; touch_sensor.setup_slider(use_wheel, enable_slider);
If a key needs to be disabled, or the threshold changed:
let key_to_setup = 3; let key_threshold = 20; //must be 1 or more! let enable_key = true; setup_key(key_to_setup, key_threshold, enable_key);
Reading keys and the slider:
if touch_sensor.keys_pressed()? { let keys_pressed = touch_sensor.read_keys()?; } if touch_sensor.slider_pressed()? { let keys_pressed = touch_sensor.read_slider()?; }
individual keys can also be read using:
let key_to_read = 3; touch_sensor.read_key(key_to_read)?;
supported features
Basic features are supported: setting up and reading the slider/wheel setting up and reading keys. Calibration.
Not supported is: setting power mode, changing drift compensation and other advanced settings Grouping keys Setting oversampling on keys
This driver is tested on an stm32f103 and made by someone who is new to rust, ymmv :)
Structs
At42qt2120 | Driver for the AT42QT2120 |
Enums
Error |