Embedde graphics demo works!

This commit is contained in:
Sebastian H. Gabrielli 2024-12-21 10:32:57 +01:00
parent 9604e0af66
commit f249ac62be

View File

@ -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);