This fundamentally doesn't work..?

This commit is contained in:
2026-02-14 16:17:30 +01:00
parent 112820bf1f
commit 87490152bd
4 changed files with 61 additions and 23 deletions

View File

@@ -3,32 +3,65 @@ pub(super) mod widgets;
use std::collections::VecDeque;
use embedded_graphics::{pixelcolor::BinaryColor, prelude::DrawTarget};
use g13_driver::G13Event;
use embedded_graphics::{
Drawable,
draw_target::DrawTarget,
mono_font::{MonoTextStyle, ascii::FONT_6X10},
pixelcolor::BinaryColor,
prelude::Point,
text::{Alignment, Baseline, LineHeight, Text, TextStyle, TextStyleBuilder},
};
use g13_driver::{G13Event, Vec2};
use super::app::widgets::Page;
type Color = BinaryColor;
const CHARACTER_STYLE: MonoTextStyle<'static, BinaryColor> =
MonoTextStyle::new(&FONT_6X10, BinaryColor::On);
const TEXT_STYLE: TextStyle = TextStyleBuilder::new()
.baseline(Baseline::Top)
.alignment(Alignment::Left)
.build();
pub struct App {
pages: VecDeque<Box<dyn Page>>,
joy: Vec2<f32>,
}
impl App {
pub fn new() -> Self {
Self {
pages: VecDeque::new(),
joy: Vec2::new(0.0, 0.0),
}
}
pub fn update(&mut self, event: G13Event) {
println!("{:?}", event);
match event {
G13Event::Axis(x, y) => {
self.joy.x = x;
self.joy.y = y;
}
G13Event::Button(_button, (_prev, _value)) => { /* noop */ }
}
}
pub fn draw<D>(&mut self, display: &mut D) -> Result<(), Box<dyn std::error::Error>>
pub fn draw<D>(&mut self, display: &mut D)
where
D: DrawTarget<Color = Color>,
{
Ok(())
if let Some(last_page) = self.pages.iter().last() {
last_page.draw(display);
}
// let string = format!(
// "{}x{}",
// (self.joy.x * 256.0) as i32,
// (self.joy.y * 256.0) as i32
// );
// let text = Text::with_text_style(&string, Point::new(1, 1), CHARACTER_STYLE, TEXT_STYLE);
// let _ = text.draw(display);
}
}