ported into a generic library
This commit is contained in:
@@ -39,19 +39,19 @@ pub async fn display_task(i2c: I2cDevice) {
|
||||
let mut terminal = Terminal::new(backend).expect("terminal init failed");
|
||||
|
||||
let mut state = DisplayState::default();
|
||||
let mut orchestrator = Orchestrator::<Screen, Screen>::new();
|
||||
let mut orchestrator = Orchestrator::<Screen>::new();
|
||||
let rx = receiver();
|
||||
|
||||
// Register pages
|
||||
// Enum-based registration
|
||||
orchestrator.register_page(Screen::Menu, Screen::Menu);
|
||||
orchestrator.register_page(Screen::Imu, Screen::Imu);
|
||||
orchestrator.register_page(Screen::Chat, Screen::Chat);
|
||||
orchestrator.register(Screen::Menu);
|
||||
orchestrator.register(Screen::Imu);
|
||||
orchestrator.register(Screen::Chat);
|
||||
|
||||
orchestrator.bind(Key::tab(), ComponentAction::Next);
|
||||
orchestrator.bind(Key::enter(), ComponentAction::Select);
|
||||
|
||||
let _ = orchestrator.navigate_to("menu".into());
|
||||
let _ = orchestrator.navigate_to(Screen::Menu);
|
||||
|
||||
info!("Display ready");
|
||||
|
||||
@@ -60,27 +60,27 @@ pub async fn display_task(i2c: I2cDevice) {
|
||||
match cmd {
|
||||
DisplayCommand::PushKey(key) => {
|
||||
if key == Key::tab() {
|
||||
orchestrator.focus_manager_mut().wrap_next();
|
||||
orchestrator.focus_manager_mut().next();
|
||||
} else if key == Key::enter() {
|
||||
if let Ok(events) = orchestrator.process_frame(key) {
|
||||
for event in events {
|
||||
match event {
|
||||
ScreenEvent::GoToImu => {
|
||||
let _ = orchestrator.navigate_to("imu".into());
|
||||
let _ = orchestrator.navigate_to(Screen::Imu);
|
||||
}
|
||||
ScreenEvent::GoToChat => {
|
||||
let _ = orchestrator.navigate_to("chat".into());
|
||||
let _ = orchestrator.navigate_to(Screen::Chat);
|
||||
}
|
||||
ScreenEvent::NavigatePrev => {
|
||||
if let Some(cur) = orchestrator.current() {
|
||||
let prev = cur.prev();
|
||||
let _ = orchestrator.navigate_to(prev.to_str().into());
|
||||
let _ = orchestrator.navigate_to(prev);
|
||||
}
|
||||
}
|
||||
ScreenEvent::NavigateNext => {
|
||||
if let Some(cur) = orchestrator.current() {
|
||||
let next = cur.next();
|
||||
let _ = orchestrator.navigate_to(next.to_str().into());
|
||||
let _ = orchestrator.navigate_to(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user