# `m5cardputer` ![Crates.io](https://img.shields.io/crates/v/m5cardputer?style=flat-square) ![Crates.io](https://img.shields.io/crates/l/m5cardputer?style=flat-square) ## Summary `m5cardputer` provides board support for the M5Stack Card Computer based on `esp-idf-hal`. It implements a driver for the integrated display based on `mipidsi` with PWM backlight dimming support, as well as for the integrated keyboard. ## Usage Example Add a dependency for this crate to `Cargo.toml`: ``` [dependencies] m5cardputer = "0.1" ``` Then, simply construct a `Display` and `Keyboard`: ``` use esp_idf_svc::hal::{gpio::*, spi::*, units::*}; use embedded_graphics::{prelude::*, pixelcolor::Rgb565}; use m5cardputer::{display::Display, keyboard::Keyboard}; // Take ownership of peripherals let dp = Peripherals::take().unwrap(); // Set up SPI driver let input_pin: Option = None; let lcd_spi_drv = SpiDriver::new(dp.spi2, dp.pins.gpio36, dp.pins.gpio35, input_pin, &SpiDriverConfig::default()).unwrap(); let config = config::Config::new().data_mode(config::MODE_0).baudrate(MegaHertz(80).into()).write_only(true); let lcd_spi = SpiDeviceDriver::new(lcd_spi_drv, Some(dp.pins.gpio37), &config).unwrap(); let mut disp = Display::new(lcd_spi, dp.pins.gpio34, dp.pins.gpio33, dp.pins.gpio38, dp.ledc.timer3, dp.ledc.channel7).unwrap(); disp.set_brightness(150).unwrap(); disp.clear(Rgb565::BLACK); // Construct keyboard let row_pins = ( dp.pins.gpio13, dp.pins.gpio15, dp.pins.gpio3, dp.pins.gpio4, dp.pins.gpio5, dp.pins.gpio6, dp.pins.gpio7 ); let address_pins = ( dp.pins.gpio8, dp.pins.gpio9, dp.pins.gpio11 ); let keyboard = Keyboard::new(row_pins, address_pins).unwrap(); let keys = keyboard.get_keys(); for key in keys { println!("{}", key); } ``` You can now simply use `disp` as an embedded-graphics `DrawTarget`, and get access to the keyboard keys by calling `keyboard.get_keys()`. ## Bug Reports and Feature Requests Contributions to this project are welcome. You can find the [code repository](https://git.sr.ht/~doesnotcompete/m5cardputer) at sourcehut.