From 34e2a9652f569e3c2aded57f50fad23106bb37a5 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 1 Jun 2026 20:41:10 -0400 Subject: [PATCH] Add low fuel indicator --- src/c/main.c | 14 ++++++++++---- src/c/palette_manip.c | 7 +------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/c/main.c b/src/c/main.c index f466e05..1640e6c 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -41,6 +41,7 @@ static GBitmap *s_f_icon; // tracking statics static bool s_pkjs_ready = false; +static bool s_low_fuel_indicator = false; static int s_batt_level; static uint8_t s_temp_level; @@ -50,9 +51,15 @@ static const uint8_t s_bar_width = 17; static const uint8_t s_bar_spacing = s_bar_height + 1; static void batt_callback(BatteryChargeState state) { - s_batt_level = state.charge_percent; + s_batt_level = state.charge_percent / 5; layer_mark_dirty(s_fuel_layer); - layer_mark_dirty(s_temp_layer); // TODO temporary!! + if (!s_low_fuel_indicator && s_batt_level < 5) { + replace_gbitmap_color(s_applied_fg, GColorChromeYellow, s_e_icon, s_e_layer); + s_low_fuel_indicator = true; + } else if (s_low_fuel_indicator && s_batt_level > 4) { + replace_gbitmap_color(GColorChromeYellow, s_applied_fg, s_e_icon, s_e_layer); + s_low_fuel_indicator = false; + } } // TODO use temperature (for now it updates with battery usage) @@ -69,10 +76,9 @@ static void temp_update_proc(Layer *layer, GContext *ctx) { static void fuel_update_proc(Layer *layer, GContext *ctx) { graphics_context_set_fill_color(ctx, GColorWhite); - const uint8_t bar_count = s_batt_level / 5; uint16_t bar_bottom_pos = 195; - for (uint8_t i = 0; i < bar_count; ++i) { + for (uint8_t i = 0; i < s_batt_level; ++i) { graphics_fill_rect(ctx, GRect(0, bar_bottom_pos, s_bar_width, s_bar_height), 0, GCornerNone); bar_bottom_pos -= s_bar_spacing; } diff --git a/src/c/palette_manip.c b/src/c/palette_manip.c index 09963e7..4a0b0eb 100644 --- a/src/c/palette_manip.c +++ b/src/c/palette_manip.c @@ -2,8 +2,6 @@ #include "palette_manip.h" -#ifdef PBL_COLOR - int get_num_palette_colors(GBitmap *b){ GBitmapFormat format = gbitmap_get_format(b); switch (format) { @@ -35,7 +33,4 @@ void replace_gbitmap_color(GColor color_to_replace, GColor replace_with_color, G if(bml != NULL){ layer_mark_dirty(bitmap_layer_get_layer(bml)); } - -} - -#endif \ No newline at end of file +} \ No newline at end of file