Moved primary lcd and navigation into dedicated files
This commit was merged in pull request #18.
This commit is contained in:
+15
-1
@@ -1 +1,15 @@
|
||||
// Navigation input module
|
||||
use esp_hal::gpio::{Input, InputConfig, Pull};
|
||||
use esp_hal::peripherals::GPIO38;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum NavCommand {
|
||||
NextCard,
|
||||
PrevCard,
|
||||
Select,
|
||||
ScanTag,
|
||||
}
|
||||
|
||||
pub fn init_navigation_button(pin: GPIO38<'static>) -> Input<'static> {
|
||||
let button_config = InputConfig::default().with_pull(Pull::Up);
|
||||
Input::new(pin, button_config)
|
||||
}
|
||||
|
||||
+35
-1
@@ -1 +1,35 @@
|
||||
// Navigation state module
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ScreenMode {
|
||||
CardDetail,
|
||||
DexGrid,
|
||||
Settings,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct NavigationState {
|
||||
pub current_screen: ScreenMode,
|
||||
pub card_index: usize,
|
||||
pub use_first_payload: bool,
|
||||
}
|
||||
|
||||
impl Default for NavigationState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
current_screen: ScreenMode::CardDetail,
|
||||
card_index: 0,
|
||||
use_first_payload: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NavigationState {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn toggle_payload(&mut self) -> bool {
|
||||
let current = self.use_first_payload;
|
||||
self.use_first_payload = !self.use_first_payload;
|
||||
current
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user