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:
@@ -0,0 +1,365 @@
|
||||
/*
|
||||
* Driveline Screen Module Implementation
|
||||
*/
|
||||
|
||||
#include "driveline_screen.h"
|
||||
#include "uart_manager.h"
|
||||
#include "display/lvgl_v8_port.h"
|
||||
#include "drivers/can_driver.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
extern "C" {
|
||||
#include "ui.h"
|
||||
}
|
||||
|
||||
namespace DrivelineScreen {
|
||||
|
||||
// ============================================================================
|
||||
// LAYOUT / THEME CONSTANTS
|
||||
// ============================================================================
|
||||
|
||||
#define COL_BG lv_color_hex(0x101418)
|
||||
#define COL_PANEL lv_color_hex(0x1B2128)
|
||||
#define COL_TEXT lv_color_hex(0xE8EDF2)
|
||||
#define COL_MUTED lv_color_hex(0x6E7B88)
|
||||
#define COL_ACCENT lv_color_hex(0x3DA9FC)
|
||||
#define COL_OK lv_color_hex(0x3DD68C)
|
||||
#define COL_WARN lv_color_hex(0xE5484D)
|
||||
|
||||
#define RPM_MAX 5000 // M57N redline is ~4500; a little headroom
|
||||
|
||||
// ============================================================================
|
||||
// MODULE STATE
|
||||
// ============================================================================
|
||||
|
||||
static lv_obj_t* g_screen = NULL;
|
||||
static lv_obj_t* g_gear_lbl = NULL;
|
||||
static lv_obj_t* g_gear_ring = NULL;
|
||||
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_turbine_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;
|
||||
static lv_obj_t* g_clutch_chip = NULL;
|
||||
static lv_obj_t* g_cool_chip = NULL;
|
||||
static lv_obj_t* g_mismatch_lbl = NULL;
|
||||
|
||||
// Home screen instance we've already hooked the right-swipe onto.
|
||||
static lv_obj_t* g_hooked_home = NULL;
|
||||
|
||||
// ============================================================================
|
||||
// PRIVATE HELPERS
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* @brief Create a small status chip (rounded pill with text).
|
||||
*/
|
||||
static lv_obj_t* makeChip(lv_obj_t* parent, const char* text) {
|
||||
lv_obj_t* chip = lv_label_create(parent);
|
||||
lv_label_set_text(chip, text);
|
||||
lv_obj_set_style_text_font(chip, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_color(chip, COL_MUTED, 0);
|
||||
lv_obj_set_style_bg_color(chip, COL_PANEL, 0);
|
||||
lv_obj_set_style_bg_opa(chip, LV_OPA_COVER, 0);
|
||||
lv_obj_set_style_radius(chip, 10, 0);
|
||||
lv_obj_set_style_pad_hor(chip, 10, 0);
|
||||
lv_obj_set_style_pad_ver(chip, 5, 0);
|
||||
return chip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set a chip's text and colour in one go.
|
||||
*/
|
||||
static void setChip(lv_obj_t* chip, const char* text, lv_color_t colour) {
|
||||
if (chip == NULL) return;
|
||||
lv_label_set_text(chip, text);
|
||||
lv_obj_set_style_text_color(chip, colour, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create a title + value stack. Returns the value label.
|
||||
*/
|
||||
static lv_obj_t* makeStat(lv_obj_t* parent, const char* title,
|
||||
const lv_font_t* value_font,
|
||||
lv_align_t align, lv_coord_t x, lv_coord_t y) {
|
||||
lv_obj_t* box = lv_obj_create(parent);
|
||||
lv_obj_remove_style_all(box);
|
||||
lv_obj_set_size(box, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_flow(box, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(box, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
lv_obj_align(box, align, x, y);
|
||||
lv_obj_clear_flag(box, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
lv_obj_t* t = lv_label_create(box);
|
||||
lv_label_set_text(t, title);
|
||||
lv_obj_set_style_text_font(t, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_color(t, COL_MUTED, 0);
|
||||
lv_obj_set_style_pad_bottom(t, 4, 0);
|
||||
|
||||
lv_obj_t* v = lv_label_create(box);
|
||||
lv_label_set_text(v, "--");
|
||||
lv_obj_set_style_text_font(v, value_font, 0);
|
||||
lv_obj_set_style_text_color(v, COL_TEXT, 0);
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gesture handler on OUR screen: swipe right/left goes back to Home.
|
||||
*/
|
||||
static void onScreenGesture(lv_event_t* e) {
|
||||
if (lv_event_get_code(e) != LV_EVENT_GESTURE) return;
|
||||
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());
|
||||
if (dir == LV_DIR_LEFT || dir == LV_DIR_RIGHT) {
|
||||
lv_indev_wait_release(lv_indev_get_act());
|
||||
_ui_screen_change(&ui_Home_Screen, LV_SCR_LOAD_ANIM_FADE_ON, 100, 0,
|
||||
&ui_Home_Screen_screen_init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gesture handler we bolt onto the Home screen at runtime.
|
||||
*
|
||||
* The generated ui_event_Home_Screen() already claims LEFT (-> Settings). LVGL
|
||||
* dispatches to every registered callback, so this one coexists with it rather
|
||||
* than replacing it — which is the whole point: we never edit the generated file.
|
||||
*/
|
||||
static void onHomeGesture(lv_event_t* e) {
|
||||
if (lv_event_get_code(e) != LV_EVENT_GESTURE) return;
|
||||
if (lv_indev_get_gesture_dir(lv_indev_get_act()) != LV_DIR_RIGHT) return;
|
||||
lv_indev_wait_release(lv_indev_get_act());
|
||||
show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build the screen. Idempotent — returns immediately if already built.
|
||||
*/
|
||||
static void build() {
|
||||
if (g_screen != NULL) return;
|
||||
|
||||
g_screen = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(g_screen, COL_BG, 0);
|
||||
lv_obj_clear_flag(g_screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_add_event_cb(g_screen, onScreenGesture, LV_EVENT_GESTURE, NULL);
|
||||
|
||||
// ---- top status bar --------------------------------------------------
|
||||
lv_obj_t* bar = lv_obj_create(g_screen);
|
||||
lv_obj_remove_style_all(bar);
|
||||
lv_obj_set_size(bar, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_flow(bar, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_style_pad_column(bar, 8, 0);
|
||||
lv_obj_align(bar, LV_ALIGN_TOP_LEFT, 24, 18);
|
||||
lv_obj_clear_flag(bar, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
g_ign_chip = makeChip(bar, "IGN --");
|
||||
g_eng_chip = makeChip(bar, "ENG --");
|
||||
g_clutch_chip = makeChip(bar, "CLUTCH --");
|
||||
g_cool_chip = makeChip(bar, "COOLING --");
|
||||
|
||||
g_mismatch_lbl = lv_label_create(g_screen);
|
||||
lv_label_set_text(g_mismatch_lbl, LV_SYMBOL_WARNING " GEAR MISMATCH");
|
||||
lv_obj_set_style_text_font(g_mismatch_lbl, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_color(g_mismatch_lbl, COL_WARN, 0);
|
||||
lv_obj_align(g_mismatch_lbl, LV_ALIGN_TOP_RIGHT, -24, 24);
|
||||
lv_obj_add_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
// ---- gear hero -------------------------------------------------------
|
||||
g_gear_ring = lv_obj_create(g_screen);
|
||||
lv_obj_set_size(g_gear_ring, 220, 220);
|
||||
lv_obj_align(g_gear_ring, LV_ALIGN_CENTER, 0, -40);
|
||||
lv_obj_set_style_radius(g_gear_ring, LV_RADIUS_CIRCLE, 0);
|
||||
lv_obj_set_style_bg_color(g_gear_ring, COL_PANEL, 0);
|
||||
lv_obj_set_style_border_color(g_gear_ring, COL_ACCENT, 0);
|
||||
lv_obj_set_style_border_width(g_gear_ring, 3, 0);
|
||||
lv_obj_clear_flag(g_gear_ring, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
g_gear_lbl = lv_label_create(g_gear_ring);
|
||||
lv_label_set_text(g_gear_lbl, "--");
|
||||
lv_obj_set_style_text_font(g_gear_lbl, &lv_font_montserrat_48, 0);
|
||||
lv_obj_set_style_text_color(g_gear_lbl, COL_TEXT, 0);
|
||||
lv_obj_center(g_gear_lbl);
|
||||
|
||||
// ---- flanking temperatures ------------------------------------------
|
||||
g_coolant_lbl = makeStat(g_screen, "COOLANT", &lv_font_montserrat_40,
|
||||
LV_ALIGN_LEFT_MID, 110, -40);
|
||||
g_gearbox_lbl = makeStat(g_screen, "GEARBOX OIL", &lv_font_montserrat_40,
|
||||
LV_ALIGN_RIGHT_MID, -110, -40);
|
||||
|
||||
// ---- RPM bar ---------------------------------------------------------
|
||||
lv_obj_t* rpm_title = lv_label_create(g_screen);
|
||||
lv_label_set_text(rpm_title, "RPM");
|
||||
lv_obj_set_style_text_font(rpm_title, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_color(rpm_title, COL_MUTED, 0);
|
||||
lv_obj_align(rpm_title, LV_ALIGN_CENTER, -330, 108);
|
||||
|
||||
g_rpm_bar = lv_bar_create(g_screen);
|
||||
lv_obj_set_size(g_rpm_bar, 560, 16);
|
||||
lv_obj_align(g_rpm_bar, LV_ALIGN_CENTER, -30, 108);
|
||||
lv_bar_set_range(g_rpm_bar, 0, RPM_MAX);
|
||||
lv_bar_set_value(g_rpm_bar, 0, LV_ANIM_OFF);
|
||||
lv_obj_set_style_bg_color(g_rpm_bar, COL_PANEL, 0);
|
||||
lv_obj_set_style_bg_color(g_rpm_bar, COL_ACCENT, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_radius(g_rpm_bar, 8, 0);
|
||||
lv_obj_set_style_radius(g_rpm_bar, 8, LV_PART_INDICATOR);
|
||||
|
||||
g_rpm_lbl = lv_label_create(g_screen);
|
||||
lv_label_set_text(g_rpm_lbl, "----");
|
||||
lv_obj_set_style_text_font(g_rpm_lbl, &lv_font_montserrat_30, 0);
|
||||
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 ------------------------------------------------
|
||||
g_turbine_lbl = makeStat(g_screen, "TURBINE (rpm)", &lv_font_montserrat_30,
|
||||
LV_ALIGN_BOTTOM_MID, -180, -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_obj_t* hint = lv_label_create(g_screen);
|
||||
lv_label_set_text(hint, LV_SYMBOL_LEFT " swipe back to Home");
|
||||
lv_obj_set_style_text_font(hint, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_color(hint, COL_MUTED, 0);
|
||||
lv_obj_align(hint, LV_ALIGN_BOTTOM_LEFT, 24, -14);
|
||||
|
||||
ESP_LOGI("Driveline", "Driveline screen built");
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PUBLIC API
|
||||
// ============================================================================
|
||||
|
||||
void show() {
|
||||
build();
|
||||
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_FADE_ON, 100, 0, false);
|
||||
}
|
||||
|
||||
void attachHomeGesture() {
|
||||
if (ui_Home_Screen == NULL) {
|
||||
g_hooked_home = NULL; // screen gone; re-hook when it returns
|
||||
return;
|
||||
}
|
||||
if (g_hooked_home == ui_Home_Screen) return;
|
||||
|
||||
lvgl_port_lock(-1);
|
||||
lv_obj_add_event_cb(ui_Home_Screen, onHomeGesture, LV_EVENT_GESTURE, NULL);
|
||||
lvgl_port_unlock();
|
||||
|
||||
g_hooked_home = ui_Home_Screen;
|
||||
ESP_LOGI("Driveline", "Right-swipe hooked onto Home screen");
|
||||
}
|
||||
|
||||
void tick() {
|
||||
// Nothing to do unless we're built AND actually the screen being shown.
|
||||
if (g_screen == NULL || lv_scr_act() != g_screen) return;
|
||||
|
||||
// loop() spins fast and Core 1 is already ~80% busy rendering. Refreshing at
|
||||
// 10Hz is well past what the eye resolves and keeps us off the LVGL lock.
|
||||
static uint32_t last_refresh = 0;
|
||||
if (millis() - last_refresh < 100) return;
|
||||
last_refresh = millis();
|
||||
|
||||
bool can_up = CANDriver::isActive();
|
||||
driveline_t dl = CANDriver::getDriveline();
|
||||
|
||||
// Snapshot the shared struct under its own mutex, briefly.
|
||||
uint8_t gear = GEAR_UNKNOWN;
|
||||
int16_t coolant = 0, gearbox = 0;
|
||||
uint8_t flags = 0;
|
||||
if (xSemaphoreTake(UARTManager::g_data_mutex, pdMS_TO_TICKS(10)) == pdTRUE) {
|
||||
gear = UARTManager::g_automotive_data.gear_position;
|
||||
coolant = UARTManager::g_automotive_data.coolant_temp;
|
||||
gearbox = UARTManager::g_automotive_data.gearbox_oil_temp;
|
||||
flags = UARTManager::g_automotive_data.valid_flags;
|
||||
xSemaphoreGive(UARTManager::g_data_mutex);
|
||||
} else {
|
||||
return; // couldn't read; leave the last frame on screen
|
||||
}
|
||||
|
||||
char buf[24];
|
||||
lvgl_port_lock(-1);
|
||||
|
||||
if (!can_up) {
|
||||
// Be explicit that there is no data, rather than showing a stale frame
|
||||
// that looks live.
|
||||
lv_label_set_text(g_gear_lbl, "--");
|
||||
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_turbine_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);
|
||||
setChip(g_eng_chip, "ENG --", COL_MUTED);
|
||||
setChip(g_clutch_chip, "CLUTCH --", COL_MUTED);
|
||||
setChip(g_cool_chip, "CAN OFF", COL_WARN);
|
||||
lv_obj_add_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
||||
lvgl_port_unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
// ---- gear ------------------------------------------------------------
|
||||
if (flags & VALID_FLAG_GEAR_POS) {
|
||||
lv_label_set_text(g_gear_lbl, gear_to_string((gear_position_t)gear));
|
||||
} else {
|
||||
lv_label_set_text(g_gear_lbl, "--");
|
||||
}
|
||||
|
||||
// ---- temperatures (only when the signal is real) ---------------------
|
||||
if (flags & VALID_FLAG_COOLANT_TEMP) {
|
||||
snprintf(buf, sizeof(buf), "%d.%d°C", coolant / 10, abs(coolant % 10));
|
||||
lv_label_set_text(g_coolant_lbl, buf);
|
||||
}
|
||||
if (flags & VALID_FLAG_GEARBOX_TEMP) {
|
||||
snprintf(buf, sizeof(buf), "%d.%d°C", gearbox / 10, abs(gearbox % 10));
|
||||
lv_label_set_text(g_gearbox_lbl, buf);
|
||||
}
|
||||
|
||||
// ---- speeds ----------------------------------------------------------
|
||||
snprintf(buf, sizeof(buf), "%u", dl.engine_rpm);
|
||||
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);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", dl.turbine_rpm);
|
||||
lv_label_set_text(g_turbine_lbl, buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", dl.output_shaft_raw);
|
||||
lv_label_set_text(g_shaft_lbl, buf);
|
||||
|
||||
// ---- status chips ----------------------------------------------------
|
||||
setChip(g_ign_chip, dl.ignition_on ? "IGN ON" : "IGN OFF",
|
||||
dl.ignition_on ? COL_OK : COL_MUTED);
|
||||
|
||||
switch (dl.engine_run_state) {
|
||||
case ENGINE_RUN_RUNNING: setChip(g_eng_chip, "ENG RUN", COL_OK); break;
|
||||
case ENGINE_RUN_STARTING: setChip(g_eng_chip, "ENG START", COL_ACCENT); break;
|
||||
case ENGINE_RUN_OFF: setChip(g_eng_chip, "ENG OFF", COL_MUTED); break;
|
||||
default: setChip(g_eng_chip, "ENG ?", COL_MUTED); break;
|
||||
}
|
||||
|
||||
switch (dl.converter_clutch) {
|
||||
case CCLT_DISENGAGED: setChip(g_clutch_chip, "CLUTCH OPEN", COL_MUTED); break;
|
||||
case CCLT_CONTROLLED: setChip(g_clutch_chip, "CLUTCH SLIP", COL_ACCENT); break;
|
||||
case CCLT_CLOSED: setChip(g_clutch_chip, "CLUTCH LOCK", COL_OK); break;
|
||||
default: setChip(g_clutch_chip, "CLUTCH ?", COL_MUTED); break;
|
||||
}
|
||||
|
||||
switch (dl.gearbox_cooling) {
|
||||
case GEARBOX_COOL_NONE: setChip(g_cool_chip, "COOLING OK", COL_MUTED); break;
|
||||
case GEARBOX_COOL_STAGE1: setChip(g_cool_chip, "COOLING 1", COL_ACCENT); break;
|
||||
case GEARBOX_COOL_STAGE2: setChip(g_cool_chip, "COOLING 2", COL_WARN); break;
|
||||
default: setChip(g_cool_chip, "COOLING ?", COL_MUTED); break;
|
||||
}
|
||||
|
||||
if (dl.gear_mismatch) {
|
||||
lv_obj_clear_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
} // namespace DrivelineScreen
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Driveline Screen Module
|
||||
*
|
||||
* A hand-coded LVGL screen showing the CAN signals we have actually verified on
|
||||
* the swap's bus: gear (hero), coolant, gearbox oil temp, engine RPM, turbine
|
||||
* speed and output shaft, plus ignition / engine / clutch / mismatch status.
|
||||
*
|
||||
* WHY THIS IS NOT A SQUARELINE SCREEN
|
||||
* SquareLine Studio owns include/ui/ and overwrites it on every export. Editing
|
||||
* generated files loses the edit — that is exactly how the CAN toggle's event
|
||||
* handler went missing. This screen lives entirely in src/, which SquareLine
|
||||
* never touches, so it cannot be clobbered. It is reached by a right-swipe
|
||||
* gesture attached to the Home screen AT RUNTIME (see attachHomeGesture) rather
|
||||
* than by editing ui_Home_Screen.c, for the same reason.
|
||||
*
|
||||
* Signals deliberately NOT shown: engine oil temp (no sensor on this M57N —
|
||||
* 0x1D0 byte 1 is permanently 0xFF) and battery voltage (0x3B4 publishes the
|
||||
* invalid marker almost always). See wiki/pages/can-id-candidates.md.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace DrivelineScreen {
|
||||
|
||||
/**
|
||||
* @brief Build the screen (idempotent) and load it.
|
||||
* @note Caller must hold the LVGL lock.
|
||||
*/
|
||||
void show();
|
||||
|
||||
/**
|
||||
* @brief Refresh all values from the CAN driver / shared automotive data.
|
||||
* Cheap no-op unless the screen exists and is currently on display.
|
||||
* Call from loop(); takes its own locks.
|
||||
*/
|
||||
void tick();
|
||||
|
||||
/**
|
||||
* @brief Attach a right-swipe handler to the Home screen so this screen is
|
||||
* reachable, without touching the SquareLine-generated Home screen code.
|
||||
* Safe to call every loop — re-attaches only when the Home screen
|
||||
* instance changes. Takes its own LVGL lock.
|
||||
*/
|
||||
void attachHomeGesture();
|
||||
|
||||
} // namespace DrivelineScreen
|
||||
Reference in New Issue
Block a user