From 7caef9c744fe483236cba664a7143c892bea99d8 Mon Sep 17 00:00:00 2001 From: Drath Date: Tue, 21 Jul 2026 20:57:39 +0200 Subject: [PATCH] tell it what ver it is --- meson.build | 16 ++++++++++++++++ src/main.c | 11 +++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index f2bc702..7f92d8f 100644 --- a/meson.build +++ b/meson.build @@ -24,6 +24,22 @@ srcs = [ cc = meson.get_compiler('c') +git = find_program('git', required : false) + +if git.found() + git_hash = run_command(git, 'rev-parse', '--short', 'HEAD', check: false).stdout().strip() + git_commits = run_command(git, 'rev-list', '--count', 'HEAD', check: false).stdout().strip() +else + git_hash = 'unknown' + git_commits = '0' +endif + +add_project_arguments( + '-DGIT_HASH="' + git_hash + '"', + '-DGIT_COMMITS="' + git_commits + '"', + language: 'c' +) + executable( 'linuxSmartie', srcs, diff --git a/src/main.c b/src/main.c index bf5cf03..eb49b7d 100644 --- a/src/main.c +++ b/src/main.c @@ -98,9 +98,16 @@ static void *display_thread(void *arg) { lcd_init(&lcd); lcd_set_backlight(&lcd, true); lcd_set_contrast(&lcd, lcd_contrast); - lcd_write_buf(&lcd, 1, 9, "Waiting for sensors..."); // need to center this still + + lcd_write_buf(&lcd, 0, 14, "linuxSmartie"); + lcd_writef(&lcd, 0, 2, "Ver. hash %s", GIT_HASH); + lcd_writef(&lcd, 0, 3, "Commit no. %s", GIT_COMMITS); lcd_flush_buf(&lcd); lcd_clear_buf(&lcd); + struct timespec next; + clock_gettime(CLOCK_REALTIME, &next); + timespec_add_ms(&next, refresh_interval_ms); + clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &next, nullptr); /* setup custom chars */ lcd_set_custom_char(&lcd, 0, &(lcd_glyph_t){16, 6, 9, 8, 8, 9, 6, 0}); // celcius @@ -172,7 +179,7 @@ static void *display_thread(void *arg) { } int main(void) { - applog(LOG_START, "linuxSmartie starting"); + applog(LOG_START, "linuxSmartie r%s (%s) starting", GIT_COMMITS, GIT_HASH); applog(LOG_DBG, "Compiled with %s", C_STD); /* see if another instance is up, quit if it is */