App 2.17.0: speed average, compact top bar, About in Settings
- "Speed, 5-min average" card under Speed: time-weighted mean speed, standing included, from the same samples as the other averages. - The top bar is one compact line (title and subtitle side by side). Version, update check and About moved from it to an App card on the Settings tab. - The Overview no longer scrolls in the car's window: checked on the emulator at 1778x640, the layout height the car reports, after trimming the page's padding and the tyre card's height. - The capacity hint says "Overview" instead of "Vehicle tab". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
@@ -177,6 +177,26 @@ final class RangeEstimator {
|
||||
return energyKwh / (covered / 3_600_000.0);
|
||||
}
|
||||
|
||||
/** Mean speed over the last five minutes, time-weighted, standing included; null below a minute. */
|
||||
synchronized Double averageSpeedKmh(long nowMs) {
|
||||
double distanceKm = 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) {
|
||||
distanceKm += (previous.speedKmh + s.speedKmh) / 2 * (dt / 3_600_000.0);
|
||||
covered += dt;
|
||||
}
|
||||
}
|
||||
previous = s;
|
||||
}
|
||||
if (covered < MIN_WINDOW_MS) return null;
|
||||
return distanceKm / (covered / 3_600_000.0);
|
||||
}
|
||||
|
||||
synchronized void clear() {
|
||||
samples.clear();
|
||||
tripEnergyKwh = 0;
|
||||
|
||||
Reference in New Issue
Block a user