Add time calculation to scan response

This commit is contained in:
Edith Boles
2026-03-16 02:23:53 -07:00
parent 448d883feb
commit 77aec099d8
3 changed files with 18831 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
#include "lvgl/lvgl.h" // IWYU pragma: keep
#include "miniaudio/miniaudio.h"
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "screen.h"
#include "pm3-lvgl.h"
@@ -22,7 +23,7 @@ void key_pressed(lv_event_t *event)
lv_key_t key = lv_indev_get_key(lv_indev_active());
printf("%u\n", key);
pthread_mutex_lock(&lvgl_mutex);
screen_response("Valid until 1:09pm", "$2.50", 0, 2000);
screen_response("Valid until 1:09pm", "$2.80", 0, 2000);
pthread_mutex_unlock(&lvgl_mutex);
ma_engine_play_sound(&engine, "assets/hop_adult.wav", NULL);
}
@@ -30,8 +31,14 @@ void key_pressed(lv_event_t *event)
void read_card(uint8_t status, uint8_t *version, uint16_t version_size,
uint8_t *data, uint16_t data_size)
{
char buf[50];
pthread_mutex_lock(&lvgl_mutex);
screen_response("Valid until 1:09pm", "$2.50", 0, 2000);
time_t curr_time;
time(&curr_time);
curr_time += 60*150;
struct tm *local_time = localtime(&curr_time);
strftime(buf, 50, "Valid until %-l:%M%P", local_time);
screen_response(buf, "$2.80", 0, 2000);
pthread_mutex_unlock(&lvgl_mutex);
ma_engine_play_sound(&engine, "assets/hop_adult.wav", NULL);
}

18819
src/res/dejavu_bold_64.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -20,6 +20,7 @@ LV_FONT_DECLARE(montserrat_15);
LV_FONT_DECLARE(dejavu_28);
LV_FONT_DECLARE(dejavu_52);
LV_FONT_DECLARE(dejavu_bold_10);
LV_FONT_DECLARE(dejavu_bold_64);
LV_FONT_DECLARE(dejavu_bold_73);
LV_FONT_DECLARE(dejavu_cbold_52);
LV_IMG_DECLARE(hop_arrow);
@@ -220,9 +221,9 @@ void screen_create(lv_obj_t *screen)
// scan response large
label_reply_big = lv_label_create(screen);
lv_label_set_text(label_reply_big, "Valid until Mar. 31");
lv_obj_set_style_text_font(label_reply_big, &dejavu_bold_73, 0);
lv_obj_set_style_text_font(label_reply_big, &dejavu_bold_64, 0);
lv_obj_set_style_text_color(label_reply_big, WHITE, 0);
lv_obj_align(label_reply_big, LV_ALIGN_CENTER, 0, 47);
lv_obj_align(label_reply_big, LV_ALIGN_CENTER, 0, 40);
lv_obj_add_flag(label_reply_big, LV_OBJ_FLAG_HIDDEN);
// scan response small