Skip to main content

m5stack_core/io/
mod.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3/// What input model a board exposes, so a consumer can install the matching
4/// LVGL indev (keypad vs pointer) instead of assuming three buttons (#32 I2).
5/// This is a *capability descriptor* only — it carries no app vocabulary
6/// (no nav/semantic meaning); see [`buttons::ButtonEvent`] for the I1 event
7/// contract and [`input_caps`] to query the running board.
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum InputCaps {
10    /// Discrete buttons (Fire27: three front-panel buttons). Drive an LVGL
11    /// KEYPAD/ENCODER indev from the [`buttons::ButtonEvent`] stream.
12    Keypad { buttons: u8 },
13    /// A touch panel of the given pixel size (CoreS3: FT6336U). Drive an LVGL
14    /// POINTER indev from `driver::ft6336u::read_touch`, or the zone-emulated
15    /// [`touch_buttons::TouchButtons`] keypad stream.
16    Pointer { width: u16, height: u16 },
17}
18
19/// The running board's input capability (#32 I2). Fire27 reports a 3-button
20/// keypad; CoreS3 reports its touch-panel size. Lets a view install the right
21/// indev without hardcoding the board.
22#[cfg(target_os = "none")]
23pub const fn input_caps() -> InputCaps {
24    #[cfg(feature = "fire27")]
25    {
26        InputCaps::Keypad { buttons: 3 }
27    }
28    #[cfg(feature = "cores3")]
29    {
30        InputCaps::Pointer {
31            width: crate::board::SCREEN_W,
32            height: crate::board::SCREEN_H,
33        }
34    }
35}
36
37#[cfg(target_os = "none")]
38pub mod buttons;
39#[cfg(target_os = "none")]
40pub mod console;
41/// Hardware-free: builds and is tested on the host too.
42pub mod console_line;
43/// Hardware-free, so it is tested on the host; its only user is `console`, so
44/// a non-test host build has nothing to compile it for.
45#[cfg(any(target_os = "none", test))]
46pub mod console_ring;
47/// Hardware-free: the console's tap, tested on the host. Public because a
48/// consumer implements its trait; the slot is the console's own.
49#[cfg(any(all(target_os = "none", feature = "console-serial"), test))]
50pub mod console_tap;
51#[cfg(target_os = "none")]
52pub mod ow_temp;
53#[cfg(target_os = "none")]
54pub mod pps;
55/// Hardware-free: builds and is tested on the host too.
56pub mod pps_plan;
57#[cfg(target_os = "none")]
58pub mod rpm;
59#[cfg(all(target_os = "none", feature = "serial-cmd"))]
60pub mod serial_cmd;
61#[cfg(target_os = "none")]
62pub mod shared_i2c;
63#[cfg(target_os = "none")]
64pub mod touch_buttons;
65#[cfg(target_os = "none")]
66pub mod watchdog;