feat: add kernel ACPI support for querying battery percentage, add battery indicator to desktop, move log state to 0:/state directory
This commit is contained in:
1 parent
0a18b2cf2d
commit
e641500b40
34 files changed
+2461
-100
No files matched your search
@@ -210,6 +210,33 @@ void gui::desktop_draw_panel(DesktopState* ds) {
|
||||
} else {
|
||||
ds->wifi_icon_rect = {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
// Battery, leftmost of the status icons. Only a machine that reported a
|
||||
// battery device at startup gets one; a desktop shows nothing here.
|
||||
if (ds->battery_present && ds->icon_battery.pixels) {
|
||||
ds->battery_icon_rect = {next_icon_x, icon_y, 16, 16};
|
||||
next_icon_x -= 16 + 10;
|
||||
|
||||
// The glyph already encodes level and charging state, and the charging
|
||||
// variants carry their own green, so it is blitted as loaded. A
|
||||
// critical battery is the one case worth shouting about.
|
||||
if (ds->battery_info.present && ds->battery_info.critical
|
||||
&& !ds->battery_info.charging) {
|
||||
uint32_t* src = ds->icon_battery.pixels;
|
||||
uint32_t tinted[256];
|
||||
for (int p = 0; p < 16 * 16; p++) {
|
||||
uint8_t a = (src[p] >> 24) & 0xFF;
|
||||
tinted[p] = ((uint32_t)a << 24) | 0x00CC3333;
|
||||
}
|
||||
fb.blit_alpha(ds->battery_icon_rect.x, icon_y, 16, 16, tinted);
|
||||
} else {
|
||||
fb.blit_alpha(ds->battery_icon_rect.x, icon_y,
|
||||
ds->icon_battery.width, ds->icon_battery.height,
|
||||
ds->icon_battery.pixels);
|
||||
}
|
||||
} else {
|
||||
ds->battery_icon_rect = {0, 0, 0, 0};
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in new issue
Block a user