Skip to content

Commit 019755e

Browse files
committed
amperage underflow fix
1 parent e01ac4a commit 019755e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

davega_simple_screen.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ uint16_t primary_item_color(t_screen_item screen_item, t_davega_data* data, t_da
2525
uint16_t color = COLOR_WHITE;
2626
if (screen_item == SCR_BATTERY_CURRENT || screen_item == SCR_MOTOR_CURRENT) {
2727
float value = screen_item == SCR_BATTERY_CURRENT ? data->battery_amps : data->motor_amps;
28+
if (value < 0)
29+
color = COLOR_RED;
2830
if (value >= 100)
2931
color = COLOR_YELLOW;
3032
if (value >= 200)
31-
color = COLOR_RED;
33+
color = COLOR_BLUEVIOLET;
3234
}
3335
else {
3436
// speed
@@ -52,5 +54,5 @@ uint8_t primary_item_value(t_screen_item screen_item, t_davega_data* data, t_dav
5254
default:
5355
value = convert_speed(data->speed_kph, config->imperial_units);
5456
}
55-
return round(value) % 100;
57+
return abs(round(value)) % 100;
5658
}

0 commit comments

Comments
 (0)