cardputer

Crates.iocardputer
lib.rscardputer
version0.1.3
sourcesrc
created_at2024-01-22 12:18:54.279019
updated_at2024-02-05 09:19:37.712874
descriptionUtilities for M5Stack Cardputer
homepage
repositoryhttps://github.com/syurazo/cardputer
max_upload_size
id1108717
size69,579
(syurazo)

documentation

https://syurazo.github.io/cardputer/

README

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]
  :
Commit count: 0

cargo fmt