Skip to main content

device_envoy_core/cyd/
touch.rs

1//! Touch-side support types for the CYD's `cyd` device abstraction.
2//!
3//! Apps read calibrated screen-space events via [`TouchEvent`]. Devices also
4//! implement [`super::CydTouchUncalibrated`] so the shared touch-calibration
5//! flow in [`calibration`] can read raw controller samples and transition
6//! into a calibrated [`super::CydTouch`].
7
8pub mod calibration;
9pub(crate) mod driver;
10pub(crate) mod flow;
11
12use embedded_graphics::geometry::Point;
13
14/// A touch event in screen coordinates (already calibrated and mapped).
15///
16/// See the [`super::Cyd`] trait documentation for a usage example.
17#[derive(Clone, Copy, Debug)]
18pub enum TouchEvent {
19    Down { point: Point },
20    Move { point: Point },
21    Up,
22}
23
24/// A raw XPT2046 touch sample in controller coordinates.
25///
26/// See the [touch calibration module documentation](calibration) for usage.
27#[derive(Clone, Copy, Debug, PartialEq, Eq)]
28pub struct RawPoint {
29    pub x: u16,
30    pub y: u16,
31}
32
33/// A raw XPT2046 touch event used by shared calibration flows.
34///
35/// See the [touch calibration module documentation](calibration) for usage.
36#[derive(Clone, Copy, Debug, PartialEq, Eq)]
37pub enum RawTouchEvent {
38    Down { raw_x: u16, raw_y: u16 },
39    Move { raw_x: u16, raw_y: u16 },
40    Up,
41}