9#include "DrawContext.h"
16 void drawBatteryIcon(M5Canvas *spi, uint32_t x, uint32_t y, uint16_t fgcolor, uint16_t bgcolor,
float offset, BatteryIconStatus batteryIconStatus, int32_t batteryLevel) {
17 spi->drawRect(x, y + 5, 5, 5, fgcolor);
18 spi->drawRect(x + 5, y, 30, 15, fgcolor);
19 int battery_width = 30 * (float)(batteryLevel / 100.0f);
20 spi->fillRect(x + 5 + 30 - battery_width, y, battery_width, 15, fgcolor);
21 if (batteryIconStatus == BatteryIconStatus::charging) {
22 spi->fillTriangle(x + 20, y, x + 15, y + 8, x + 20, y + 8, bgcolor);
23 spi->fillTriangle(x + 18, y + 7, x + 18, y + 15, x + 23, y + 7, bgcolor);
24 spi->drawLine(x + 20, y, x + 15, y + 8, fgcolor);
25 spi->drawLine(x + 20, y, x + 20, y + 7, fgcolor);
26 spi->drawLine(x + 18, y + 15, x + 23, y + 7, fgcolor);
27 spi->drawLine(x + 18, y + 8, x + 18, y + 15, fgcolor);
38 if (ctx->getBatteryIconStatus() != BatteryIconStatus::invisible) {
39 uint16_t primaryColor = ctx->getColorDepth() == 1 ? 1 : ctx->getColorPalette()->get(COLOR_PRIMARY);
40 uint16_t bgColor = ctx->getColorDepth() == 1 ? ERACER_COLOR : ctx->getColorPalette()->get(COLOR_BACKGROUND);
41 float offset = ctx->getBreath();
42 int32_t batteryLevel = ctx->getBatteryLevel();
43 drawBatteryIcon(spi, 285, 5, primaryColor, bgColor, -offset, ctx->getBatteryIconStatus(), batteryLevel);
Definition: BatteryIcon.h:14
Definition: BoundingRect.h:10
Definition: DrawContext.h:22
Definition: Drawable.h:13