Skip to content

Commit

Permalink
Add splash screen, remove dummy hello screen
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Aug 10, 2024
1 parent cf2c74c commit b5f229b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
23 changes: 18 additions & 5 deletions firmware/src/display.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use embedded_graphics::mono_font::ascii::{FONT_10X20, FONT_6X13};
use embedded_graphics::mono_font::ascii::{FONT_10X20, FONT_6X10, FONT_9X18_BOLD};
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
Expand Down Expand Up @@ -48,10 +48,23 @@ impl<I2C: I2c> Display<I2C> {
Ok(())
}

/// Display hello screen
pub fn hello(&mut self) -> Result<(), Error> {
let style = MonoTextStyle::new(&FONT_6X13, BinaryColor::On);
Text::new("Hello, world!", Point::new(0, 20), style).draw(&mut self.driver)?;
/// Display splash screen
pub fn splash(&mut self) -> Result<(), Error> {
self.driver.clear(BinaryColor::Off)?;
Text::with_alignment(
"Touch 'n Drink",
Point::new(64, 28),
MonoTextStyle::new(&FONT_9X18_BOLD, BinaryColor::On),
Alignment::Center,
)
.draw(&mut self.driver)?;
Text::with_alignment(
concat!("v", env!("CARGO_PKG_VERSION")),
Point::new(64, 28 + 12),
MonoTextStyle::new(&FONT_6X10, BinaryColor::On),
Alignment::Center,
)
.draw(&mut self.driver)?;
self.driver.flush()?;
Ok(())
}
Expand Down
15 changes: 5 additions & 10 deletions firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ use esp_hal::peripherals::Peripherals;
use esp_hal::prelude::*;
use esp_hal::rng::Rng;
use esp_hal::system::SystemControl;
use esp_hal::timer::{
systimer::SystemTimer, timg::TimerGroup, ErasedTimer, OneShotTimer, PeriodicTimer,
};
use esp_hal::timer::systimer::SystemTimer;
use esp_hal::timer::timg::TimerGroup;
use esp_hal::timer::{ErasedTimer, OneShotTimer, PeriodicTimer};
use log::info;

// When you are okay with using a nightly compiler it's better to use https://docs.rs/static_cell/2.1.0/static_cell/macro.make_static.html
Expand Down Expand Up @@ -96,6 +96,7 @@ async fn main(_spawner: Spawner) {
// Panic on failure since without a display there's no reasonable way to tell the user
Err(err) => panic!("Display initialization failed: {:?}", err),
};
let _ = display.splash();

// Initialize keypad
let mut keypad = keypad::Keypad::new(
Expand Down Expand Up @@ -128,11 +129,6 @@ async fn main(_spawner: Spawner) {
// Panic on failure since an initialization error indicates a static configuration error
Err(err) => panic!("Wifi initialization failed: {:?}", err),
};

// Display hello screen
display.clear().unwrap();
display.hello().unwrap();

let mut displaying_key = false;
loop {
led.toggle();
Expand All @@ -145,8 +141,7 @@ async fn main(_spawner: Spawner) {
displaying_key = true;
}
Err(_) if displaying_key => {
display.clear().unwrap();
display.hello().unwrap();
display.splash().unwrap();
displaying_key = false;
}
_ => {}
Expand Down

0 comments on commit b5f229b

Please sign in to comment.