pimoroni_gfx_pack

Crates.iopimoroni_gfx_pack
lib.rspimoroni_gfx_pack
version
sourcesrc
created_at2024-12-05 16:32:56.69063
updated_at2024-12-05 16:32:56.69063
descriptionDriver for LCD GFX PACK by Pimoroni
homepage
repositoryhttps://github.com/tracyspacy/pimoroni_gfx_pack
max_upload_size
id1473376
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`
size0
tracyspacy (tracyspacy)

documentation

README

pimoroni_gfx_pack

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.

This driver enables easy initialization and usage of the entire GFX Pack (including pico) with a single line of code:

let mut gfx = GFXPACK::new();

It also allows easily access gfx pack properties like display, buttons, rgbled:

//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()

Example program - simple counter (press a button to increment , press b button to reset):

#![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

Commit count: 6

cargo fmt