Driveline screen: boot into it, add engine torque, revise shaft scaling
Boot screen: land on the Driveline data screen instead of the SquareLine gauges Home screen. Done in display_init after ui_init while the backlight is still off (no flash of the wrong screen); Home stays reachable by swiping off Driveline. Engine torque added to the screen, decoded from 0x0A8 TORQ_AVL (available/ delivered torque), bits 12-23, signed x0.5 Nm. The user identified the ID and supplied the spreadsheet formula (D2*256+D1)/32, which is algebraically bits12-23 x0.5; confirmed against the repo's 0x0A8 worked example (24 Nm). Firmware masks D1's low nibble (that's the alive counter, not torque - the repo example shows ALIV=8 there) and sign-extends so overrun reads negative. 0x0AA TORQ_DVCH is the same layout but driver demand - identical at idle, diverges under load - so the delivered value is the right one to show. Output-shaft scaling revised: a direct Launch reference (output speed 128 rpm at our raw 1192) implies ~0.107, contradicting the earlier x0.125 (which would predict 149). One eyeballed cross-tool point, so nothing is adopted - the field stays raw counts - but 0.125 is downgraded in firmware and wiki, and the Launch now gives a direct rpm reference so calibration is just a multi-point sweep and a linear fit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "display_init.h"
|
||||
#include "display/lvgl_v8_port.h"
|
||||
#include "ui/ui.h"
|
||||
#include "driveline_screen.h"
|
||||
|
||||
namespace DisplayInit {
|
||||
|
||||
@@ -71,6 +72,11 @@ DisplayObjects init() {
|
||||
lvgl_port_lock(-1);
|
||||
ui_init(); // Initialize the SquareLine Studio generated UI
|
||||
// Note: onSelectSSID event handler is registered in ui_Settings_Screen.c
|
||||
// Override the boot screen: land on the Driveline data screen, not the
|
||||
// gauges Home screen. ui_init() loaded Home; swap to Driveline while the
|
||||
// backlight is still off so there's no visible flash of the wrong screen.
|
||||
// Home stays reachable by swiping off the Driveline screen.
|
||||
DrivelineScreen::show();
|
||||
lvgl_port_unlock();
|
||||
Serial.println("[DisplayInit] Step 13: SquareLine UI loaded successfully!");
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ static lv_obj_t* g_coolant_lbl = NULL;
|
||||
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_shaft_lbl = NULL;
|
||||
static lv_obj_t* g_ign_chip = NULL;
|
||||
@@ -210,13 +211,15 @@ 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);
|
||||
|
||||
// ---- driveline speeds ------------------------------------------------
|
||||
// ---- bottom row: torque -> turbine -> output (engine to output shaft) --
|
||||
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,
|
||||
LV_ALIGN_BOTTOM_MID, -180, -34);
|
||||
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,
|
||||
LV_ALIGN_BOTTOM_MID, 180, -34);
|
||||
LV_ALIGN_BOTTOM_MID, 340, -34);
|
||||
|
||||
lv_obj_t* hint = lv_label_create(g_screen);
|
||||
lv_label_set_text(hint, LV_SYMBOL_LEFT " swipe back to Home");
|
||||
@@ -288,6 +291,7 @@ void tick() {
|
||||
lv_label_set_text(g_coolant_lbl, "--");
|
||||
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_shaft_lbl, "--");
|
||||
lv_bar_set_value(g_rpm_bar, 0, LV_ANIM_OFF);
|
||||
@@ -322,6 +326,11 @@ void tick() {
|
||||
lv_label_set_text(g_rpm_lbl, buf);
|
||||
lv_bar_set_value(g_rpm_bar, dl.engine_rpm > RPM_MAX ? RPM_MAX : dl.engine_rpm, LV_ANIM_OFF);
|
||||
|
||||
// Torque is signed (negative under overrun/braking); one decimal, matching
|
||||
// the 0.5 Nm resolution of the field.
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user