App 2.22.1: gear badge shows only P; Logs list the raw gear codes

The badge said "D" for every gear that was not P, so N and R read as D.
EVHardware now passes on the raw gear code; the badge shows P for 1,
no letter for codes not yet mapped, "—" when unread. The Logs tab lists
each change of the code with time and speed, to match R, N and D on
the car. Emulator only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-24 16:59:44 +02:00
co-authored by Claude Opus 5.5
parent cd0dfcd612
commit 16cc2746ef
12 changed files with 151 additions and 11 deletions
@@ -1519,8 +1519,7 @@ public class MainActivity extends AppCompatActivity {
Float power = s.getBatteryPowerKw();
Float speed = s.getSpeedKmh();
Boolean parked = s.getParked();
cockpitPower.setValue(power, parked == null ? "—" : parked ? "P" : "D",
cockpitPower.setValue(power, Gear.label(s.getGearRaw()),
speed == null ? null : String.format(us, "%.0f", speed), getString(R.string.dash_unit_kmh),
power == null ? "—" : String.format(us, "%.1f kW", power), null);
cockpitTrace.add(android.os.SystemClock.elapsedRealtime(), power);
@@ -1554,8 +1553,7 @@ public class MainActivity extends AppCompatActivity {
fmt(s.getRangeKm(), "%.0f km"));
dashBatteryBar.setSoc(soc);
dashBatteryText.setText(fmt(soc, "%.0f %%"));
Boolean parked = s.getParked();
dashGear.setText(parked == null ? "—" : parked ? "P" : "D");
dashGear.setText(Gear.label(s.getGearRaw()));
dashClimate.setText(fmt(s.getClimate().getDriverTargetCelsius(), "%.0f °C"));
}
@@ -1577,6 +1575,7 @@ public class MainActivity extends AppCompatActivity {
vehTireFr.setText(unit.format(s.getTirePressures().getFrontRightKpa()));
vehTireRl.setText(unit.format(s.getTirePressures().getRearLeftKpa()));
vehTireRr.setText(unit.format(s.getTirePressures().getRearRightKpa()));
GearLog.note(this, s.getGearRaw(), s.getSpeedKmh());
showDashboard(s);
showCockpit(s);
} catch (Throwable ignored) {
@@ -1901,6 +1900,14 @@ public class MainActivity extends AppCompatActivity {
// Update steps first: after a failed install, they are what the driver came here for.
java.util.List<String> updates = UpdateLog.lines(this);
StringBuilder sb = new StringBuilder();
// The car's gear codes, for matching R, N and D to the lever (only P = 1 is known).
java.util.List<String> gears = GearLog.lines(this);
if (!gears.isEmpty()) {
Integer now = GearLog.current();
sb.append(getString(R.string.gear_log_title, now == null ? "—" : String.valueOf(now)));
for (String line : gears) sb.append('\n').append(line);
sb.append("\n\n");
}
if (!updates.isEmpty()) {
sb.append(getString(R.string.update_log_title));
for (String line : updates) sb.append('\n').append(line);