diff --git a/include/protocol/automotive_data.h b/include/protocol/automotive_data.h index 0302694..73d40f9 100644 --- a/include/protocol/automotive_data.h +++ b/include/protocol/automotive_data.h @@ -192,6 +192,18 @@ typedef struct __attribute__((packed)) { #define CAN_BYTE_OUTPUT_SHAFT_L 3 #define CAN_BYTE_OUTPUT_SHAFT_H 4 +// PROVISIONAL output-shaft factor, from a SINGLE Launch reference reading +// (128 rpm at raw 1192, 2026-07-17) taken through a known zero. Good enough to +// put an approximate rpm on the display (±~10%), NOT good enough to trust for +// anything computed. Replace once a multi-point Launch sweep gives a real fit. +// rpm ~= raw * 1074 / 10000 +#define OUTPUT_SHAFT_RPM_NUM 1074 +#define OUTPUT_SHAFT_RPM_DEN 10000 + +static inline uint16_t can_output_shaft_rpm(uint16_t raw) { + return (uint16_t)(((uint32_t)raw * OUTPUT_SHAFT_RPM_NUM) / OUTPUT_SHAFT_RPM_DEN); +} + // --- 0x1A2 turbine speed (EGS, DLC 4, 20 ms) ------------------------------- // Gearbox INPUT speed. Physically proves engagement: free-spins at ~engine // speed in P/N, collapses to ~0 when the box engages against a held output. diff --git a/src/modules/driveline_screen.cpp b/src/modules/driveline_screen.cpp index 38669a0..4ce9319 100644 --- a/src/modules/driveline_screen.cpp +++ b/src/modules/driveline_screen.cpp @@ -40,7 +40,7 @@ static lv_obj_t* g_gearbox_lbl = NULL; static lv_obj_t* g_rpm_bar = NULL; static lv_obj_t* g_rpm_lbl = NULL; static lv_obj_t* g_torque_lbl = NULL; -static lv_obj_t* g_turbine_lbl = NULL; +static lv_obj_t* g_pedal_lbl = NULL; static lv_obj_t* g_shaft_lbl = NULL; static lv_obj_t* g_ign_chip = NULL; static lv_obj_t* g_eng_chip = NULL; @@ -211,14 +211,16 @@ static void build() { lv_obj_set_style_text_color(g_rpm_lbl, COL_TEXT, 0); lv_obj_align(g_rpm_lbl, LV_ALIGN_CENTER, 330, 108); - // ---- bottom row: torque -> turbine -> output (engine to output shaft) -- + // ---- bottom row: torque | pedal | output shaft ----------------------- + // Turbine speed is intentionally NOT shown: it's a diagnostic (engagement + // proof), not a driver number. Still decoded in the driver. g_torque_lbl = makeStat(g_screen, "TORQUE (Nm)", &lv_font_montserrat_30, LV_ALIGN_BOTTOM_MID, -340, -34); - g_turbine_lbl = makeStat(g_screen, "TURBINE (rpm)", &lv_font_montserrat_30, + g_pedal_lbl = makeStat(g_screen, "PEDAL (%)", &lv_font_montserrat_30, LV_ALIGN_BOTTOM_MID, 0, -34); - // "raw" is not decoration: the output-shaft scaling is still unverified, so - // we deliberately show counts rather than invent a unit. - g_shaft_lbl = makeStat(g_screen, "OUTPUT SHAFT (raw)", &lv_font_montserrat_30, + // Output shaft in rpm via a PROVISIONAL factor (one Launch point). The label + // carries "~" so the screen doesn't present an unlocked scaling as exact. + g_shaft_lbl = makeStat(g_screen, "OUTPUT (~rpm)", &lv_font_montserrat_30, LV_ALIGN_BOTTOM_MID, 340, -34); lv_obj_t* hint = lv_label_create(g_screen); @@ -292,7 +294,7 @@ void tick() { lv_label_set_text(g_gearbox_lbl, "--"); lv_label_set_text(g_rpm_lbl, "----"); lv_label_set_text(g_torque_lbl, "--"); - lv_label_set_text(g_turbine_lbl, "--"); + lv_label_set_text(g_pedal_lbl, "--"); lv_label_set_text(g_shaft_lbl, "--"); lv_bar_set_value(g_rpm_bar, 0, LV_ANIM_OFF); setChip(g_ign_chip, "IGN --", COL_MUTED); @@ -331,10 +333,11 @@ void tick() { snprintf(buf, sizeof(buf), "%d.%d", dl.engine_torque_x10 / 10, abs(dl.engine_torque_x10 % 10)); lv_label_set_text(g_torque_lbl, buf); - snprintf(buf, sizeof(buf), "%u", dl.turbine_rpm); - lv_label_set_text(g_turbine_lbl, buf); + snprintf(buf, sizeof(buf), "%u", dl.pedal_percent); + lv_label_set_text(g_pedal_lbl, buf); - snprintf(buf, sizeof(buf), "%u", dl.output_shaft_raw); + // Provisional rpm from the single-point Launch factor (see automotive_data.h). + snprintf(buf, sizeof(buf), "%u", can_output_shaft_rpm(dl.output_shaft_raw)); lv_label_set_text(g_shaft_lbl, buf); // ---- status chips ---------------------------------------------------- diff --git a/wiki/pages/driveline-speed-signals.md b/wiki/pages/driveline-speed-signals.md index 77d70ff..7a63cb7 100644 --- a/wiki/pages/driveline-speed-signals.md +++ b/wiki/pages/driveline-speed-signals.md @@ -126,6 +126,8 @@ The Launch diagnostic tool reads the EGS output speed directly in rpm (it polls > [!warning] One eyeballed point, not a calibration > Reading 128 on one tool and 1192 on another at the same instant, on a spinning driveline, is hard to do precisely — the two may be a second apart at slightly different speed. So this **downgrades ×0.125** but doesn't yet promote 0.107. It also can't see an offset (both go through zero, which we know, so a pure factor should hold). +> +> **The driveline screen now shows this as "OUTPUT (~rpm)"** using the provisional 0.107 factor — the `~` and the wiki caveat are how we keep an unlocked scaling from reading as exact. Firmware: `can_output_shaft_rpm()` in `automotive_data.h`. **Turbine speed (`0x1A2`) was removed from the display** — it's a diagnostic (engagement proof), not a driver number — but is still decoded. ### Finishing it (now easier — the Launch IS the reference)