Inital commit
This commit is contained in:
53
src/main.rs
Normal file
53
src/main.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use embedded_graphics::{
|
||||
mono_font::{MonoTextStyle, iso_8859_14::FONT_10X20},
|
||||
pixelcolor::BinaryColor,
|
||||
prelude::*,
|
||||
text::{Alignment, Text, TextStyleBuilder},
|
||||
};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::g13::{G13, G13_LCD_COLUMNS, G13_LCD_ROWS};
|
||||
|
||||
mod g13;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut g13 = G13::new().await?;
|
||||
|
||||
g13.set_lcd_color(64, 0, 64).await?;
|
||||
|
||||
let mut _g13 = g13.clone();
|
||||
tokio::spawn(async move {
|
||||
let character_style = MonoTextStyle::new(&FONT_10X20, BinaryColor::On);
|
||||
let textstyle = TextStyleBuilder::new()
|
||||
.alignment(Alignment::Center)
|
||||
.baseline(embedded_graphics::text::Baseline::Middle)
|
||||
.build();
|
||||
|
||||
loop {
|
||||
let now = OffsetDateTime::now_utc();
|
||||
|
||||
let string = format!("{:0>2}:{:0>2}:{:0>2}", now.hour(), now.minute(), now.second());
|
||||
|
||||
_g13.clear(BinaryColor::Off).unwrap();
|
||||
Text::with_text_style(
|
||||
&string,
|
||||
Point::new(G13_LCD_COLUMNS / 2, G13_LCD_ROWS / 2),
|
||||
character_style,
|
||||
textstyle,
|
||||
)
|
||||
.draw(&mut _g13)
|
||||
.unwrap();
|
||||
|
||||
_g13.render().unwrap();
|
||||
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
});
|
||||
|
||||
loop {
|
||||
g13.read().await?;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user