Skip to content

Commit

Permalink
amperage underflow fix
Browse files Browse the repository at this point in the history
  • Loading branch information
janpom committed Apr 16, 2019
1 parent e01ac4a commit 019755e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions davega_simple_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ uint16_t primary_item_color(t_screen_item screen_item, t_davega_data* data, t_da
uint16_t color = COLOR_WHITE;
if (screen_item == SCR_BATTERY_CURRENT || screen_item == SCR_MOTOR_CURRENT) {
float value = screen_item == SCR_BATTERY_CURRENT ? data->battery_amps : data->motor_amps;
if (value < 0)
color = COLOR_RED;
if (value >= 100)
color = COLOR_YELLOW;
if (value >= 200)
color = COLOR_RED;
color = COLOR_BLUEVIOLET;
}
else {
// speed
Expand All @@ -52,5 +54,5 @@ uint8_t primary_item_value(t_screen_item screen_item, t_davega_data* data, t_dav
default:
value = convert_speed(data->speed_kph, config->imperial_units);
}
return round(value) % 100;
return abs(round(value)) % 100;
}

0 comments on commit 019755e

Please sign in to comment.