draw square

This commit is contained in:
2025-06-25 14:32:53 -06:00
parent f8325a7750
commit a3b16c51f8
5 changed files with 54 additions and 53 deletions

View File

@@ -3,15 +3,15 @@ use embassy_rp::{
peripherals::{PIN_13, PIN_14, PIN_15, SPI1},
spi::{Blocking, Spi},
};
use embassy_time::Delay;
use embassy_time::{Delay, Timer};
use embedded_graphics::{
Drawable,
pixelcolor::{BinaryColor, Rgb555, Rgb565},
prelude::{Point, Primitive, RgbColor},
primitives::{PrimitiveStyle, Triangle},
prelude::{Point, Primitive, RgbColor, Size},
primitives::{PrimitiveStyle, Rectangle, Triangle},
};
use embedded_hal_bus::spi::ExclusiveDevice;
use st7365p_lcd::ST7365P;
use st7365p_lcd::{Orientation, ST7365P};
#[embassy_executor::task]
pub async fn display_task(
@@ -30,18 +30,17 @@ pub async fn display_task(
320,
320,
);
display.init(&mut Delay).unwrap();
display.set_orientation(&Orientation::Landscape).unwrap();
let thin_stroke = PrimitiveStyle::with_stroke(Rgb565::RED, 1);
let thin_stroke = PrimitiveStyle::with_stroke(Rgb565::RED, 20);
let yoffset = 10;
Rectangle::new(Point::new(10, 10), Size::new(100, 100))
.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();
loop {
Timer::after_millis(500).await;
}
}