Skip to content

Commit

Permalink
Move version string constants to root module
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Aug 10, 2024
1 parent 268d70f commit 2af364d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions firmware/src/display.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::{GIT_SHA_STR, VERSION_STR};
use embedded_graphics::mono_font::ascii::{FONT_10X20, FONT_5X8, FONT_6X10, FONT_9X18_BOLD};
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::pixelcolor::BinaryColor;
Expand Down Expand Up @@ -71,14 +72,14 @@ impl<I2C: I2c> Display<I2C> {
)
.draw(&mut self.driver)?;
Text::with_alignment(
concat!("v", env!("CARGO_PKG_VERSION")),
VERSION_STR,
Point::new(63, 28 + 12),
MonoTextStyle::new(&FONT_6X10, BinaryColor::On),
Alignment::Center,
)
.draw(&mut self.driver)?;
Text::with_alignment(
env!("GIT_SHORT_SHA"),
GIT_SHA_STR,
Point::new(127, 63),
MonoTextStyle::new(&FONT_5X8, BinaryColor::On),
Alignment::Right,
Expand Down
4 changes: 4 additions & 0 deletions firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ macro_rules! mk_static {
}};
}

static VERSION_STR: &str = concat!("v", env!("CARGO_PKG_VERSION"));
static GIT_SHA_STR: &str = env!("GIT_SHORT_SHA");

#[main]
async fn main(_spawner: Spawner) {
let peripherals = Peripherals::take();
Expand All @@ -79,6 +82,7 @@ async fn main(_spawner: Spawner) {

// Initialize logging
esp_println::logger::init_logger_from_env();
info!("Touch 'n Drink {} ({})", VERSION_STR, GIT_SHA_STR);

// Initialize I2C controller
let i2c = I2C::new(
Expand Down

0 comments on commit 2af364d

Please sign in to comment.