mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2025-12-28 08:15:59 +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;
|
||||
}
|
||||
}
|
||||
|
||||
13
src/main.rs
13
src/main.rs
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user