mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-26 00:20:38 +02:00
Check if USB cable is plugged before returning the battery level.
This commit is contained in:
parent
64db1d7912
commit
7484ad2ef0
@ -1461,21 +1461,25 @@ typedef struct {
|
|||||||
} MMSP2ADC;
|
} MMSP2ADC;
|
||||||
|
|
||||||
unsigned short GMenu2X::getBatteryLevel() {
|
unsigned short GMenu2X::getBatteryLevel() {
|
||||||
if (!batteryHandle) return 0;
|
if (usbHandle) {
|
||||||
int battval = 0;
|
int usbval = 0;
|
||||||
fscanf(batteryHandle, "%d", &battval);
|
fscanf(usbHandle, "%d", &usbval);
|
||||||
rewind(batteryHandle);
|
rewind(usbHandle);
|
||||||
if (battval>90) return 5;
|
if (usbval == 1)
|
||||||
if (battval>70) return 4;
|
return 6;
|
||||||
if (battval>50) return 3;
|
}
|
||||||
if (battval>30) return 2;
|
|
||||||
if (battval>10) return 1;
|
|
||||||
|
|
||||||
if (!usbHandle) return 0;
|
if (batteryHandle) {
|
||||||
int usbval = 0;
|
int battval = 0;
|
||||||
fscanf(usbHandle, "%d", &usbval);
|
fscanf(batteryHandle, "%d", &battval);
|
||||||
rewind(usbHandle);
|
rewind(batteryHandle);
|
||||||
if (usbval==1) return 6;
|
|
||||||
|
if (battval>90) return 5;
|
||||||
|
if (battval>70) return 4;
|
||||||
|
if (battval>50) return 3;
|
||||||
|
if (battval>30) return 2;
|
||||||
|
if (battval>10) return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user