调整电池电压接口和实现

lowmem
Matthew 1 month ago
parent e4e174a083
commit dc17a15210

@ -1266,18 +1266,19 @@ bool CPhoneDevice::EnableGPS(bool enabled)
return true;
}
float CPhoneDevice::QueryBattaryVoltage(int timesForAvg, bool* isCharging)
int CPhoneDevice::QueryBattaryVoltage(int timesForAvg, int* chargingVoltage)
{
if (timesForAvg <= 0)
{
return 0.0f;
timesForAvg = 1;
}
int val = 0;
int totalVals = 0;
float chargingBusVoltage = 0.0f;
int cv = 0;
int idx = 0;
XYLOG(XYLOG_SEVERITY_DEBUG, "WorkStatus BusVoltage");
int matched = 0;
for (idx = 0; idx < timesForAvg; idx++)
{
// auto now = std::chrono::system_clock::now();
@ -1287,18 +1288,19 @@ float CPhoneDevice::QueryBattaryVoltage(int timesForAvg, bool* isCharging)
// XYLOG(XYLOG_SEVERITY_DEBUG, "WorkStatus BusVoltage val=%d, time=%lld", val, static_cast<long long>(duration));
if (val > 1000)
{
chargingBusVoltage = (float)val / 1000.0;
cv += val;
matched++;
break;
}
}
XYLOG(XYLOG_SEVERITY_DEBUG, "WorkStatus BusVoltage end");
if (isCharging != NULL)
if (chargingVoltage != NULL)
{
*isCharging = chargingBusVoltage > DEFAULT_WARNING_CHARGING_BUS_VOL;
*chargingVoltage = matched > 0 ? (cv / matched) : 0;
}
XYLOG(XYLOG_SEVERITY_DEBUG, "WorkStatus BatteryVoltage");
int matched = 0;
matched = 0;
for (int idx = 0; idx < timesForAvg; idx++)
{
// auto now3 = std::chrono::system_clock::now();
@ -1313,7 +1315,7 @@ float CPhoneDevice::QueryBattaryVoltage(int timesForAvg, bool* isCharging)
}
}
XYLOG(XYLOG_SEVERITY_DEBUG, "WorkStatus BatteryVoltage end");
return (matched > 0) ? ((float)totalVals / 1000.0 / matched) : 0;
return (matched > 0) ? (totalVals / matched) : 0;
}
uint32_t CPhoneDevice::QueryLdr()

@ -234,7 +234,7 @@ public:
virtual bool InstallAPP(const std::string& path, unsigned int delayedTime);
virtual bool Reboot(int resetType, bool manually, const std::string& reason, uint32_t timeout = 1000);
virtual bool EnableGPS(bool enabled);
virtual float QueryBattaryVoltage(int timesForAvg, bool* isCharging);
virtual int QueryBattaryVoltage(int timesForAvg, int* isCharging);
virtual uint32_t QueryLdr();
virtual bool RequestPosition();
virtual timer_uid_t RegisterHeartbeat(unsigned int timerType, unsigned int timeout, time_t tsForNextPhoto);

Loading…
Cancel
Save