Commit 9032b092 authored by Christian Kellner's avatar Christian Kellner
Browse files

Assume energy_now while computing statistics

Therefore we can simplify the code. The minimal interval we need
to wait to see any changes is UPDATE_FREQUENCY.
parent 55b7a30e
......@@ -254,7 +254,10 @@ gbb_power_statistics_compute (const GbbPowerState *base,
double time_elapsed = (current->time_us - base->time_us) / 1000000.;
if (current->energy_now >= 0 && time_elapsed > 0) {
if (time_elapsed < (UPDATE_FREQUENCY / 1000.)) {
return statistics;
}
double energy_used = base->energy_now - current->energy_now;
if (energy_used > 0) {
statistics->power = 3600 * (energy_used) / time_elapsed;
......@@ -263,7 +266,6 @@ gbb_power_statistics_compute (const GbbPowerState *base,
if (base->energy_full_design >= 0)
statistics->battery_life_design = 3600 * base->energy_full_design / statistics->power;
}
}
return statistics;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment