| 72 | } |
| 73 | |
| 74 | void BaseTheme::fillBatteryIcon(const GfxRenderer& renderer, Rect rect, uint16_t percentage) const { |
| 75 | const bool charging = gpio.isUsbConnected(); |
| 76 | |
| 77 | const int maxFillWidth = rect.width - 5; |
| 78 | const int fillHeight = rect.height - 4; |
| 79 | if (maxFillWidth <= 0 || fillHeight <= 0) { |
| 80 | return; |
| 81 | } |
| 82 | // +1 to round up so we always fill at least one pixel |
| 83 | int filledWidth = percentage * maxFillWidth / 100 + 1; |
| 84 | if (filledWidth > maxFillWidth) { |
| 85 | filledWidth = maxFillWidth; |
| 86 | } |
| 87 | |
| 88 | // When charging, ensure minimum fill so lightning bolt is fully visible |
| 89 | constexpr int minFillForBolt = 8; |
| 90 | if (charging && filledWidth < minFillForBolt) { |
| 91 | filledWidth = std::min(minFillForBolt, maxFillWidth); |
| 92 | } |
| 93 | |
| 94 | renderer.fillRect(rect.x + 2, rect.y + 2, filledWidth, fillHeight); |
| 95 | |
| 96 | if (charging) { |
| 97 | drawBatteryLightningBolt(renderer, rect.x + 4, rect.y + 2); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void BaseTheme::drawBatteryLeft(const GfxRenderer& renderer, Rect rect, const bool showPercentage) const { |
| 102 | // Left aligned: icon on left, percentage on right (reader mode) |
nothing calls this directly
no test coverage detected