1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: MIT OR Apache-2.0
//! FT6336U capacitive touch controller driver (I2C 0x38).
//!
//! Reads only touch point 1 (single-finger). Returns screen coordinates
//! or None if no touch is active.
//!
//! Register map (FT6336U datasheet V1.0, §4 "Register Description"):
//! 0x02 TD_STATUS [3:0] = number of touch points (0–2)
//! 0x03 P1_XH [7:6] = event flag (00=down, 01=up, 10=contact, 11=reserved)
//! [3:0] = X position high nibble
//! 0x04 P1_XL [7:0] = X position low byte
//! 0x05 P1_YH [7:6] = (reserved) [3:0] = Y position high nibble
//! 0x06 P1_YL [7:0] = Y position low byte
//!
//! Ref: <https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/D-FT6336U-DataSheet-V1.020af.pdf>
//! Also: FT6x06 Application Note (Adafruit) for FT6x36 family register compatibility.
use crateSharedI2cBus;
pub const ADDR: u8 = 0x38;
const REG_TD_STATUS: u8 = 0x02; // burst-read 0x02..0x06 (5 bytes)
/// Read first touch point. Returns `Some((x, y))` if touched, `None` otherwise.
pub async