Gauge screen: coolant and gearbox oil as gradient arc gauges with needles on the rim, icons past the hot ends; digits only for the battery
Firmware / build (push) Successful in 3m16s

This commit is contained in:
2026-09-28 08:48:16 +02:00
parent 232eacc8a1
commit 7bc2188ae7
3 changed files with 209 additions and 92 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ include/
**DisplayInit** — `init()`, `update()`, `lock(timeout_ms)` / `unlock()`, `setBrightness(0–255)`, `getBrightness()`. Default brightness 128. `DISPLAY_RADIUS 120` defines the circular mask.
**GaugeScreen** (round-panel layout 2026-09-27: 6 px warning-lamp ring at the rim - dim / RED BLINKING 2 Hz on any red alert / amber on gearbox cooling; coolant top-left and gearbox top-right as [icon][whole degrees]; gear 110 px centre; battery [icon][12.4] bottom; Wi-Fi tell-tale at 9 o'clock (green while joined for an update, dim otherwise), red `!` at 3 o'clock when the link is lost; every element placed absolutely inside the circle) — `init()` builds and loads the screen once; `setNotice(text)` shows the updater's progress line; `update(data, link_ok)` at 5 Hz writes a label, colour or icon **only when it changed** (`lv_label_set_text()` and style setters invalidate even for identical values, and every redraw is SPI time). Gear label: engaged gear, or the target gear pulsing while `target != engaged`, red on the mismatch alert; icons red from A's alert bits; everything N/A when the link is lost.
**GaugeScreen** (round-panel layout, user's design 2026-09-28: two ARC GAUGES on the rim with no digits - coolant on the left from compass 230° (bottom, 50 °C) to 320° (top, 120 °C), gearbox oil on the right from 140° (bottom, 40 °C) to 40° (top, 150 °C); each a blue→neutral→red gradient built from 10° `lv_arc` segments, a white `lv_line` needle recomputed only when its angle changes, and the gauge's icon just past the hot end (red variant while that alert is on); 6 px warning-lamp ring at the very rim - dim / RED BLINKING 2 Hz on any red alert / amber on gearbox cooling; gear 110 px centre; battery [icon][12.4] bottom; Wi-Fi tell-tale at 9 o'clock (green only while joined for an update), red `!` at 3 o'clock when the link is lost. LVGL angle = compass − 90; everything placed absolutely inside the circle) — `init()` builds and loads the screen once; `setNotice(text)` shows the updater's progress line; `update(data, link_ok)` at 5 Hz writes a label, colour or icon **only when it changed** (`lv_label_set_text()` and style setters invalidate even for identical values, and every redraw is SPI time). Gear label: engaged gear, or the target gear pulsing while `target != engaged`, red on the mismatch alert; icons red from A's alert bits; everything N/A when the link is lost.
**UARTReceiver** — `init()`, `processFrame(frame, len, source)`, `getLatestData()`, `getStats()` (applied / per-transport / duplicate / config counts, checksum / framing / version errors, last times), `isConnected()`, `isSourceAlive(source)`, `getConfig()` + `getConfigSeq()`. Link lost after 1000 ms without an applied DATA frame on any transport.
+204 -91
View File
@@ -1,21 +1,24 @@
/*
* Gauge Screen implementation. See gauge_screen.h.
*
* Layout for the ROUND 240x240 panel (2026-09-27 redesign). Everything is
* positioned absolutely, inside the circle:
* Layout for the ROUND 240x240 panel (2026-09-28, user's design):
*
* [wifi] coolant gearbox [link]
* o [icon] 89 92 [icon] !
* D3 (110 px)
* [batt] 12.4
* - two ARC GAUGES on the rim, no digits: coolant on the LEFT (compass 230°
* at the bottom-left up to 320° at the top-left), gearbox oil on the RIGHT
* (compass 140° bottom-right up to 40° top-right). Each arc is a blue ->
* red gradient (cold at the bottom, hot at the top) with a white needle.
* LVGL angles are compass - 90: coolant 140..230, gearbox 310..410 (=50).
* - the gauge's icon sits just past the hot end, upper-left / upper-right;
* it switches to its red variant while that alert is on.
* - outer ring, 6 px, at the very rim: dim normally, RED BLINKING while any
* red alert is on, amber while the gearbox asks for cooling.
* - gear letter 110 px in the centre, battery [icon][12.4] at the bottom.
* - tell-tales: Wi-Fi at 9 o'clock (green only while joined for an update),
* red "!" at 3 o'clock when the link to A is lost.
*
* - outer ring, 6 px: dim normally, RED BLINKING while a red alert is on,
* amber while the gearbox asks for cooling. A warning lamp for the whole
* display - the driver sees it without reading anything.
* - the affected value turns red as well (icon + digits).
* - temperatures as whole degrees, battery to a tenth: fewer, bigger digits.
* - tell-tales at 3 and 9 o'clock: Wi-Fi (bright while joined for an
* update, dim otherwise) and a red "!" when the link to A is lost.
* Geometry (centre 120,120): ring r 114-120, arc band r 100-110, needle
* r 92-113, icons centred at r 66, gear ink roughly y 94-174, battery row
* y 176-220. Everything placed absolutely inside the circle.
*/
#include "modules/gauge_screen.h"
@@ -24,10 +27,10 @@
#include <lvgl.h>
#include <WiFi.h>
#include <string.h>
#include <math.h>
namespace GaugeScreen {
// A shift pulse is shown for at least this long, so a fast shift still blinks
#define SHIFT_PULSE_MIN_MS 600
#define BLINK_MS 500
@@ -38,33 +41,58 @@ static const lv_color_t COL_ALERT2 = lv_color_hex(0x7A1410); // blink low phas
static const lv_color_t COL_AMBER = lv_color_hex(0xF5A524);
static const lv_color_t COL_RING = lv_color_hex(0x2A323C);
static const lv_color_t COL_OK = lv_color_hex(0x3DD68C);
static const lv_color_t COL_COLD = lv_color_hex(0x2F80ED); // arc, cold end
static const lv_color_t COL_MID = lv_color_hex(0xC8D0D8); // arc, middle
static const lv_color_t COL_HOT = lv_color_hex(0xFF3B30); // arc, hot end
// ---- one value unit: icon + digits side by side ------------------------------
struct Cell {
// Arc geometry / scales
#define ARC_DIAMETER 220 // outer radius 110
#define ARC_WIDTH 10 // band r 100..110
#define NEEDLE_R0 92
#define NEEDLE_R1 113
#define ICON_R 66
#define COOL_A0 140 // LVGL degrees, cold end (bottom-left)
#define COOL_A1 230 // hot end (top-left)
#define COOL_T_MIN 50 // degC at the cold end
#define COOL_T_MAX 120 // degC at the hot end
#define GB_A0 50 // cold end (bottom-right)
#define GB_A1 -50 // hot end (top-right) == 310
#define GB_T_MIN 40
#define GB_T_MAX 150
// ---- an arc gauge -------------------------------------------------------------
struct Gauge {
lv_obj_t* needle;
lv_point_t pts[2];
int last_angle; // LVGL degrees, -1000 = hidden
lv_obj_t* icon;
lv_obj_t* icon_red;
int8_t shown; // -1 none, 0 normal, 1 red
};
struct Cell { // battery: icon + digits
lv_obj_t* cont;
lv_obj_t* lbl;
lv_obj_t* icon;
lv_obj_t* icon_red;
int8_t shown; // -1 none, 0 normal icon, 1 red icon
bool red; // digits red
int8_t shown;
bool red;
};
static lv_obj_t* g_screen = NULL;
static lv_obj_t* g_ring = NULL;
static lv_obj_t* g_wifi_tt = NULL;
static lv_obj_t* g_link_tt = NULL;
static lv_obj_t* g_notice = NULL; // on lv_layer_top(): update progress line
static Cell g_coolant = {0};
static Cell g_gearbox = {0};
static Cell g_battery = {0};
static lv_obj_t* g_notice = NULL;
static Gauge g_coolant = {0};
static Gauge g_gearbox = {0};
static Cell g_battery = {0};
static lv_obj_t* g_gear_lbl = NULL;
static bool g_gear_red = false;
static lv_color_t g_ring_col;
static bool g_wifi_bright = false;
static bool g_link_lost_shown = false;
// gear pulse
static lv_anim_t g_gear_anim;
static bool g_gear_pulsing = false;
static uint32_t g_gear_pulse_started = 0;
@@ -83,13 +111,119 @@ static void setTextColour(lv_obj_t* lbl, lv_color_t c) {
lv_obj_set_style_text_color(lbl, c, 0);
}
static void setIcon(Cell& c, bool visible, bool red) {
static void showIconPair(lv_obj_t* icon, lv_obj_t* icon_red, int8_t& shown, bool visible, bool red) {
int8_t want = !visible ? -1 : (red ? 1 : 0);
if (want != c.shown) {
c.shown = want;
if (want == 0) lv_obj_clear_flag(c.icon, LV_OBJ_FLAG_HIDDEN); else lv_obj_add_flag(c.icon, LV_OBJ_FLAG_HIDDEN);
if (want == 1) lv_obj_clear_flag(c.icon_red, LV_OBJ_FLAG_HIDDEN); else lv_obj_add_flag(c.icon_red, LV_OBJ_FLAG_HIDDEN);
if (want == shown) return;
shown = want;
if (want == 0) lv_obj_clear_flag(icon, LV_OBJ_FLAG_HIDDEN); else lv_obj_add_flag(icon, LV_OBJ_FLAG_HIDDEN);
if (want == 1) lv_obj_clear_flag(icon_red, LV_OBJ_FLAG_HIDDEN); else lv_obj_add_flag(icon_red, LV_OBJ_FLAG_HIDDEN);
}
static lv_obj_t* makeIcon(lv_obj_t* parent, const lv_img_dsc_t* src) {
lv_obj_t* i = lv_img_create(parent);
lv_img_set_src(i, src);
lv_obj_add_flag(i, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(i, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_CLICKABLE);
return i;
}
/** Blue -> neutral -> red along t in [0,1]. */
static lv_color_t arcColour(float t) {
if (t < 0.5f) return lv_color_mix(COL_MID, COL_COLD, (uint8_t)(t * 2 * 255));
return lv_color_mix(COL_HOT, COL_MID, (uint8_t)((t - 0.5f) * 2 * 255));
}
/** One static arc segment on the rim band. Angles in LVGL degrees, may exceed 360. */
static void makeArcSegment(lv_obj_t* parent, int a0, int a1, lv_color_t col) {
lv_obj_t* a = lv_arc_create(parent);
lv_obj_remove_style(a, NULL, LV_PART_KNOB);
lv_obj_set_style_arc_opa(a, LV_OPA_TRANSP, LV_PART_INDICATOR);
lv_obj_set_style_arc_width(a, ARC_WIDTH, LV_PART_MAIN);
lv_obj_set_style_arc_color(a, col, LV_PART_MAIN);
lv_obj_set_style_arc_rounded(a, false, LV_PART_MAIN);
lv_obj_set_style_bg_opa(a, LV_OPA_TRANSP, 0);
lv_obj_set_size(a, ARC_DIAMETER, ARC_DIAMETER);
lv_obj_center(a);
lv_arc_set_rotation(a, 0);
lv_arc_set_bg_angles(a, (uint16_t)((a0 % 360 + 360) % 360), (uint16_t)((a1 % 360 + 360) % 360));
lv_obj_clear_flag(a, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
}
/**
* The gradient band from angle a_cold to a_hot (either direction), in ~10°
* segments overlapping by 1° so no seams show.
*/
static void makeBand(lv_obj_t* parent, int a_cold, int a_hot) {
int span = a_hot - a_cold; // signed
int n = abs(span) / 10;
int dir = span > 0 ? 1 : -1;
for (int k = 0; k < n; k++) {
int s = a_cold + dir * 10 * k;
int e = s + dir * 10;
if (k < n - 1) e += dir; // overlap the next segment by 1°
int lo = dir > 0 ? s : e, hi = dir > 0 ? e : s;
makeArcSegment(parent, lo, hi, arcColour((k + 0.5f) / n));
}
}
static void makeNeedle(Gauge& g, lv_obj_t* parent) {
g.needle = lv_line_create(parent);
lv_obj_set_pos(g.needle, 0, 0);
lv_obj_set_size(g.needle, 240, 240);
lv_obj_set_style_line_width(g.needle, 3, 0);
lv_obj_set_style_line_color(g.needle, lv_color_white(), 0);
lv_obj_set_style_line_rounded(g.needle, true, 0);
lv_obj_clear_flag(g.needle, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
g.pts[0].x = g.pts[1].x = 120;
g.pts[0].y = g.pts[1].y = 120;
lv_line_set_points(g.needle, g.pts, 2);
lv_obj_add_flag(g.needle, LV_OBJ_FLAG_HIDDEN);
g.last_angle = -1000;
}
/** Point the needle at an LVGL angle (degrees), or hide it (angle == -1000). */
static void setNeedle(Gauge& g, int angle) {
if (angle == g.last_angle) return;
g.last_angle = angle;
if (angle == -1000) { lv_obj_add_flag(g.needle, LV_OBJ_FLAG_HIDDEN); return; }
float rad = angle * (float)M_PI / 180.0f;
float c = cosf(rad), s = sinf(rad);
g.pts[0].x = (lv_coord_t)lroundf(120 + NEEDLE_R0 * c);
g.pts[0].y = (lv_coord_t)lroundf(120 + NEEDLE_R0 * s);
g.pts[1].x = (lv_coord_t)lroundf(120 + NEEDLE_R1 * c);
g.pts[1].y = (lv_coord_t)lroundf(120 + NEEDLE_R1 * s);
lv_line_set_points(g.needle, g.pts, 2);
lv_obj_clear_flag(g.needle, LV_OBJ_FLAG_HIDDEN);
}
/** Temperature (0.1 degC) -> LVGL angle on a gauge running a_cold..a_hot over t_min..t_max. */
static int tempAngle(int16_t t_x10, int t_min, int t_max, int a_cold, int a_hot) {
float t = (t_x10 / 10.0f - t_min) / (float)(t_max - t_min);
if (t < 0) t = 0;
if (t > 1) t = 1;
return (int)lroundf(a_cold + (a_hot - a_cold) * t);
}
static void placeIcon(lv_obj_t* icon, int angle) {
float rad = angle * (float)M_PI / 180.0f;
lv_coord_t cx = (lv_coord_t)lroundf(120 + ICON_R * cosf(rad));
lv_coord_t cy = (lv_coord_t)lroundf(120 + ICON_R * sinf(rad));
lv_obj_set_pos(icon, cx - 25, cy - 22); // icons are 50x44
}
static void makeGauge(Gauge& g, lv_obj_t* parent, int a_cold, int a_hot, int icon_angle,
const lv_img_dsc_t* icon, const lv_img_dsc_t* icon_red) {
makeBand(parent, a_cold, a_hot);
makeNeedle(g, parent);
g.icon_red = makeIcon(parent, icon_red);
g.icon = makeIcon(parent, icon);
placeIcon(g.icon, icon_angle);
placeIcon(g.icon_red, icon_angle);
g.shown = -1;
}
static void setCellIcon(Cell& c, bool visible, bool red) {
showIconPair(c.icon, c.icon_red, c.shown, visible, red);
bool want_red = visible && red;
if (want_red != c.red) {
c.red = want_red;
@@ -97,45 +231,27 @@ static void setIcon(Cell& c, bool visible, bool red) {
}
}
static lv_obj_t* makeBox(lv_obj_t* parent, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h) {
lv_obj_t* o = lv_obj_create(parent);
lv_obj_remove_style_all(o);
lv_obj_set_pos(o, x, y);
lv_obj_set_size(o, w, h);
lv_obj_set_flex_flow(o, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(o, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_clear_flag(o, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
return o;
}
static void makeBatteryCell(Cell& c, lv_obj_t* parent) {
c.cont = lv_obj_create(parent);
lv_obj_remove_style_all(c.cont);
lv_obj_set_pos(c.cont, 55, 176);
lv_obj_set_size(c.cont, 130, 44);
lv_obj_set_flex_flow(c.cont, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(c.cont, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_set_style_pad_column(c.cont, 8, 0);
lv_obj_clear_flag(c.cont, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
static lv_obj_t* makeValueLabel(lv_obj_t* parent) {
lv_obj_t* l = lv_label_create(parent);
lv_label_set_text(l, "--");
lv_obj_set_style_text_font(l, &ui_font_UbuntuLight_35, 0);
lv_obj_set_style_text_color(l, COL_TEXT, 0);
return l;
}
static lv_obj_t* makeIcon(lv_obj_t* parent, const lv_img_dsc_t* src) {
lv_obj_t* i = lv_img_create(parent);
lv_img_set_src(i, src);
lv_obj_add_flag(i, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(i, LV_OBJ_FLAG_SCROLLABLE);
return i;
}
/** icon_first: [icon][value]; otherwise [value][icon]. The two icons overlay each other. */
static void makeCell(Cell& c, lv_obj_t* parent, lv_coord_t x, lv_coord_t y, lv_coord_t w,
const lv_img_dsc_t* icon, const lv_img_dsc_t* icon_red, bool icon_first) {
c.cont = makeBox(parent, x, y, w, 44);
lv_obj_t* icons = lv_obj_create(c.cont); // 50x44 slot holding both icon variants
lv_obj_t* icons = lv_obj_create(c.cont);
lv_obj_remove_style_all(icons);
lv_obj_set_size(icons, 50, 44);
lv_obj_clear_flag(icons, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
c.icon_red = makeIcon(icons, icon_red);
c.icon = makeIcon(icons, icon);
c.lbl = makeValueLabel(c.cont);
if (!icon_first) lv_obj_move_to_index(c.lbl, 0);
c.icon_red = makeIcon(icons, &ui_img_batteryvoltagered_png);
c.icon = makeIcon(icons, &ui_img_batteryvoltage_png);
c.lbl = lv_label_create(c.cont);
lv_label_set_text(c.lbl, "--");
lv_obj_set_style_text_font(c.lbl, &ui_font_UbuntuLight_35, 0);
lv_obj_set_style_text_color(c.lbl, COL_TEXT, 0);
c.shown = -1;
c.red = false;
}
@@ -245,7 +361,7 @@ void init() {
lv_obj_clear_flag(g_screen, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_bg_color(g_screen, lv_color_black(), 0);
// Warning-lamp ring at the rim (6 px; the panel's round mask trims the corners)
// Warning-lamp ring at the rim
g_ring = lv_obj_create(g_screen);
lv_obj_remove_style_all(g_ring);
lv_obj_set_pos(g_ring, 0, 0);
@@ -257,37 +373,35 @@ void init() {
lv_obj_clear_flag(g_ring, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
g_ring_col = COL_RING;
// top-left: coolant [icon][value]; top-right: gearbox oil [value][icon]
makeCell(g_coolant, g_screen, 28, 46, 92, &ui_img_enginetemp_png, &ui_img_enginetempred_png, true);
makeCell(g_gearbox, g_screen, 120, 46, 92, &ui_img_gearboxoiltemp_png, &ui_img_gearboxoiltempred_png, false);
// Arc gauges: coolant left (140 -> 230), gearbox right (50 -> -50 i.e. 310); icons past the hot ends
makeGauge(g_coolant, g_screen, COOL_A0, COOL_A1, 245, &ui_img_enginetemp_png, &ui_img_enginetempred_png);
makeGauge(g_gearbox, g_screen, GB_A0, GB_A1, 295, &ui_img_gearboxoiltemp_png, &ui_img_gearboxoiltempred_png);
// centre: the gear (Ubuntu Bold 110: line 110, baseline 21 -> ink roughly y 94..174 at this offset)
// Centre: the gear
g_gear_lbl = lv_label_create(g_screen);
lv_label_set_text(g_gear_lbl, "?");
lv_obj_set_style_text_font(g_gear_lbl, &ui_font_UbuntuBold_110, 0);
lv_obj_set_style_text_color(g_gear_lbl, COL_TEXT, 0);
lv_obj_align(g_gear_lbl, LV_ALIGN_CENTER, 0, 20);
// bottom: battery [icon][value], centred
makeCell(g_battery, g_screen, 55, 176, 130, &ui_img_batteryvoltage_png, &ui_img_batteryvoltagered_png, true);
lv_obj_set_flex_align(g_battery.cont, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_set_style_pad_column(g_battery.cont, 8, 0);
// Bottom: battery [icon][value]
makeBatteryCell(g_battery, g_screen);
// tell-tales at 9 and 3 o'clock
// Tell-tales at 9 and 3 o'clock
g_wifi_tt = lv_label_create(g_screen);
lv_label_set_text(g_wifi_tt, LV_SYMBOL_WIFI);
lv_obj_set_style_text_font(g_wifi_tt, &lv_font_montserrat_14, 0);
lv_obj_set_style_text_color(g_wifi_tt, COL_MUTED, 0);
lv_obj_align(g_wifi_tt, LV_ALIGN_LEFT_MID, 12, 0);
lv_obj_align(g_wifi_tt, LV_ALIGN_LEFT_MID, 24, 0);
g_link_tt = lv_label_create(g_screen);
lv_label_set_text(g_link_tt, LV_SYMBOL_WARNING);
lv_obj_set_style_text_font(g_link_tt, &lv_font_montserrat_14, 0);
lv_obj_set_style_text_color(g_link_tt, COL_ALERT, 0);
lv_obj_align(g_link_tt, LV_ALIGN_RIGHT_MID, -12, 0);
lv_obj_align(g_link_tt, LV_ALIGN_RIGHT_MID, -24, 0);
lv_obj_add_flag(g_link_tt, LV_OBJ_FLAG_HIDDEN);
// Notice line for the updater: a dark pill low on the round panel, hidden until used.
// Updater notice line, on the top layer
g_notice = lv_label_create(lv_layer_top());
lv_obj_set_style_text_font(g_notice, &lv_font_montserrat_14, 0);
lv_obj_set_style_text_color(g_notice, lv_color_white(), 0);
@@ -301,7 +415,7 @@ void init() {
lv_scr_load(g_screen);
DisplayInit::unlock();
Serial.println("[GaugeScreen] built (ring, coolant, gearbox oil, gear, battery, tell-tales)");
Serial.println("[GaugeScreen] built (ring, coolant arc, gearbox arc, gear, battery, tell-tales)");
}
void setNotice(const char* text) {
@@ -319,17 +433,17 @@ void setNotice(const char* text) {
void update(const automotive_data_t& d, bool link_ok) {
if (g_screen == NULL) return;
if (!DisplayInit::lock(50)) return; // never stall the loop on a busy renderer
if (!DisplayInit::lock(50)) return;
updateTellTales(link_ok);
if (!link_ok) {
setText(g_coolant.lbl, "--");
setText(g_gearbox.lbl, "--");
setNeedle(g_coolant, -1000);
setNeedle(g_gearbox, -1000);
showIconPair(g_coolant.icon, g_coolant.icon_red, g_coolant.shown, true, false);
showIconPair(g_gearbox.icon, g_gearbox.icon_red, g_gearbox.shown, true, false);
setText(g_battery.lbl, "--");
setIcon(g_coolant, true, false);
setIcon(g_gearbox, true, false);
setIcon(g_battery, true, false);
setCellIcon(g_battery, true, false);
updateGear(d, false);
updateRing(0, false);
DisplayInit::unlock();
@@ -341,19 +455,18 @@ void update(const automotive_data_t& d, bool link_ok) {
uint16_t alerts = alerts_valid ? d.alerts : 0;
bool coolant_valid = (d.valid_flags & VALID_FLAG_COOLANT_TEMP) != 0;
if (coolant_valid) snprintf(buf, sizeof(buf), "%d", d.coolant_temp / 10);
setText(g_coolant.lbl, coolant_valid ? buf : "--");
setIcon(g_coolant, true, (alerts & ALERT_COOLANT_HOT) != 0);
setNeedle(g_coolant, coolant_valid ? tempAngle(d.coolant_temp, COOL_T_MIN, COOL_T_MAX, COOL_A0, COOL_A1) : -1000);
showIconPair(g_coolant.icon, g_coolant.icon_red, g_coolant.shown, true, (alerts & ALERT_COOLANT_HOT) != 0);
bool gearbox_valid = (d.valid_flags & VALID_FLAG_GEARBOX_TEMP) != 0;
if (gearbox_valid) snprintf(buf, sizeof(buf), "%d", d.gearbox_oil_temp / 10);
setText(g_gearbox.lbl, gearbox_valid ? buf : "--");
setIcon(g_gearbox, true, (alerts & (ALERT_GEARBOX_HOT | ALERT_GEARBOX_COOLING)) != 0);
setNeedle(g_gearbox, gearbox_valid ? tempAngle(d.gearbox_oil_temp, GB_T_MIN, GB_T_MAX, GB_A0, GB_A1) : -1000);
showIconPair(g_gearbox.icon, g_gearbox.icon_red, g_gearbox.shown, true,
(alerts & (ALERT_GEARBOX_HOT | ALERT_GEARBOX_COOLING)) != 0);
bool battery_valid = (d.valid_flags & VALID_FLAG_BATTERY_VOLT) != 0;
if (battery_valid) snprintf(buf, sizeof(buf), "%d.%d", d.battery_voltage / 100, (d.battery_voltage % 100) / 10);
setText(g_battery.lbl, battery_valid ? buf : "--");
setIcon(g_battery, true, (alerts & ALERT_BATTERY_LOW) != 0);
setCellIcon(g_battery, true, (alerts & ALERT_BATTERY_LOW) != 0);
updateGear(d, (d.valid_flags & VALID_FLAG_GEAR_POS) != 0);
updateRing(alerts, alerts_valid);
+4
View File
@@ -74,3 +74,7 @@ User connected `485_A → IO1` (ground via the USB hub). B had rebooted on plug-
## [2026-09-27] update | Round-panel redesign of B's screen: warning ring, tell-tales, whole-degree values
User asked for an automotive look, a Wi-Fi indicator and a sense of urgency on crossed thresholds. `gauge_screen.cpp` rebuilt for the circle: a 6 px ring at the rim acts as a warning lamp (dim; red blinking at 2 Hz while any red alert bit is set; amber while the gearbox asks for cooling), the affected value's digits and icon go red, temperatures show whole degrees and the battery a tenth (fewer, bigger digits), coolant/gearbox sit at 10 and 2 o'clock as icon + digits, the 110 px gear stays in the centre, battery centred low; tell-tales at 9 o'clock (Wi-Fi: green only while joined for an update) and 3 o'clock (red `!` when the link to A is lost). Everything is positioned absolutely inside the circle - the old flex column overflowed 240 px, so the battery digits sat partly off-panel. Built and flashed COM13; the user has not yet looked at it. The bench cannot show an alert (A's alerts come from CAN frames only), so the ring/red-value path is untested until the car.
## [2026-09-28] update | B's screen: arc gauges with needles instead of digits (user's design)
User saw the 2026-09-27 layout ("not bad") and redesigned it: no temperature digits; coolant as an arc on the LEFT rim from compass 230° (bottom-left, cold) to 320° (top-left, hot) with a needle, gearbox oil mirrored on the RIGHT from 140° to 40°; arcs blue when cool grading to red at the hot end; each icon just past the hot end, upper-left / upper-right; battery digits stay at the bottom. Implemented in `gauge_screen.cpp`: gradient = 9-10 `lv_arc` segments of 10° (1° overlap, no seams) coloured blue→neutral→red, needle = 3 px white `lv_line` from r 92 to 113 recomputed only on an angle change, band r 100-110 inside the 6 px warning ring, icons centred at r 66 (angles 245° / 295° LVGL). Scales: coolant 50-120 °C, gearbox 40-150 °C (thresholds 100 / 130 sit at ~70 % / ~80 % of the sweep). Ring blink / red icons / tell-tales unchanged. Built and flashed COM13, clean boot; the user is looking at it.