Crates.io | pimoroni_gfx_pack |
lib.rs | pimoroni_gfx_pack |
version | |
source | src |
created_at | 2024-12-05 16:32:56.69063 |
updated_at | 2024-12-05 16:32:56.69063 |
description | Driver for LCD GFX PACK by Pimoroni |
homepage | |
repository | https://github.com/tracyspacy/pimoroni_gfx_pack |
max_upload_size | |
id | 1473376 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This rust library offers convenient functions for interacting with Pico GFX Pack - The Pico GFX Pack adds a 128x64 LCD Matrix display to your headered Raspberry Pi Pico or PicoW, with RGBW backlight and 5 input buttons.
let mut gfx = GFXPACK::new();
//accessing display from GFXPACK and turning off backlight
gfx.display.backlight(BacklightStatus::Off).unwrap();
//accessing rgbled and setting color
gfx.rgb.set_rgb_color(155, 93, 229);
//accessing button a and checking if pressed
gfx.button_a.is_button_pressed()
#![no_std]
#![no_main]
use defmt::*;
use defmt_rtt as _;
use embedded_graphics::{
mono_font::{ascii::FONT_6X10, MonoTextStyle},
pixelcolor::BinaryColor,
prelude::*,
text::Text,
};
use itoa::Buffer;
use panic_probe as _;
//reexports rp2040_hal
use pimoroni_gfx_pack::hal::entry;
use pimoroni_gfx_pack::{BacklightStatus, ST7567Type, GFXPACK};
fn draw_text(s: &str, x: i32, y: i32, display: &mut ST7567Type) {
let style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On);
Text::new(s, Point::new(x, y), style).draw(display).unwrap();
}
#[entry]
fn main() -> ! {
info!("Program start");
//init whole gfx pack and rp2040 pico
let mut gfx = GFXPACK::new();
let mut counter = 0;
//accessing display from GFXPACK and turning off backlight
gfx.display.backlight(BacklightStatus::Off).unwrap();
loop {
//accessing rgbled and setting color
gfx.rgb.set_rgb_color(155, 93, 229);
//accessing button a and checking if pressed
if gfx.button_a.is_button_pressed() {
//clearing display
gfx.display.clear().unwrap();
counter += 1;
} else if gfx.button_b.is_button_pressed() {
gfx.display.clear().unwrap();
counter = 0;
}
let mut buffer = Buffer::new();
let counter_str = buffer.format(counter);
let text = "Count: ";
draw_text(text, 3, 45, &mut gfx.display);
draw_text(counter_str, 58, 45, &mut gfx.display);
gfx.display.show().unwrap();
}
}
// End of file