firmware for my Touchscreen E-Paper Input Module for Framework Laptop 16
1use embedded_graphics::pixelcolor::BinaryColor;
2use embedded_graphics::prelude::*;
3use eepy_gui::draw_target::EpdDrawTarget;
4use eepy_gui::element::Gui;
5use eepy_sys::input_common::Event;
6use crate::ui::page::about::AboutPage;
7use crate::ui::page::app_info::AppInfoPage;
8use crate::ui::page::main::MainPage;
9use crate::ui::page::scratchpad::ScratchpadPage;
10
11mod page;
12pub(crate) mod flashing;
13
14pub(crate) enum MainGui {
15 MainPage(MainPage),
16 ScratchpadPage(ScratchpadPage),
17 AppInfoPage(AppInfoPage),
18 AboutPage(AboutPage),
19}
20
21impl MainGui {
22 pub(crate) fn new() -> Self {
23 Self::MainPage(MainPage::new())
24 }
25
26 fn get_current_page(&self) -> &dyn Gui<Output = Option<Self>> {
27 match self {
28 MainGui::MainPage(page) => page,
29 MainGui::ScratchpadPage(page) => page,
30 MainGui::AppInfoPage(page) => page,
31 MainGui::AboutPage(page) => page,
32 }
33 }
34
35 fn get_current_page_mut(&mut self) -> &mut dyn Gui<Output = Option<Self>> {
36 match self {
37 MainGui::MainPage(page) => page,
38 MainGui::ScratchpadPage(page) => page,
39 MainGui::AppInfoPage(page) => page,
40 MainGui::AboutPage(page) => page,
41 }
42 }
43}
44
45impl Gui for MainGui {
46 type Output = ();
47
48 fn draw_init(&self, draw_target: &mut EpdDrawTarget) {
49 self.get_current_page().draw_init(draw_target);
50 }
51
52 fn tick(&mut self, draw_target: &mut EpdDrawTarget, ev: Event) -> Self::Output {
53 if let Some(gui) = self.get_current_page_mut().tick(draw_target, ev) {
54 *self = gui;
55
56 draw_target.clear(BinaryColor::Off).unwrap();
57 self.draw_init(draw_target);
58 draw_target.refresh(false);
59 }
60 }
61}