4 releases

0.1.3 Feb 5, 2024
0.1.2 Jan 28, 2024
0.1.1 Jan 25, 2024
0.1.0 Jan 22, 2024

#2075 in Embedded development

37 downloads per month

MIT license

22KB
540 lines

Utilities for M5Stack Cardputer

Features

  • Initialize ST7789 driver
  • LCD backlight control
  • Decode 74HC138 and convert to keycode
  • Initialize I2C driver for Grove I/F

Usage

Dependencies:

[dependencies]
cardputer = "0.1"

Code:

use cardputer::keyboard::Keyboard;

let peripherals = Peripherals::take().unwrap();

let mut keyboard = Keyboard::new(
    peripherals.pins.gpio8,
    peripherals.pins.gpio9,
    peripherals.pins.gpio11,
    peripherals.pins.gpio13,
    peripherals.pins.gpio15,
    peripherals.pins.gpio3,
    peripherals.pins.gpio4,
    peripherals.pins.gpio5,
    peripherals.pins.gpio6,
    peripherals.pins.gpio7,
)
.unwrap();

let mut keyboard_state = KeyboardState::default();
keyboard_state.update(&mut keyboard).unwrap();
let keys = keyboard_state.pressed_keys();

Examples

Simple example that just outputs the pressed keys to log:info

% cargo run --example key_monitor
  :
I (2642) key_monitor: [Q]
I (3142) key_monitor: [W]
I (3642) key_monitor: [E]
I (4142) key_monitor: [R]
I (4642) key_monitor: [T]
I (5142) key_monitor: [Y]
I (5642) key_monitor: [Space]
  :

Dependencies

~7–15MB
~217K SLoC