gt9x 0.1.0

A no_std driver for the GT9x series of capacitive touch screen controllers, supporting both async and blocking interfaces.
Documentation
use bitfield_struct::bitfield;

pub enum CMD {
    ModeRead,
}

impl CMD {
    #[inline(always)]
    pub const fn as_bytes(self) -> &'static [u8; 3] {
        match self {
            CMD::ModeRead => &[0x80, 0x40, 0],
        }
    }
}

pub const ID_ADDR: &[u8; 2] = &[0x81, 0x40];

pub const STATUS_ADDR: &[u8; 2] = &[0x81, 0x4E];
pub const CLEAR_STATUS: &[u8; 3] = &[0x81, 0x4E, 0x00];

/// STATUS register (8-bit)
/// Bit7: Buffer status — 1 = data ready (coordinates or key ready), 0 = not ready
/// Bit6: Large Detect — 1 = large touch detected
/// Bit5: Proximity Valid — 1 = proximity sensing valid
/// Bit4: HaveKey — 1 = key pressed, 0 = no key
/// Bit3..0: Number of touch points (N)
#[bitfield(u8, order = Msb)]
pub struct Status {
    #[bits(1)]
    pub buffer_status: bool, // bit7

    #[bits(1)]
    pub large_detect: bool, // bit6

    #[bits(1)]
    pub proximity_valid: bool, // bit5

    #[bits(1)]
    pub have_key: bool, // bit4

    #[bits(4)]
    pub num_points: u8, // bits3..0
}

pub const POINT_BASE: [u8; 2] = [0x81, 0x4F];