Make powerGetDetails return status, disable output on failure to read
-PC returns false always -Switch returns if either charge or charge status fails
This commit is contained in:
parent
233dfd2b2c
commit
a8ce7c2a6b
@ -64,7 +64,6 @@ void menuStartupPath(void);
|
|||||||
void menuStartup(void);
|
void menuStartup(void);
|
||||||
void themeMenuStartup(void);
|
void themeMenuStartup(void);
|
||||||
void menuLoop(void);
|
void menuLoop(void);
|
||||||
void menuExit(void);
|
|
||||||
|
|
||||||
static inline uint8_t BlendColor(uint32_t src, uint32_t dst, uint8_t alpha)
|
static inline uint8_t BlendColor(uint32_t src, uint32_t dst, uint8_t alpha)
|
||||||
{
|
{
|
||||||
|
@ -427,18 +427,23 @@ void drawCharge() {
|
|||||||
char chargeString[5];
|
char chargeString[5];
|
||||||
uint32_t batteryCharge;
|
uint32_t batteryCharge;
|
||||||
bool isCharging;
|
bool isCharging;
|
||||||
|
bool validPower;
|
||||||
|
|
||||||
|
validPower = powerGetDetails(&batteryCharge, &isCharging);
|
||||||
|
|
||||||
powerGetDetails(&batteryCharge, &isCharging);
|
if (validPower)
|
||||||
batteryCharge = (batteryCharge > 100) ? 100 : batteryCharge;
|
{
|
||||||
|
batteryCharge = (batteryCharge > 100) ? 100 : batteryCharge;
|
||||||
|
|
||||||
sprintf(chargeString, "%d%%", batteryCharge);
|
sprintf(chargeString, "%d%%", batteryCharge);
|
||||||
|
|
||||||
|
int tmpX = GetTextXCoordinate(interuiregular14, 1180, chargeString, 'r');
|
||||||
|
|
||||||
int tmpX = GetTextXCoordinate(interuiregular14, 1180, chargeString, 'r');
|
DrawText(interuiregular14, tmpX - 15, 0 + 47 + 10 + 21, themeCurrent.textColor, chargeString);
|
||||||
|
drawIcon(1180 - 11, 0 + 47 + 10 + 6, 10, 15, battery_icon_bin, themeCurrent.textColor);
|
||||||
DrawText(interuiregular14, tmpX - 15, 0 + 47 + 10 + 21, themeCurrent.textColor, chargeString);
|
if (isCharging)
|
||||||
drawIcon(1180 - 11, 0 + 47 + 10 + 6, 10, 15, battery_icon_bin, themeCurrent.textColor);
|
drawIcon(tmpX - 32, 0 + 47 + 10 + 6, 9, 15, charging_icon_bin, themeCurrent.textColor);
|
||||||
if (isCharging)
|
}
|
||||||
drawIcon(tmpX - 32, 0 + 47 + 10 + 6, 9, 15, charging_icon_bin, themeCurrent.textColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawBackBtn(menu_s* menu, bool emptyDir) {
|
void drawBackBtn(menu_s* menu, bool emptyDir) {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
void powerInit(void);
|
void powerInit(void);
|
||||||
|
|
||||||
void powerGetDetails(uint32_t *batteryCharge, bool *isCharging);
|
bool powerGetDetails(uint32_t *batteryCharge, bool *isCharging);
|
||||||
|
|
||||||
void powerExit(void);
|
void powerExit(void);
|
@ -3,18 +3,24 @@
|
|||||||
|
|
||||||
static bool psmInitialized;
|
static bool psmInitialized;
|
||||||
|
|
||||||
void powerGetDetails(uint32_t *batteryCharge, bool *isCharging) {
|
bool powerGetDetails(uint32_t *batteryCharge, bool *isCharging) {
|
||||||
ChargerType charger = ChargerType_None;
|
ChargerType charger = ChargerType_None;
|
||||||
|
bool hwReadsSucceeded = false;
|
||||||
|
Result rc = 0;
|
||||||
|
|
||||||
*isCharging = false;
|
*isCharging = false;
|
||||||
*batteryCharge = 0;
|
*batteryCharge = 0;
|
||||||
|
|
||||||
if (psmInitialized)
|
if (psmInitialized)
|
||||||
{
|
{
|
||||||
psmGetBatteryChargePercentage(batteryCharge);
|
rc = psmGetBatteryChargePercentage(batteryCharge);
|
||||||
psmGetChargerType(&charger);
|
hwReadsSucceeded = R_SUCCEEDED(rc);
|
||||||
|
rc = psmGetChargerType(&charger);
|
||||||
|
hwReadsSucceeded &= R_SUCCEEDED(rc);
|
||||||
*isCharging = (charger > ChargerType_None);
|
*isCharging = (charger > ChargerType_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return hwReadsSucceeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void powerInit(void) {
|
void powerInit(void) {
|
||||||
|
@ -8,7 +8,8 @@ void powerExit(void) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void powerGetDetails(uint32_t *batteryCharge, bool *isCharging)
|
bool powerGetDetails(uint32_t *batteryCharge, bool *isCharging)
|
||||||
*isCharging = false;
|
*isCharging = false;
|
||||||
*batteryCharge = 100;
|
*batteryCharge = 100;
|
||||||
|
return false;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user