From f249ac62beb3901748af09cf888515b6df7fd07c Mon Sep 17 00:00:00 2001 From: "Sebastian H. Gabrielli" Date: Sat, 21 Dec 2024 10:32:57 +0100 Subject: [PATCH] Embedde graphics demo works! --- src/main.rs | 87 ++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/src/main.rs b/src/main.rs index 82adbfb..fdd8589 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,53 +100,58 @@ async fn main(spawner: Spawner) { display.clear(Rgb565::RED).unwrap(); - // // Create styles used by the drawing operations. - // let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1); - // let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3); - // let border_stroke = PrimitiveStyleBuilder::new() - // .stroke_color(BinaryColor::On) - // .stroke_width(3) - // .stroke_alignment(StrokeAlignment::Inside) - // .build(); - // let fill = PrimitiveStyle::with_fill(BinaryColor::On); - // let character_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On); + // Create styles used by the drawing operations. + let thin_stroke = PrimitiveStyle::with_stroke(Rgb565::WHITE, 1); + let thick_stroke = PrimitiveStyle::with_stroke(Rgb565::WHITE, 3); + let border_stroke = PrimitiveStyleBuilder::new() + .stroke_color(Rgb565::WHITE) + .stroke_width(3) + .stroke_alignment(StrokeAlignment::Inside) + .build(); + let fill = PrimitiveStyle::with_fill(Rgb565::WHITE); + let character_style = MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE); - // let yoffset = 10; + let yoffset = 10; - // // Draw a 3px wide outline around the display. - // display - // .bounding_box() - // .into_styled(border_stroke) - // .draw(&mut display).unwrap(); + // Draw a 3px wide outline around the display. + display + .bounding_box() + .into_styled(border_stroke) + .draw(&mut display) + .unwrap(); - // // Draw a triangle. - // Triangle::new( - // Point::new(16, 16 + yoffset), - // Point::new(16 + 16, 16 + yoffset), - // Point::new(16 + 8, yoffset), - // ) - // .into_styled(thin_stroke) - // .draw(&mut display).unwrap(); + // Draw a triangle. + Triangle::new( + Point::new(16, 16 + yoffset), + Point::new(16 + 16, 16 + yoffset), + Point::new(16 + 8, yoffset), + ) + .into_styled(thin_stroke) + .draw(&mut display) + .unwrap(); - // // Draw a filled square - // Rectangle::new(Point::new(52, yoffset), Size::new(16, 16)) - // .into_styled(fill) - // .draw(&mut display).unwrap(); + // Draw a filled square + Rectangle::new(Point::new(52, yoffset), Size::new(16, 16)) + .into_styled(fill) + .draw(&mut display) + .unwrap(); - // // Draw a circle with a 3px wide stroke. - // Circle::new(Point::new(88, yoffset), 17) - // .into_styled(thick_stroke) - // .draw(&mut display).unwrap(); + // Draw a circle with a 3px wide stroke. + Circle::new(Point::new(88, yoffset), 17) + .into_styled(thick_stroke) + .draw(&mut display) + .unwrap(); - // // Draw centered text. - // let text = "embedded-graphics"; - // Text::with_alignment( - // text, - // display.bounding_box().center() + Point::new(0, 15), - // character_style, - // Alignment::Center, - // ) - // .draw(&mut display).unwrap(); + // Draw centered text. + let text = "embedded-graphics"; + Text::with_alignment( + text, + display.bounding_box().center() + Point::new(0, 15), + character_style, + Alignment::Center, + ) + .draw(&mut display) + .unwrap(); let mut led = Output::new(p.P0_03, Level::Low, OutputDrive::Standard);