mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 13:09:43 +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;
|
||||
|
||||
unsigned short GMenu2X::getBatteryLevel() {
|
||||
if (!batteryHandle) return 0;
|
||||
if (usbHandle) {
|
||||
int usbval = 0;
|
||||
fscanf(usbHandle, "%d", &usbval);
|
||||
rewind(usbHandle);
|
||||
if (usbval == 1)
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (batteryHandle) {
|
||||
int battval = 0;
|
||||
fscanf(batteryHandle, "%d", &battval);
|
||||
rewind(batteryHandle);
|
||||
|
||||
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;
|
||||
|
||||
if (!usbHandle) return 0;
|
||||
int usbval = 0;
|
||||
fscanf(usbHandle, "%d", &usbval);
|
||||
rewind(usbHandle);
|
||||
if (usbval==1) return 6;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user