Add low fuel indicator

This commit is contained in:
2026-06-01 20:41:10 -04:00
parent 8717dcc6a4
commit 34e2a9652f
2 changed files with 11 additions and 10 deletions
+10 -4
View File
@@ -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;
}
+1 -6
View File
@@ -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
}