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;
}
}

View File

@@ -39,11 +39,6 @@ async fn main(spawner: Spawner) {
static KEYBOARD_EVENTS: StaticCell<Channel<NoopRawMutex, KeyEvent, 10>> = StaticCell::new();
let keyboard_events = KEYBOARD_EVENTS.init(Channel::new());
loop {
info!("im alive");
Timer::after_secs(1).await;
}
// configure keyboard event handler
let config = i2c::Config::default();
let i2c1 = I2c::new_async(p.I2C1, p.PIN_7, p.PIN_6, Irqs, config);
@@ -53,9 +48,15 @@ async fn main(spawner: Spawner) {
// configure display handler
let mut config = spi::Config::default();
config.frequency = 10_000_000;
config.frequency = 16_000_000;
let spi1 = spi::Spi::new_blocking(p.SPI1, p.PIN_10, p.PIN_11, p.PIN_12, config);
spawner
.spawn(display_task(spi1, p.PIN_13, p.PIN_14, p.PIN_15))
.unwrap();
let receiver = keyboard_events.receiver();
loop {
let key = receiver.receive().await;
info!("got key: {}", key.key as u8);
}
}