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:
2026-10-18 13:26:02 +02:00
co-authored by Claude Opus 5.5
parent 66fed48aae
commit 40906ec4a7
12 changed files with 159 additions and 8 deletions
@@ -0,0 +1,29 @@
package com.evsuite.abrp;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/** Tyre pressure display units — pure JVM. */
public class PressureUnitTest {
@Test
public void kpaFromTheCarInEachUnit() {
assertEquals("2.5 bar", PressureUnit.BAR.format(250f));
assertEquals("250 kPa", PressureUnit.KPA.format(250f));
assertEquals("36.3 psi", PressureUnit.PSI.format(250f));
}
@Test
public void anUnreadPressureStaysADash() {
assertEquals("—", PressureUnit.BAR.format(null));
assertEquals("—", PressureUnit.PSI.format(Float.NaN));
}
@Test
public void barUnlessSomethingElseWasChosen() {
assertEquals(PressureUnit.BAR, PressureUnit.fromPref(null));
assertEquals(PressureUnit.BAR, PressureUnit.fromPref("nonsense"));
assertEquals(PressureUnit.PSI, PressureUnit.fromPref("PSI"));
}
}
@@ -128,4 +128,16 @@ public class RangeEstimatorTest {
for (long t = 615_000; t <= 735_000; t += 15_000) r.add(t, -20f, 60f); // downhill
assertTrue(r.energySinceStart() < 5.0); // recuperation counts back
}
@Test
public void averagePowerOverTheLastFiveMinutes() {
RangeEstimator r = new RangeEstimator();
r.add(0, 20f, 50f);
assertNull(r.averagePowerKw(0)); // too little yet
for (long t = 15_000; t <= 300_000; t += 15_000) r.add(t, 20f, 50f);
assertEquals(20.0, r.averagePowerKw(300_000), 1e-6);
// Standing with the climate on counts: half the window at 2 kW.
for (long t = 315_000; t <= 450_000; t += 15_000) r.add(t, 2f, 0f);
assertEquals(11.0, r.averagePowerKw(450_000), 1.0);
}
}