Use Outputs type in Navigable trait
This commit is contained in:
@@ -8,8 +8,6 @@ use crate::views::view::View;
|
||||
use embassy_futures::select::{Either, select};
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
|
||||
pub type Mutex<T> = embassy_sync::mutex::Mutex<CriticalSectionRawMutex, T>;
|
||||
pub type Signal<T> = embassy_sync::signal::Signal<CriticalSectionRawMutex, T>;
|
||||
@@ -29,11 +27,7 @@ pub struct NewState {
|
||||
}
|
||||
|
||||
pub trait Navigable {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565> + Send,
|
||||
D::Error: core::fmt::Debug;
|
||||
// fn display<D>(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send;
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send;
|
||||
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = NewState> + Send;
|
||||
}
|
||||
|
||||
@@ -42,7 +36,7 @@ pub async fn run(mut inputs: Inputs, mut outputs: Outputs) {
|
||||
log::info!("starting navigation");
|
||||
|
||||
let mut state = NavigationState::new();
|
||||
state.screens.last().unwrap().display(&mut outputs.primary_display).await;
|
||||
state.screens.last().unwrap().display(&mut outputs).await;
|
||||
|
||||
loop {
|
||||
let selection = select(
|
||||
@@ -88,7 +82,7 @@ pub async fn run(mut inputs: Inputs, mut outputs: Outputs) {
|
||||
state.screens.push(new_state.view);
|
||||
|
||||
if action != Action::Timer || new_state.redraw {
|
||||
state.screens.last().unwrap().display(&mut outputs.primary_display).await;
|
||||
state.screens.last().unwrap().display(&mut outputs).await;
|
||||
}
|
||||
|
||||
Timer::after(Duration::from_millis(DEBOUNCE_DURATION_MILLIS)).await;
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
use crate::display::{shared_bus::{DualPrimaryDisplay, DualSecondaryDisplay}, tertiary_lcd::TertiaryI2cLcd};
|
||||
|
||||
use embedded_graphics::{
|
||||
draw_target::DrawTarget as _,
|
||||
pixelcolor::{Rgb565, RgbColor as _},
|
||||
};
|
||||
|
||||
use crate::display::{
|
||||
shared_bus::{DualPrimaryDisplay, DualSecondaryDisplay},
|
||||
tertiary_lcd::TertiaryI2cLcd,
|
||||
};
|
||||
|
||||
pub struct Outputs {
|
||||
pub primary_display: DualPrimaryDisplay<'static>,
|
||||
@@ -9,4 +15,14 @@ pub struct Outputs {
|
||||
// pub secondary_display_3: DualSecondaryDisplay<'static>,
|
||||
pub tertiary_display: TertiaryI2cLcd<'static>,
|
||||
pub _led_a: (),
|
||||
}
|
||||
}
|
||||
|
||||
impl Outputs {
|
||||
pub fn clear_screens(&mut self) {
|
||||
self.primary_display.clear(Rgb565::BLACK).unwrap();
|
||||
self.secondary_display_1.clear().unwrap();
|
||||
// self.secondary_display_2.clear().unwrap();
|
||||
// self.secondary_display_3.clear().unwrap();
|
||||
self.tertiary_display.clear().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user