Add Driveline screen; stop displaying values that were never measured
New hand-coded LVGL screen (src/modules/driveline_screen.*) showing only signals verified on this bus: gear as the hero, coolant and gearbox oil temp flanking it, an engine RPM bar, and turbine / output-shaft speeds, plus ignition, engine-run, converter-clutch, gearbox-cooling and gear-mismatch status. Reached by swiping right from Home. It lives in src/ and hooks its gesture onto the Home screen at RUNTIME rather than editing ui_Home_Screen.c, because SquareLine Studio overwrites include/ui/ on every export - that is how the CAN toggle's event handler went missing. LVGL dispatches to every registered callback, so the runtime hook coexists with the generated left-swipe handler instead of replacing it. Same reasoning the existing meters_manager already follows. Output shaft is labelled "raw" and shown as counts: the x0.125 scaling is still a hypothesis, so inventing a unit here would launder it into fact. Also fixes a defect found while wiring this up: main.cpp updated the Home screen's meters and battery label unconditionally, but those fields are pre-seeded with DEFAULT_* constants. With no CAN data the display showed a confident 92.0degC engine oil temp and 12.45V battery that had never been measured. Two of them have no source on this bus at all - engine oil temp has no sensor (0x1D0 byte 1 is permanently 0xFF), and 0x3B4 publishes the battery's not-available marker on nearly every frame. Now gated on valid_flags, so an unmeasured value reads "--.--" instead of a plausible lie. Same class of bug in the driver: 0x3B4's U_BT was accepted even when it read 0xFFF, which would have put a confident 61V on screen. Now rejected, leaving the valid flag clear. Decodes ignition state from 0x3B4 byte 2 (user-verified: 0x00 = on, 0x09 = off, unmoved by the engine starting). Both the E65 repo (ST_ENGINE_RUN) and the E60 VFL sheet (engine flag, 0x09 = running) are wrong about this field on our bus - inverted and mislabelled. Noted at the definition so it doesn't get "corrected" back. It also restores ignition sensing, which we thought was lost with CAS/0x130 absent from the swap. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -212,10 +212,23 @@ static bool parseCANMessage(const twai_message_t& message) {
|
||||
break;
|
||||
|
||||
case CAN_ID_BATTERY_VOLTAGE:
|
||||
// 0x3B4: U_BT, 12-bit little-endian x 0.015 V.
|
||||
// 0x3B4: U_BT (12-bit LE x 0.015 V) + ignition state.
|
||||
if (dlc > CAN_BYTE_BATTERY_VOLT_H) {
|
||||
g_automotive_data.battery_voltage = can_to_voltage(data);
|
||||
g_automotive_data.valid_flags |= VALID_FLAG_BATTERY_VOLT;
|
||||
// The field reads 0xFFF (not-available) on nearly every frame of
|
||||
// this bus. Publishing that would put a confident 61 V on the
|
||||
// display, so only accept real readings and leave the valid flag
|
||||
// clear otherwise.
|
||||
if (can_battery_raw(data) != BATTERY_RAW_INVALID) {
|
||||
g_automotive_data.battery_voltage = can_to_voltage(data);
|
||||
g_automotive_data.valid_flags |= VALID_FLAG_BATTERY_VOLT;
|
||||
}
|
||||
parsed = true;
|
||||
}
|
||||
if (dlc > CAN_BYTE_IGNITION) {
|
||||
// Byte 2's low nibble tracks ignition (inverted), NOT engine run
|
||||
// — verified on this bus against both published claims.
|
||||
g_driveline.ignition_on =
|
||||
((data[CAN_BYTE_IGNITION] & 0x0F) == IGNITION_ON);
|
||||
parsed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user