Mainmenu #28
+6
-5
@@ -7,8 +7,9 @@
|
|||||||
)]
|
)]
|
||||||
#![deny(clippy::large_stack_frames)]
|
#![deny(clippy::large_stack_frames)]
|
||||||
|
|
||||||
|
use alloc::boxed::Box;
|
||||||
use creaturedex::card::mock::{MOCK_PAYLOAD, MOCK_PAYLOAD2};
|
use creaturedex::card::mock::{MOCK_PAYLOAD, MOCK_PAYLOAD2};
|
||||||
use creaturedex::display::primary_lcd::init_primary_lcd;
|
use creaturedex::display::primary_lcd::{PrimaryLcdDisplay, init_primary_lcd};
|
||||||
use creaturedex::display::views::card_view::render_nfc_payload;
|
use creaturedex::display::views::card_view::render_nfc_payload;
|
||||||
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
|
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
|
||||||
use creaturedex::navigation::inputs::Inputs;
|
use creaturedex::navigation::inputs::Inputs;
|
||||||
@@ -61,7 +62,7 @@ async fn main(spawner: Spawner) {
|
|||||||
|
|
||||||
log::info!("Setup complete, entering main loop");
|
log::info!("Setup complete, entering main loop");
|
||||||
|
|
||||||
let mut display = init_primary_lcd(
|
let display: &mut PrimaryLcdDisplay = Box::leak(Box::new(init_primary_lcd(
|
||||||
peripherals.SPI2,
|
peripherals.SPI2,
|
||||||
peripherals.GPIO36,
|
peripherals.GPIO36,
|
||||||
peripherals.GPIO35,
|
peripherals.GPIO35,
|
||||||
@@ -69,7 +70,7 @@ async fn main(spawner: Spawner) {
|
|||||||
peripherals.GPIO11,
|
peripherals.GPIO11,
|
||||||
peripherals.GPIO10,
|
peripherals.GPIO10,
|
||||||
peripherals.GPIO12,
|
peripherals.GPIO12,
|
||||||
);
|
)));
|
||||||
|
|
||||||
setup_wifi(peripherals.WIFI, peripherals.FLASH, &spawner).await;
|
setup_wifi(peripherals.WIFI, peripherals.FLASH, &spawner).await;
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut nav_state = NavigationState::new();
|
let mut nav_state = NavigationState::new();
|
||||||
|
|
||||||
let button_config = InputConfig::default().with_pull(Pull::Up);
|
let button_config = InputConfig::default().with_pull(Pull::Up);
|
||||||
let mut inputs = Inputs {
|
let inputs = Inputs {
|
||||||
up: Input::new(peripherals.GPIO38, button_config.clone()),
|
up: Input::new(peripherals.GPIO38, button_config.clone()),
|
||||||
down: Input::new(peripherals.GPIO0, button_config.clone()),
|
down: Input::new(peripherals.GPIO0, button_config.clone()),
|
||||||
left: Input::new(peripherals.GPIO1, button_config.clone()),
|
left: Input::new(peripherals.GPIO1, button_config.clone()),
|
||||||
@@ -100,5 +101,5 @@ async fn main(spawner: Spawner) {
|
|||||||
ok: Input::new(peripherals.GPIO4, button_config.clone()),
|
ok: Input::new(peripherals.GPIO4, button_config.clone()),
|
||||||
};
|
};
|
||||||
|
|
||||||
spawner.spawn(navigation::run(inputs).expect("run task failed"));
|
spawner.spawn(navigation::run(inputs, display).expect("run task failed"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
use crate::navigation::inputs::Inputs;
|
use crate::{display::primary_lcd::PrimaryLcdDisplay, navigation::inputs::Inputs};
|
||||||
|
|
||||||
|
use alloc::format;
|
||||||
|
use embedded_graphics::mono_font::MonoTextStyle;
|
||||||
|
use embedded_graphics::mono_font::ascii::FONT_6X10;
|
||||||
|
use embedded_graphics::pixelcolor::Rgb565;
|
||||||
|
use embedded_graphics::prelude::Point;
|
||||||
|
use embedded_graphics::prelude::RgbColor;
|
||||||
|
use embedded_graphics::text::Text;
|
||||||
|
use embedded_graphics::{Drawable, geometry::Size, primitives::Rectangle};
|
||||||
|
use embedded_graphics_core::draw_target::DrawTarget;
|
||||||
|
|
||||||
pub const MAX_SELECTED: i8 = 3;
|
pub const MAX_SELECTED: i8 = 3;
|
||||||
|
|
||||||
@@ -7,5 +17,44 @@ pub struct MainMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MainMenu {
|
impl MainMenu {
|
||||||
pub async fn display(self: &Self) {}
|
pub async fn display(&self, display: &mut PrimaryLcdDisplay<'static>) {
|
||||||
|
let style = MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE);
|
||||||
|
let selected_style = MonoTextStyle::new(&FONT_6X10, Rgb565::BLUE);
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("Last card"),
|
||||||
|
Point::new(20, 240),
|
||||||
|
if self.selected == 0 {
|
||||||
|
selected_style
|
||||||
|
} else {
|
||||||
|
style
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("Journal"),
|
||||||
|
Point::new(20, 250),
|
||||||
|
if self.selected == 1 {
|
||||||
|
selected_style
|
||||||
|
} else {
|
||||||
|
style
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("Settings"),
|
||||||
|
Point::new(20, 260),
|
||||||
|
if self.selected == 1 {
|
||||||
|
selected_style
|
||||||
|
} else {
|
||||||
|
style
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use crate::navigation::inputs::Inputs;
|
|
||||||
use crate::navigation::main_menu::{MAX_SELECTED, MainMenu};
|
use crate::navigation::main_menu::{MAX_SELECTED, MainMenu};
|
||||||
|
use crate::{display::primary_lcd::PrimaryLcdDisplay, navigation::inputs::Inputs};
|
||||||
|
|
||||||
use embassy_futures::select::Either6;
|
use embassy_futures::select::Either6;
|
||||||
use embassy_futures::select::select6;
|
use embassy_futures::select::select6;
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn run(mut inputs: Inputs) {
|
pub async fn run(mut inputs: Inputs, display: &'static mut PrimaryLcdDisplay<'static>) {
|
||||||
let mut state = MainMenu { selected: 0 };
|
let mut state = MainMenu { selected: 0 };
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
@@ -30,6 +30,6 @@ pub async fn run(mut inputs: Inputs) {
|
|||||||
|
|
||||||
state.selected = value;
|
state.selected = value;
|
||||||
|
|
||||||
state.display().await
|
state.display(display).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user