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::app_info::AppInfoPage;
7use crate::ui::page::main::MainPage;
8use crate::ui::page::scratchpad::ScratchpadPage;
9
10mod page;
11pub(crate) mod flashing;
12
13pub(crate) enum MainGui {
14 MainPage(MainPage),
15 ScratchpadPage(ScratchpadPage),
16 AppInfoPage(AppInfoPage),
17}
18
19impl MainGui {
20 pub(crate) fn new() -> Self {
21 Self::MainPage(MainPage::new())
22 }
23
24 fn get_current_page(&self) -> &dyn Gui<Output = Option<Self>> {
25 match self {
26 MainGui::MainPage(page) => page,
27 MainGui::ScratchpadPage(page) => page,
28 MainGui::AppInfoPage(page) => page,
29 }
30 }
31
32 fn get_current_page_mut(&mut self) -> &mut dyn Gui<Output = Option<Self>> {
33 match self {
34 MainGui::MainPage(page) => page,
35 MainGui::ScratchpadPage(page) => page,
36 MainGui::AppInfoPage(page) => page,
37 }
38 }
39}
40
41impl Gui for MainGui {
42 type Output = ();
43
44 fn draw_init(&self, draw_target: &mut EpdDrawTarget) {
45 self.get_current_page().draw_init(draw_target);
46 }
47
48 fn tick(&mut self, draw_target: &mut EpdDrawTarget, ev: Event) -> Self::Output {
49 if let Some(gui) = self.get_current_page_mut().tick(draw_target, ev) {
50 *self = gui;
51
52 draw_target.clear(BinaryColor::Off).unwrap();
53 self.draw_init(draw_target);
54 draw_target.refresh(false);
55 }
56 }
57}