| Crates.io | ft6336u-driver |
| lib.rs | ft6336u-driver |
| version | 1.0.0 |
| created_at | 2026-01-19 02:03:54.585549+00 |
| updated_at | 2026-01-19 02:03:54.585549+00 |
| description | A no_std embedded-hal driver for the FT6336U capacitive touch controller |
| homepage | |
| repository | https://github.com/trevorflahardy/ft6336u-driver |
| max_upload_size | |
| id | 2053544 |
| size | 64,418 |
A platform-agnostic Rust driver for the FT6336U capacitive touch controller, built using the embedded-hal traits.
no_std compatible - Works in embedded environments without the standard libraryembedded-hal I2C traits for maximum portabilityThe FT6336U is a capacitive touch controller commonly found in:
I2C Address: 0x38
Add this to your Cargo.toml:
[dependencies]
ft6336u-driver = "1.0"
embedded-hal = "1.0"
use ft6336u_driver::FT6336U;
// Create the driver with your I2C peripheral
let mut touch = FT6336U::new(i2c);
// Scan for touch events
let touch_data = touch.scan().unwrap();
if touch_data.touch_count > 0 {
let point = &touch_data.points[0];
println!("Touch at ({}, {})", point.x, point.y);
}
Continuously poll for touch events:
use ft6336u_driver::{FT6336U, TouchStatus};
let mut touch = FT6336U::new(i2c);
loop {
let data = touch.scan().unwrap();
for i in 0..data.touch_count as usize {
let point = &data.points[i];
match point.status {
TouchStatus::Touch => {
println!("New touch at ({}, {})", point.x, point.y);
}
TouchStatus::Stream => {
println!("Touch moved to ({}, {})", point.x, point.y);
}
TouchStatus::Release => {
println!("Touch released");
}
}
}
delay.delay_ms(10);
}
For better power efficiency, use interrupt-driven operation:
use ft6336u_driver::{FT6336U, GestureMode};
let mut touch = FT6336U::new(i2c);
// Enable interrupt mode
touch.write_g_mode(GestureMode::Trigger).unwrap();
// In your interrupt handler:
// let data = touch.scan().unwrap();
// Process touch data...
// Read chip ID (should be 0x64)
let chip_id = touch.read_chip_id().unwrap();
// Read firmware version
let firmware_id = touch.read_firmware_id().unwrap();
// Read library version
let lib_version = touch.read_library_version().unwrap();
On some boards like the CoreSE-S3, the touch controller's reset and interrupt pins are managed through a GPIO expander:
// Configure expander pins
// - P0_0 (TOUCH_RST): Output mode
// - P1_2 (TOUCH_INT): Input mode with interrupt
// Reset sequence
expander.set_pin_low(P0_0); // Assert reset
delay.delay_ms(10);
expander.set_pin_high(P0_0); // Release reset
delay.delay_ms(50);
// Create touch driver
let mut touch = FT6336U::new(i2c);
// Enable interrupt mode
touch.write_g_mode(GestureMode::Trigger).unwrap();
The repository includes several examples:
polling.rs - Continuous polling for touch eventsinterrupt.rs - Interrupt-driven touch detectiondevice_info.rs - Reading device information and configurationRun examples with (requires hardware):
cargo build --example polling --target your-target
For complete API documentation, visit docs.rs/ft6336u-driver.
Build documentation locally:
cargo doc --open
The driver provides both high-level methods (like scan()) and low-level register access:
// High-level touch scanning
let data = touch.scan().unwrap();
// Low-level register access
let threshold = touch.read_touch_threshold().unwrap();
touch.write_ctrl_mode(CtrlMode::KeepActive).unwrap();
This driver works on any platform that implements the embedded-hal I2C traits, including:
embedded-hal supportRun documentation tests:
cargo test --doc
Contributions are welcome! Please feel free to submit a Pull Request.
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Trevor Flahardy
Note: This is an unofficial driver and is not affiliated with or endorsed by FocalTech Systems Co., Ltd.
Platform-agnostic driver for the FT6336U capacitive touch controller using embedded-hal traits.