feat(color): add color options for radio info widget battery level indicator (#4845)
This commit is contained in:
@@ -85,13 +85,8 @@ class RadioInfoWidget : public TopBarWidget
|
||||
batteryFill = lv_obj_create(lvobj);
|
||||
lv_obj_set_pos(batteryFill, W_AUDIO_X + 1, 26);
|
||||
lv_obj_set_size(batteryFill, 20, 9);
|
||||
lv_obj_set_style_bg_color(batteryFill, lv_palette_main(LV_PALETTE_GREEN),
|
||||
LV_PART_MAIN);
|
||||
lv_obj_set_style_bg_color(batteryFill, lv_palette_main(LV_PALETTE_AMBER),
|
||||
LV_PART_MAIN | LV_STATE_USER_1);
|
||||
lv_obj_set_style_bg_color(batteryFill, lv_palette_main(LV_PALETTE_RED),
|
||||
LV_PART_MAIN | LV_STATE_USER_2);
|
||||
lv_obj_set_style_bg_opa(batteryFill, LV_OPA_COVER, LV_PART_MAIN);
|
||||
update();
|
||||
|
||||
// RSSI bars
|
||||
const uint8_t rssiBarsHeight[] = {5, 10, 15, 21, 31};
|
||||
@@ -107,6 +102,21 @@ class RadioInfoWidget : public TopBarWidget
|
||||
checkEvents();
|
||||
}
|
||||
|
||||
void update() override
|
||||
{
|
||||
lv_color_t color;
|
||||
|
||||
// get colors from options
|
||||
color.full = persistentData->options[2].value.unsignedValue;
|
||||
lv_obj_set_style_bg_color(batteryFill, color, LV_PART_MAIN);
|
||||
|
||||
color.full = persistentData->options[1].value.unsignedValue;
|
||||
lv_obj_set_style_bg_color(batteryFill, color, LV_PART_MAIN | LV_STATE_USER_1);
|
||||
|
||||
color.full = persistentData->options[0].value.unsignedValue;
|
||||
lv_obj_set_style_bg_color(batteryFill, color, LV_PART_MAIN | LV_STATE_USER_2);
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
TopBarWidget::checkEvents();
|
||||
@@ -175,6 +185,8 @@ class RadioInfoWidget : public TopBarWidget
|
||||
}
|
||||
}
|
||||
|
||||
static const ZoneOption options[];
|
||||
|
||||
protected:
|
||||
uint8_t lastVol = 0;
|
||||
uint8_t lastBatt = 0;
|
||||
@@ -194,8 +206,14 @@ class RadioInfoWidget : public TopBarWidget
|
||||
#endif
|
||||
};
|
||||
|
||||
BaseWidgetFactory<RadioInfoWidget> RadioInfoWidget("Radio Info", nullptr,
|
||||
"Radio Info");
|
||||
const ZoneOption RadioInfoWidget::options[] = {
|
||||
{STR_LOW_BATT_COLOR, ZoneOption::Color, RGB(0xF4, 0x43, 0x36)},
|
||||
{STR_MID_BATT_COLOR, ZoneOption::Color, RGB(0xFF, 0xC1, 0x07)},
|
||||
{STR_HIGH_BATT_COLOR, ZoneOption::Color, RGB(0x4C, 0xAF, 0x50)},
|
||||
{nullptr, ZoneOption::Bool}};
|
||||
|
||||
BaseWidgetFactory<RadioInfoWidget> RadioInfoWidget("Radio Info", RadioInfoWidget::options,
|
||||
STR_RADIO_INFO_WIDGET);
|
||||
|
||||
// Adjustment to make main view date/time align with model/radio settings views
|
||||
#if LCD_W > LCD_H
|
||||
@@ -212,6 +230,7 @@ class DateTimeWidget : public TopBarWidget
|
||||
TopBarWidget(factory, parent, rect, persistentData)
|
||||
{
|
||||
dateTime = new HeaderDateTime(lvobj, DT_OFFSET, 3);
|
||||
update();
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
@@ -224,13 +243,17 @@ class DateTimeWidget : public TopBarWidget
|
||||
if (t.tm_min != lastMinute) {
|
||||
lastMinute = t.tm_min;
|
||||
dateTime->update();
|
||||
// get color from options
|
||||
LcdFlags color =
|
||||
COLOR2FLAGS(persistentData->options[0].value.unsignedValue);
|
||||
dateTime->setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void update() override
|
||||
{
|
||||
// get color from options
|
||||
LcdFlags color =
|
||||
COLOR2FLAGS(persistentData->options[0].value.unsignedValue);
|
||||
dateTime->setColor(color);
|
||||
}
|
||||
|
||||
HeaderDateTime* dateTime = nullptr;
|
||||
int8_t lastMinute = -1;
|
||||
|
||||
@@ -244,7 +267,7 @@ const ZoneOption DateTimeWidget::options[] = {
|
||||
|
||||
BaseWidgetFactory<DateTimeWidget> DateTimeWidget("Date Time",
|
||||
DateTimeWidget::options,
|
||||
"Date Time");
|
||||
STR_DATE_TIME_WIDGET);
|
||||
|
||||
#if defined(INTERNAL_GPS)
|
||||
|
||||
@@ -285,6 +308,6 @@ class InternalGPSWidget : public TopBarWidget
|
||||
};
|
||||
|
||||
BaseWidgetFactory<InternalGPSWidget> InternalGPSWidget("Internal GPS", nullptr,
|
||||
"Internal GPS");
|
||||
STR_INT_GPS_LABEL);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user