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
@@ -2115,7 +2115,14 @@ object EVHardware {
private val sGearLog = StateChangeLog<Int>()
private val sIgnitionLog = StateChangeLog<Int>()
fun isVehicleInPark(): Boolean? {
fun isVehicleInPark(): Boolean? = getGearRaw()?.let { it == GEAR_PARK_VALUE }
/**
* The gear as the car's own code, null if unreadable. Only P = 1 is established (see
* [isVehicleInPark]); the other codes are passed on unnamed so the app can show them and
* the driver can match them to R, N and D.
*/
fun getGearRaw(): Int? {
val gen = FirmwareInfo.getGeneration()
val gear = when {
gen == FirmwareInfo.Gen.SWI133 ->
@@ -2132,7 +2139,7 @@ object EVHardware {
if (sGearLog.accept(gear)) {
AppLogger.i(TAG, "isVehicleInPark — gen=$gen gear=$gear (P=$GEAR_PARK_VALUE)")
}
return gear == GEAR_PARK_VALUE
return gear
}
// ── Read gear SWI68/165 (poll direct) + A9 (CarStateClient) ───────────