diff --git a/eepy-launcher/build.sh b/eepy-launcher/build.sh index 2072fc3..3e00f32 100755 --- a/eepy-launcher/build.sh +++ b/eepy-launcher/build.sh @@ -2,6 +2,7 @@ rm -rf out mkdir out +export EEPY_LAUNCHER_BUILD_DATE=$(date -I) cargo build --release elf2epb -i ../target/thumbv6m-none-eabi/release/eepy-launcher -o out/eepy-launcher.s00.epb truncate -s 128K out/eepy-launcher.s00.epb \ No newline at end of file diff --git a/eepy-launcher/src/ui/mod.rs b/eepy-launcher/src/ui/mod.rs index 6441ade..8c1f5e4 100644 --- a/eepy-launcher/src/ui/mod.rs +++ b/eepy-launcher/src/ui/mod.rs @@ -3,6 +3,7 @@ use embedded_graphics::prelude::*; use eepy_gui::draw_target::EpdDrawTarget; use eepy_gui::element::Gui; use eepy_sys::input_common::Event; +use crate::ui::page::about::AboutPage; use crate::ui::page::app_info::AppInfoPage; use crate::ui::page::main::MainPage; use crate::ui::page::scratchpad::ScratchpadPage; @@ -14,6 +15,7 @@ pub(crate) enum MainGui { MainPage(MainPage), ScratchpadPage(ScratchpadPage), AppInfoPage(AppInfoPage), + AboutPage(AboutPage), } impl MainGui { @@ -26,6 +28,7 @@ impl MainGui { MainGui::MainPage(page) => page, MainGui::ScratchpadPage(page) => page, MainGui::AppInfoPage(page) => page, + MainGui::AboutPage(page) => page, } } @@ -34,6 +37,7 @@ impl MainGui { MainGui::MainPage(page) => page, MainGui::ScratchpadPage(page) => page, MainGui::AppInfoPage(page) => page, + MainGui::AboutPage(page) => page, } } } diff --git a/eepy-launcher/src/ui/page/about.rs b/eepy-launcher/src/ui/page/about.rs new file mode 100644 index 0000000..d1c02fc --- /dev/null +++ b/eepy-launcher/src/ui/page/about.rs @@ -0,0 +1,56 @@ +use embedded_graphics::Drawable; +use embedded_graphics::mono_font::{ascii, MonoTextStyle}; +use embedded_graphics::pixelcolor::BinaryColor; +use embedded_graphics::prelude::Point; +use embedded_graphics::text::Text; +use eepy_gui::draw_target::EpdDrawTarget; +use eepy_gui::element::button::Button; +use eepy_gui::element::{Gui, DEFAULT_TEXT_STYLE}; +use eepy_sys::input_common::Event; +use crate::ui::MainGui; +use crate::ui::page::main::MainPage; + +const SMALL_ITALIC_TEXT_STYLE: MonoTextStyle = MonoTextStyle::new(&ascii::FONT_6X13_ITALIC, BinaryColor::On); + +pub(crate) struct AboutPage { + back_button: Button<'static>, +} + +impl Default for AboutPage { + fn default() -> Self { + Self { + back_button: Button::with_default_style_auto_sized(Point::new(10, 10), "Back", true), + } + } +} + +impl Gui for AboutPage { + type Output = Option; + + fn draw_init(&self, target: &mut EpdDrawTarget) { + Text::new(concat!("eepyOS (Launcher ", env!("CARGO_PKG_VERSION"), ")"), Point::new(5, 190), DEFAULT_TEXT_STYLE) + .draw(target) + .unwrap(); + Text::new(concat!("built ", env!("EEPY_LAUNCHER_BUILD_DATE")), Point::new(40, 210), DEFAULT_TEXT_STYLE) + .draw(target) + .unwrap(); + Text::new("(c) 2025 arthomnix - MIT licensed", Point::new(18, 300), SMALL_ITALIC_TEXT_STYLE) + .draw(target) + .unwrap(); + Text::new("https://tangled.org/@arthomnix.dev/eepy", Point::new(3, 316), SMALL_ITALIC_TEXT_STYLE) + .draw(target) + .unwrap(); + self.back_button.draw_init(target); + } + + fn tick(&mut self, target: &mut EpdDrawTarget, ev: Event) -> Self::Output { + let bb_out = self.back_button.tick(target, ev); + if bb_out.clicked { + return Some(MainGui::MainPage(MainPage::new())); + } else if bb_out.needs_refresh { + target.refresh(true); + } + + None + } +} \ No newline at end of file diff --git a/eepy-launcher/src/ui/page/main.rs b/eepy-launcher/src/ui/page/main.rs index 4eeef6c..f6d360f 100644 --- a/eepy-launcher/src/ui/page/main.rs +++ b/eepy-launcher/src/ui/page/main.rs @@ -7,25 +7,31 @@ use eepy_sys::exec::exec; use eepy_sys::header::Programs; use eepy_sys::input_common::Event; use crate::ui::MainGui; +use crate::ui::page::about::AboutPage; use crate::ui::page::app_info::AppInfoPage; use crate::ui::page::scratchpad::ScratchpadPage; pub(crate) struct MainPage { scratchpad_button: Button<'static>, + about_button: Button<'static>, app_buttons: [Option<(Button<'static>, u8)>; 32], } impl MainPage { - fn app_button(x: usize, y: usize, label: &'static str) -> Button<'static> { + fn grid_button(x: usize, y: usize, label: &'static str, touch_feedback_immediate_release: bool) -> Button<'static> { let x_coord = 10 + 115 * x as i32; let y_coord = 8 + 25 * y as i32; Button::with_default_style( Rectangle::new(Point::new(x_coord, y_coord), Size::new(105, 20)), label, - false, + touch_feedback_immediate_release, ) } + fn app_button(x: usize, y: usize, label: &'static str) -> Button<'static> { + Self::grid_button(x, y, label, false) + } + pub(crate) fn refresh_buttons(&mut self) { let mut programs = Programs::new(); @@ -48,11 +54,8 @@ impl MainPage { pub(crate) fn new() -> Self { let mut res = Self { - scratchpad_button: Button::with_default_style( - Rectangle::new(Point::new(10, 8), Size::new(105, 20)), - "Scratchpad", - true - ), + scratchpad_button: Self::grid_button(0, 0, "Scratchpad", true), + about_button: Self::grid_button(1, 15, "About", true), app_buttons: [const { None }; 32], }; res.refresh_buttons(); @@ -65,6 +68,11 @@ impl Gui for MainPage { fn draw_init(&self, draw_target: &mut EpdDrawTarget) { self.scratchpad_button.draw_init(draw_target); + + if self.app_buttons[31].is_none() { + self.about_button.draw_init(draw_target); + } + for b in &self.app_buttons { if let Some((button, _)) = b { button.draw_init(draw_target); @@ -75,13 +83,21 @@ impl Gui for MainPage { fn tick(&mut self, draw_target: &mut EpdDrawTarget, ev: Event) -> Self::Output { let mut needs_refresh = false; - let s = self.scratchpad_button.tick(draw_target, ev); - if s.clicked { + let sp_out = self.scratchpad_button.tick(draw_target, ev); + if sp_out.clicked { return Some(MainGui::ScratchpadPage(ScratchpadPage::new())); - } else if s.needs_refresh { + } else if sp_out.needs_refresh { draw_target.refresh(true); } + let about_out = self.about_button.tick(draw_target, ev); + if about_out.clicked { + return Some(MainGui::AboutPage(AboutPage::default())); + } else if about_out.needs_refresh { + draw_target.refresh(true); + } + + for b in &mut self.app_buttons[1..] { if let Some((button, s)) = b { let response = button.tick(draw_target, ev); diff --git a/eepy-launcher/src/ui/page/mod.rs b/eepy-launcher/src/ui/page/mod.rs index bb7aab6..e011c41 100644 --- a/eepy-launcher/src/ui/page/mod.rs +++ b/eepy-launcher/src/ui/page/mod.rs @@ -1,3 +1,4 @@ pub(super) mod main; pub(super) mod scratchpad; -pub(super) mod app_info; \ No newline at end of file +pub(super) mod app_info; +pub(super) mod about; \ No newline at end of file