mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2025-12-27 15:55:25 +00:00
draw square
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user