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.
22pub const fn input_caps() -> InputCaps {
23    #[cfg(feature = "fire27")]
24    {
25        InputCaps::Keypad { buttons: 3 }
26    }
27    #[cfg(feature = "cores3")]
28    {
29        InputCaps::Pointer { width: crate::board::SCREEN_W, height: crate::board::SCREEN_H }
30    }
31}
32
33pub mod buttons;
34pub mod console;
35pub mod ow_temp;
36pub mod pps;
37pub mod rpm;
38pub mod shared_i2c;
39#[cfg(feature = "serial-cmd")]
40pub mod serial_cmd;
41pub mod touch_buttons;
42pub mod watchdog;