Browse Source

Merge 9580d71a32 into adc631f315

pull/3054/merge
hansimgamr 8 hours ago
committed by GitHub
parent
commit
5b0f103252
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 17
      examples/companion_radio/ui-new/UITask.cpp
  2. 10
      examples/companion_radio/ui-new/icons.h

17
examples/companion_radio/ui-new/UITask.cpp

@ -141,11 +141,24 @@ class HomeScreen : public UIScreen {
int fillWidth = (batteryPercentage * (iconWidth - 4)) / 100;
display.fillRect(iconX + 2, iconY + 2, fillWidth, iconHeight - 4);
// show muted icon if buzzer is muted
// while charging, show a bolt (or a plug once full) just left of the battery,
// keeping the fill bar itself clean and uninterrupted
bool charging = board.isExternalPowered();
if (charging) {
// There's no charge-complete signal on most boards, so "full" is a high
// voltage band rather than an exact 100% (a real pack rarely reads 4.2V).
const int BATT_FULL_PCT = 95;
const uint8_t* symbol = (batteryPercentage >= BATT_FULL_PCT) ? plug_icon : charging_icon;
display.setColor(UIColor::title_txt);
display.drawXbm(iconX - 9, iconY + 1, symbol, 8, 8);
}
// show muted icon if buzzer is muted (shifted further left when the charging
// icon already occupies the slot immediately left of the battery)
#ifdef PIN_BUZZER
if (_task->isBuzzerQuiet()) {
display.setColor(UIColor::warning_txt);
display.drawXbm(iconX - 9, iconY + 1, muted_icon, 8, 8);
display.drawXbm(iconX - (charging ? 18 : 9), iconY + 1, muted_icon, 8, 8);
}
#endif
}

10
examples/companion_radio/ui-new/icons.h

@ -119,4 +119,14 @@ static const uint8_t advert_icon[] = {
static const uint8_t muted_icon[] = {
0x20, 0x6a, 0xea, 0xe4, 0xe4, 0xea, 0x6a, 0x20
};
// small lightning bolt, 8x8px, shown next to the battery icon while charging
static const uint8_t charging_icon[] = {
0x18, 0x30, 0x60, 0xFC, 0x18, 0x30, 0x60, 0xC0
};
// small power plug, 8x8px, shown next to the battery icon once fully charged
static const uint8_t plug_icon[] = {
0x24, 0x24, 0x7E, 0x7E, 0x7E, 0x3C, 0x18, 0x18
};
Loading…
Cancel
Save