m5cardputer 0.1.1

esp-idf-hal-based board support for the M5Stack Card Computer
docs.rs failed to build m5cardputer-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

m5cardputer

Crates.io Crates.io

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<AnyIOPin> = 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 at sourcehut.