修复死循环

hdrplus
Matthew 1 year ago
parent 0fa112304a
commit 57381dc5e8

@ -689,17 +689,18 @@ float CPhoneDevice::QueryBattaryVoltage(int timesForAvg, bool* isCharging)
*isCharging = chargingBusVoltage > 10.0; *isCharging = chargingBusVoltage > 10.0;
} }
for (int idx = 0; idx < timesForAvg; ) int matched = 0;
for (int idx = 0; idx < timesForAvg; idx++)
{ {
val = GpioControl::getBatteryVoltage(); // // BatVol val = GpioControl::getBatteryVoltage(); // // BatVol
if (val > 0) if (val > 0)
{ {
totalVals += val > BATTARY_VOLTAGE_MAX ? BATTARY_VOLTAGE_MAX : val; totalVals += val > BATTARY_VOLTAGE_MAX ? BATTARY_VOLTAGE_MAX : val;
idx++; matched++;
} }
} }
return (float)totalVals / 1000.0 / timesForAvg; return (matched > 0) ? ((float)totalVals / 1000.0 / matched) : 0;
} }
bool CPhoneDevice::RequestPosition() bool CPhoneDevice::RequestPosition()

Loading…
Cancel
Save