Skip to content

ft6336u

FocalTech FT6336U — self-capacitive touch-panel controller.

The touch panel on the M5Stack Core2, at I2C [ADDR]. Layer 3: it knows the part, not the chip or board driving it, and talks through a [BusHandle] — the same shape as the IMU and PMIC drivers, and on the Core2 it shares the internal I2C0 bus with both.

Up to two simultaneous touch points. Each point is an (x, y) coordinate, a touch id, and an [Event] (down, contact, up). This driver reads the first point, which is what a single-touch UI needs; the register layout for the second is identical eight bytes further on if that is ever wanted.

Coordinates are the panel’s raw counts. On the Core2 the panel is 320×240 with a taller touch area (the three capacitive buttons below the screen), so y runs past 240; the mapping to screen pixels is a board/app concern, not this driver’s — it reports what the controller measured.

From FocalTech’s register map (the FT6x36 family): the touch count is the low nibble of TD_STATUS, and each point packs its high coordinate bits and flags into the same bytes as the coordinate — x’s event flag in the top two bits of P1_XH, the touch id in the top nibble of P1_YH. Presence is checked against the vendor id register (0x11, FocalTech), which is stable across the family, rather than the chip-id, which is not.

struct Ft6336u<'a> { /* private fields */ }

An FT6336U on a bus already addressed to [ADDR].

struct Touch {
pub x: u16,
pub y: u16,
pub id: u8,
pub event: Event,
}

One touch point.

Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq

References: Event

enum Event {
Down,
Up,
Contact,
None,
}

What a touch point is doing.

Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq

const ADDR: u8;

I2C address of the FT6336U. Fixed in the part.

const FOCALTECH_ID: u8;

The FocalTech vendor id FOCALTECH_ID reads back.