enum to string that is passed to the library, waiting for the enum based generic library

This commit is contained in:
Priec
2026-01-19 15:23:39 +01:00
parent 424c795170
commit 9910bf9402
2 changed files with 14 additions and 4 deletions

View File

@@ -39,13 +39,14 @@ pub async fn display_task(i2c: I2cDevice) {
let mut terminal = Terminal::new(backend).expect("terminal init failed"); let mut terminal = Terminal::new(backend).expect("terminal init failed");
let mut state = DisplayState::default(); let mut state = DisplayState::default();
let mut orchestrator = Orchestrator::<Screen>::new(); let mut orchestrator = Orchestrator::<Screen, Screen>::new();
let rx = receiver(); let rx = receiver();
// Register pages // Register pages
orchestrator.register_page("menu".into(), Screen::Menu); // Enum-based registration
orchestrator.register_page("imu".into(), Screen::Imu); orchestrator.register_page(Screen::Menu, Screen::Menu);
orchestrator.register_page("chat".into(), Screen::Chat); orchestrator.register_page(Screen::Imu, Screen::Imu);
orchestrator.register_page(Screen::Chat, Screen::Chat);
orchestrator.bind(Key::tab(), ComponentAction::Next); orchestrator.bind(Key::tab(), ComponentAction::Next);
orchestrator.bind(Key::enter(), ComponentAction::Select); orchestrator.bind(Key::enter(), ComponentAction::Select);

View File

@@ -11,6 +11,15 @@ use ratatui::{
}; };
use log::info; use log::info;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Screen {
Menu,
Imu,
Chat,
}
impl pages_tui::page::PageId for Screen {}
/// Focus targets - different per screen /// Focus targets - different per screen
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum PageFocus { pub enum PageFocus {