Add progress counter

This commit is contained in:
RandyTheSilly committed 2026-10-30 20:16:51 -04:00
1 parent 23518c7af9
commit 530a2b82ab
1 file changed
+26 -12
+26 -12
View File
@@ -17,7 +17,7 @@ static Layer *s_top_bar_layer;
static Layer *s_bottom_bar_layer;
// static TextLayer *s_time_txt_layer;
static TextLayer *s_countdown_txt_layer;
// static TextLayer *s_progress_txt_layer;
static TextLayer *s_progress_txt_layer;
static TextLayer *s_status_txt_layer;
//// setter
static BitmapLayer *s_clock_bmp_layer;
@@ -64,8 +64,9 @@ static bool s_skip_current_day = false;
static uint8_t s_current_triangle_num;
static uint8_t s_solution_indices[3];
static uint8_t s_selected_indices[3] = {9, 9, 9};
static uint8_t s_awareness_countdown_int = 0;
static char s_awareness_countdown_buf[4];
static uint8_t s_countdown_int = 0;
static char s_countdown_buf[4];
static char s_progress_buf[7];
static uint32_t s_vibe_segments[5];
static VibePattern s_vibe_pattern;
@@ -412,16 +413,20 @@ static void update_for_new_triangle() {
};
// setup countdown
s_awareness_countdown_int = settings.TriangleSecsMin + ((settings.TriangleCount - s_current_triangle_num) * settings.TriangleSecsStep);
snprintf(s_awareness_countdown_buf, sizeof(s_awareness_countdown_buf), "%03u", s_awareness_countdown_int);
text_layer_set_text(s_countdown_txt_layer, s_awareness_countdown_buf);
s_countdown_int = settings.TriangleSecsMin + ((settings.TriangleCount - s_current_triangle_num) * settings.TriangleSecsStep);
snprintf(s_countdown_buf, sizeof(s_countdown_buf), "%03u", s_countdown_int);
text_layer_set_text(s_countdown_txt_layer, s_countdown_buf);
// set progress counter
snprintf(s_progress_buf, sizeof(s_progress_buf), "%d/%d ", s_current_triangle_num, settings.TriangleCount);
text_layer_set_text(s_progress_txt_layer, s_progress_buf);
}
static void awareness_alarm_seconds_handler(struct tm *tick_time, TimeUnits units_changed) {
s_awareness_countdown_int--;
snprintf(s_awareness_countdown_buf, sizeof(s_awareness_countdown_buf), "%03u", s_awareness_countdown_int);
text_layer_set_text(s_countdown_txt_layer, s_awareness_countdown_buf);
if (s_awareness_countdown_int == 0) {
s_countdown_int--;
snprintf(s_countdown_buf, sizeof(s_countdown_buf), "%03u", s_countdown_int);
text_layer_set_text(s_countdown_txt_layer, s_countdown_buf);
if (s_countdown_int == 0) {
send_zap(settings.PavlokIntensity);
if (s_current_triangle_num > 1) {
s_current_triangle_num--;
@@ -502,7 +507,7 @@ static void alarm_select_hold_handler(void *recognizer, void *ctx) {
}
}
if (s_awareness_countdown_int > 0) {
if (s_countdown_int > 0) {
if (s_current_triangle_num == settings.TriangleCount) {
tick_timer_service_unsubscribe(); // alarm is fully disarmed - prevent stimulus in confirmation window
wakeup_service_subscribe(NULL); // ignore wakeup events to avoid overwriting new alarm
@@ -698,14 +703,23 @@ static void alarm_window_load() {
s_drop_window,
(WindowHandlers){.load = drop_menu_window_load, .unload = drop_menu_window_unload});
static const GRect s_top_bar_text_grect = GRect(0, (s_small_top_bar_height / 2) - PBL_IF_ROUND_ELSE(6, 10), PBL_DISPLAY_WIDTH, s_small_top_bar_height);
// countdown
s_countdown_txt_layer = text_layer_create(GRect(0, (s_small_top_bar_height / 2) - PBL_IF_ROUND_ELSE(6, 10), PBL_DISPLAY_WIDTH, s_small_top_bar_height));
s_countdown_txt_layer = text_layer_create(s_top_bar_text_grect);
text_layer_set_background_color(s_countdown_txt_layer, GColorClear);
text_layer_set_text_color(s_countdown_txt_layer, GColorWhite);
text_layer_set_text_alignment(s_countdown_txt_layer, GTextAlignmentCenter);
text_layer_set_font(s_countdown_txt_layer, s_font_lecoish_small);
layer_add_child(window_layer, text_layer_get_layer(s_countdown_txt_layer));
// progress
s_progress_txt_layer = text_layer_create(s_top_bar_text_grect);
text_layer_set_background_color(s_progress_txt_layer, GColorClear);
text_layer_set_text_color(s_progress_txt_layer, GColorWhite);
text_layer_set_text_alignment(s_progress_txt_layer, GTextAlignmentRight);
text_layer_set_font(s_progress_txt_layer, s_font_lecoish_small);
layer_add_child(window_layer, text_layer_get_layer(s_progress_txt_layer));
// configure UI around current triangle in s_triangle_layer
update_for_new_triangle();