created module for display
WIP
This commit is contained in:
26
src/display.rs
Normal file
26
src/display.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use embedded_graphics::{
|
||||
mono_font::{MonoTextStyle, ascii::{FONT_9X18_BOLD, FONT_10X20}},
|
||||
pixelcolor::BinaryColor,
|
||||
prelude::{DrawTarget, Point, *},
|
||||
text::Text,
|
||||
};
|
||||
|
||||
pub struct CoMoDisplay<D: DrawTarget<Color = BinaryColor>> {
|
||||
display: D,
|
||||
}
|
||||
|
||||
impl<D: DrawTarget<Color = BinaryColor>> CoMoDisplay<D> {
|
||||
pub fn new(display: D) -> Self {
|
||||
Self { display }
|
||||
}
|
||||
|
||||
pub fn draw(&mut self) -> Result<(), D::Error> {
|
||||
let text_style = MonoTextStyle::new(&FONT_10X20, BinaryColor::On);
|
||||
|
||||
self.display.clear(BinaryColor::Off)?;
|
||||
|
||||
Text::new("18,6 Ips", Point::new(50, 40), text_style).draw(&mut self.display)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
28
src/main.rs
28
src/main.rs
@@ -3,23 +3,21 @@
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_rp::{
|
||||
bind_interrupts, gpio,
|
||||
Peri, bind_interrupts, gpio,
|
||||
peripherals::USB,
|
||||
spi::{self, Spi},
|
||||
spi::{self, ClkPin, Instance, Spi},
|
||||
usb::Driver,
|
||||
};
|
||||
use embassy_time::Timer;
|
||||
use embedded_graphics::{
|
||||
mono_font::{MonoTextStyle, iso_8859_1::FONT_10X20},
|
||||
pixelcolor::{BinaryColor, Rgb565, Rgb666},
|
||||
prelude::{Point, *},
|
||||
primitives::{Circle, PrimitiveStyle},
|
||||
text::Text,
|
||||
};
|
||||
use embedded_graphics::prelude::DrawTargetExt;
|
||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||
use gpio::{Level, Output};
|
||||
use log::{error, info};
|
||||
use mipidsi::{Builder, interface::SpiInterface, models::ST7789, options::ColorOrder};
|
||||
use log::error;
|
||||
use mipidsi::{Builder, interface::SpiInterface, models::ST7789};
|
||||
|
||||
use crate::display::CoMoDisplay;
|
||||
|
||||
mod display;
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||
@@ -75,11 +73,9 @@ async fn main(spawner: Spawner) {
|
||||
.init(&mut embassy_time::Delay)
|
||||
.unwrap();
|
||||
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
Circle::new(Point::new(70, 100), 80)
|
||||
.into_styled(PrimitiveStyle::with_fill(Rgb565::RED))
|
||||
.draw(&mut display)
|
||||
.unwrap();
|
||||
let mut como_display = CoMoDisplay::new(display.color_converted());
|
||||
|
||||
let _ = como_display.draw();
|
||||
|
||||
loop {
|
||||
Timer::after_secs(1).await;
|
||||
|
||||
Reference in New Issue
Block a user