device_envoy_core/cyd/touch.rs
1//! Touch-side support types for the CYD's `cyd` device abstraction.
2//!
3//! Applications read calibrated, oriented events via [`TouchEvent`]. Device
4//! Envoy's platform implementations connect raw controller samples to the
5//! private calibration workflow. Applications use
6//! [`CydTouch`](super::CydTouch); see its
7//! [example](super::CydTouch::try_read).
8
9pub(crate) mod calibration;
10pub(crate) mod driver;
11pub(crate) mod flow;
12
13use embedded_graphics::geometry::Point;
14
15/// A touch event in logical display coordinates (already calibrated and oriented).
16///
17/// Read it with [CydTouch::try_read](super::CydTouch::try_read) in the
18/// [focused example](super::CydTouch::try_read), or see the larger
19/// [application example](../index.html#application-example) for a complete
20/// read-and-draw flow. Applications receive coordinates bounded by
21/// [`CydDisplay::screen_size()`](super::CydDisplay::screen_size) and must not
22/// apply another orientation mapping.
23/// Calibration remains defined against the fixed `320×240` landscape panel
24/// internally; the platform touch implementation maps the result into the
25/// runtime display orientation before returning it.
26#[derive(Clone, Copy, Debug)]
27pub enum TouchEvent {
28 /// The touch contact began at `point`.
29 Down {
30 /// The contact position.
31 point: Point,
32 },
33 /// The active contact moved to `point`.
34 Move {
35 /// The contact position.
36 point: Point,
37 },
38 /// The touch contact ended.
39 Up,
40}
41
42/// A raw XPT2046 touch sample used internally by calibration.
43#[derive(Clone, Copy, Debug, PartialEq, Eq)]
44pub(crate) struct RawPoint {
45 pub x: u16,
46 pub y: u16,
47}