mGUI: Add BATTERY_NOT_PRESENT state

This commit is contained in:
Vicki Pfau 2018-09-20 11:22:58 -07:00
parent b712a7208d
commit 9fb7485051
3 changed files with 7 additions and 1 deletions

View File

@ -47,7 +47,8 @@ enum {
BATTERY_HIGH = 3,
BATTERY_FULL = 4,
BATTERY_CHARGING = 8
BATTERY_CHARGING = 8,
BATTERY_NOT_PRESENT = 16
};
struct GUIBackground {

View File

@ -360,6 +360,8 @@ static int _batteryState(void) {
int state = 0;
if (R_SUCCEEDED(psmGetBatteryChargePercentage(&charge))) {
state = (charge + 12) / 25;
} else {
return BATTERY_NOT_PRESENT;
}
ChargerType type;
if (R_SUCCEEDED(psmGetChargerType(&type)) && type) {

View File

@ -260,6 +260,9 @@ void GUIDrawBattery(struct GUIParams* params) {
return;
}
int state = params->batteryState();
if (state == BATTERY_NOT_PRESENT) {
return;
}
uint32_t color = 0xFF000000;
if (state == (BATTERY_CHARGING | BATTERY_FULL)) {
color |= 0xFFC060;