Skip to content

Commit

Permalink
Update ui_tanks.h
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Apr 22, 2023
1 parent 30d5cf9 commit 81a2d31
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions bbn_m5tough_active_boat/ui_tanks.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,33 @@ extern "C" {

static void tanks_update_cb() {
for (int i = 0; i < MAX_TANKS; i++) {
lv_bar_set_value(bar_tank[i], shipDataModel.tanks.tank[i].percent_of_full.pct, LV_ANIM_OFF);
float pct = shipDataModel.tanks.tank[i].percent_of_full.pct;
lv_bar_set_value(bar_tank[i], pct, LV_ANIM_OFF);
if (shipDataModel.tanks.tank[i].fluid_type == fluid_type_e::FUEL) {
lv_obj_set_style_bg_color(bar_tank[i], lv_palette_lighten(LV_PALETTE_GREEN, 1), LV_PART_INDICATOR);
lv_obj_set_style_radius(bar_tank[i], 6, LV_PART_MAIN);
lv_label_set_text(bar_tank_l[i], "Fuel\n--%");
lv_label_set_text(bar_tank_l[i], (String("Fuel\n") + String(pct, 1) + "%").c_str());
} else if (shipDataModel.tanks.tank[i].fluid_type == fluid_type_e::BLACK_WATER) {
lv_obj_set_style_bg_color(bar_tank[i], lv_palette_lighten(LV_PALETTE_RED, 1), LV_PART_INDICATOR);
lv_obj_set_style_radius(bar_tank[i], 6, LV_PART_MAIN);
lv_label_set_text(bar_tank_l[i], "Black\n--%");
lv_label_set_text(bar_tank_l[i], (String("Black\n") + String(pct, 1) + "%").c_str());
} else if (shipDataModel.tanks.tank[i].fluid_type == fluid_type_e::WASTE_WATER) {
lv_obj_set_style_bg_color(bar_tank[i], lv_palette_lighten(LV_PALETTE_RED, 1), LV_PART_INDICATOR);
lv_obj_set_style_radius(bar_tank[i], 6, LV_PART_MAIN);
lv_label_set_text(bar_tank_l[i], "Grey\n--%");
lv_label_set_text(bar_tank_l[i], (String("Grey\n") + String(pct, 1) + "%").c_str());
} else if (shipDataModel.tanks.tank[i].fluid_type == fluid_type_e::FRESH_WATER) {
lv_obj_set_style_radius(bar_tank[i], 6, LV_PART_MAIN);
lv_label_set_text(bar_tank_l[i], "Fresh\n--%");
lv_label_set_text(bar_tank_l[i], (String("Fresh\n") + String(pct, 1) + "%").c_str());
} else if (shipDataModel.tanks.tank[i].fluid_type == fluid_type_e::LUBRICATION) {
lv_obj_set_style_radius(bar_tank[i], 6, LV_PART_MAIN);
lv_obj_set_style_bg_color(bar_tank[i], lv_palette_lighten(LV_PALETTE_ORANGE, 1), LV_PART_INDICATOR);
lv_label_set_text(bar_tank_l[i], "Lube\n--%");
lv_label_set_text(bar_tank_l[i], (String("Lube\n") + String(pct, 1) + "%").c_str());
} else if (shipDataModel.tanks.tank[i].fluid_type == fluid_type_e::LIVE_WELL) {
lv_obj_set_style_radius(bar_tank[i], 6, LV_PART_MAIN);
lv_label_set_text(bar_tank_l[i], "Live Well\n--%");
lv_label_set_text(bar_tank_l[i], (String("Live Well\n") + String(pct, 1) + "%").c_str());
} else if (shipDataModel.tanks.tank[i].fluid_type == fluid_type_e::GAS) {
lv_obj_set_style_bg_color(bar_tank[i], lv_palette_lighten(LV_PALETTE_ORANGE, 1), LV_PART_INDICATOR);
lv_label_set_text(bar_tank_l[i], "Gas\n--%");
lv_label_set_text(bar_tank_l[i], (String("Gas\n") + String(pct, 1) + "%").c_str());
} else {
lv_obj_set_style_radius(bar_tank[i], 6, LV_PART_MAIN);
lv_label_set_text(bar_tank_l[i], "n/a");
Expand Down

0 comments on commit 81a2d31

Please sign in to comment.