WIP scsi
This commit is contained in:
@@ -6,3 +6,4 @@ edition = "2024"
|
||||
[dependencies]
|
||||
abi = { path = "../../abi" }
|
||||
embedded-graphics = "0.8.1"
|
||||
kolibri-embedded-gui = "0.1.0"
|
||||
|
||||
@@ -2,18 +2,22 @@
|
||||
#![no_main]
|
||||
|
||||
extern crate alloc;
|
||||
use abi::{KeyCode, display::Display, embassy_time, get_key, print, sleep};
|
||||
use abi::{KeyCode, display::Display, get_key, print, sleep};
|
||||
use alloc::{boxed::Box, string::String, vec};
|
||||
use core::{panic::PanicInfo, pin::Pin};
|
||||
use embedded_graphics::{
|
||||
Drawable,
|
||||
geometry::{Dimensions, Point},
|
||||
mono_font::{MonoTextStyle, ascii::FONT_6X10},
|
||||
mono_font::{
|
||||
MonoTextStyle,
|
||||
ascii::{self, FONT_6X10},
|
||||
},
|
||||
pixelcolor::Rgb565,
|
||||
prelude::{Primitive, RgbColor, Size},
|
||||
primitives::{PrimitiveStyle, Rectangle},
|
||||
text::{Alignment, Text},
|
||||
};
|
||||
use kolibri_embedded_gui::{label::Label, style::medsize_rgb565_style, ui::Ui};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_info: &PanicInfo) -> ! {
|
||||
@@ -24,36 +28,20 @@ pub async fn main() {
|
||||
print("Starting Async Calculator app");
|
||||
let mut display = Display;
|
||||
|
||||
let character_style = MonoTextStyle::new(&FONT_6X10, Rgb565::RED);
|
||||
|
||||
let mut text = vec!['T', 'y', 'p', 'e'];
|
||||
let mut dirty = true;
|
||||
let mut last_bounds: Option<Rectangle> = None;
|
||||
|
||||
loop {
|
||||
if dirty {
|
||||
if let Some(bounds) = last_bounds {
|
||||
Rectangle::new(bounds.top_left, bounds.size)
|
||||
.into_styled(PrimitiveStyle::with_fill(Rgb565::BLACK))
|
||||
.draw(&mut display)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let mut ui = Ui::new_fullscreen(&mut display, medsize_rgb565_style());
|
||||
let text = text.iter().cloned().collect::<String>();
|
||||
let aligned_text = Text::with_alignment(
|
||||
&text,
|
||||
display.bounding_box().center(),
|
||||
character_style,
|
||||
Alignment::Center,
|
||||
);
|
||||
last_bounds = Some(aligned_text.bounding_box());
|
||||
|
||||
aligned_text.draw(&mut display).unwrap();
|
||||
// ui.clear_background();
|
||||
ui.add(Label::new(&text).with_font(ascii::FONT_10X20));
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
if let Some(event) = get_key() {
|
||||
dirty = true;
|
||||
match event.key {
|
||||
KeyCode::Char(ch) => {
|
||||
text.push(ch);
|
||||
@@ -67,6 +55,7 @@ pub async fn main() {
|
||||
KeyCode::Esc => return,
|
||||
_ => (),
|
||||
}
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user