App 2.13.0: tyre pressures in bar; 5-minute average power
Tyre pressures show in bar by default; Settings → Display offers kPa and psi as well. Display only: the car reports kPa and the server keeps storing kPa. A "Power, 5-min average" card under Power: the time-weighted mean battery power over the last five minutes, standing included, from the same samples as the 5-minute range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
@@ -154,6 +154,29 @@ final class RangeEstimator {
|
||||
return new Estimate(rangeKm, kwhPerKm * 100, distanceKm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mean battery power over the last five minutes, time-weighted, standing included; null with
|
||||
* less than a minute of samples. Positive is drawn from the pack, as the Power tile shows it.
|
||||
*/
|
||||
synchronized Double averagePowerKw(long nowMs) {
|
||||
double energyKwh = 0;
|
||||
long covered = 0;
|
||||
Sample previous = null;
|
||||
for (Sample s : samples) {
|
||||
if (s.timeMs < nowMs - WINDOW_MS) continue;
|
||||
if (previous != null) {
|
||||
long dt = s.timeMs - previous.timeMs;
|
||||
if (dt > 0 && dt <= MAX_GAP_MS) {
|
||||
energyKwh += (previous.powerKw + s.powerKw) / 2 * (dt / 3_600_000.0);
|
||||
covered += dt;
|
||||
}
|
||||
}
|
||||
previous = s;
|
||||
}
|
||||
if (covered < MIN_WINDOW_MS) return null;
|
||||
return energyKwh / (covered / 3_600_000.0);
|
||||
}
|
||||
|
||||
synchronized void clear() {
|
||||
samples.clear();
|
||||
tripEnergyKwh = 0;
|
||||
|
||||
Reference in New Issue
Block a user