Check if there are batteries before checking if they are charging

pull/536/head
Alessandro Toia 3 years ago
parent 8980ff46bc
commit c6074b0f4d

@ -151,6 +151,7 @@ float BatteryStats::getPower(int batt_num) {
} }
bool BatteryStats::isCharging() { bool BatteryStats::isCharging() {
if (numBattery() > 0) {
for(int i =0; i < 2; i++) { for(int i =0; i < 2; i++) {
string syspath = battPath[i]; string syspath = battPath[i];
string status = syspath + "/status"; string status = syspath + "/status";
@ -167,11 +168,12 @@ bool BatteryStats::isCharging() {
return true; return true;
} }
} }
}
return false; return false;
} }
bool BatteryStats::fullCharge(){ bool BatteryStats::fullCharge(){
//check if both batteries are fully charged //check if both batteries are fully charged
int charged =0; int charged =0;

Loading…
Cancel
Save