Skip to content
C

bump 1.2.6 for new GT3 UI

YU CHIH CHANG8cf610a7b041
diff --git a/include/version.h b/include/version.h
index df9f2ca..bffba97 100644
--- a/include/version.h
+++ b/include/version.h
@@ -1,3 +1,3 @@
#pragma once
-inline constexpr char GT7_DASH_VERSION[] = "1.2.5";
+inline constexpr char GT7_DASH_VERSION[] = "1.2.6";
diff --git a/installer/firmware/firmware-ili9341.bin b/installer/firmware/firmware-ili9341.bin
index 81a3046..74918aa 100644
Binary files a/installer/firmware/firmware-ili9341.bin and b/installer/firmware/firmware-ili9341.bin differ
diff --git a/installer/firmware/firmware-st7789.bin b/installer/firmware/firmware-st7789.bin
index d85c2fa..6dd04ca 100644
Binary files a/installer/firmware/firmware-st7789.bin and b/installer/firmware/firmware-st7789.bin differ
diff --git a/installer/manifest-st7789.json b/installer/manifest-st7789.json
index 3034f50..f6387ef 100644
--- a/installer/manifest-st7789.json
+++ b/installer/manifest-st7789.json
@@ -1,6 +1,6 @@
{
"name": "ESP32 GT7 Dashboard (ST7789)",
- "version": "1.2.5",
+ "version": "1.2.6",
"new_install_prompt_erase": true,
"builds": [
{
diff --git a/installer/manifest.json b/installer/manifest.json
index 4b03b87..3a874fc 100644
--- a/installer/manifest.json
+++ b/installer/manifest.json
@@ -1,6 +1,6 @@
{
"name": "ESP32 GT7 Dashboard (ILI9341)",
- "version": "1.2.5",
+ "version": "1.2.6",
"new_install_prompt_erase": true,
"builds": [
{
diff --git a/installer/release-notes.json b/installer/release-notes.json
index 96d7e38..0c3dd3e 100644
--- a/installer/release-notes.json
+++ b/installer/release-notes.json
@@ -1,4 +1,7 @@
{
+ "1.2.6": [
+ "Introduced the refined low-RAM GT3 dashboard UI."
+ ],
"1.2.5": [
"Added tyre-temperature colour display."
],
diff --git a/installer/releases.json b/installer/releases.json
index 3dcb32f..f810f71 100644
--- a/installer/releases.json
+++ b/installer/releases.json
@@ -1,5 +1,15 @@
{
"versions": [
+ {
+ "version": "1.2.6",
+ "notes": [
+ "Introduced the refined low-RAM GT3 dashboard UI."
+ ],
+ "manifests": {
+ "ili9341": "manifest.json",
+ "st7789": "manifest-st7789.json"
+ }
+ },
{
"version": "1.2.5",
"notes": [
diff --git a/photos/fa3addef-b474-4772-a3b6-478f1000bc1f.png b/photos/fa3addef-b474-4772-a3b6-478f1000bc1f.png
new file mode 100644
index 0000000..cf70590
Binary files /dev/null and b/photos/fa3addef-b474-4772-a3b6-478f1000bc1f.png differ
diff --git a/platformio.ini b/platformio.ini
index b220eb5..6c1c125 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -100,8 +100,8 @@ build_flags =
;upload_speed = 921600
;upload_port = COM10
-upload_port = COM4
-monitor_port = COM4
+upload_port = COM3
+monitor_port = COM3
monitor_speed = 115200
# Alternate ESP32-2432S028 display controller.
diff --git a/src/SHCustomProtocol.h b/src/SHCustomProtocol.h
index cebbb8a..2b34237 100644
--- a/src/SHCustomProtocol.h
+++ b/src/SHCustomProtocol.h
@@ -30,6 +30,91 @@ static const int HALF_CELL_HEIGHT = CELL_HEIGHT / 2;
static const int COL[] = {0, CELL_WIDTH, CELL_WIDTH * 2, CELL_WIDTH * 3, CELL_WIDTH * 4, CELL_WIDTH * 6, CELL_WIDTH * 7};
static const int ROW[] = {0, CELL_HEIGHT, CELL_HEIGHT * 2, CELL_HEIGHT * 3, CELL_HEIGHT * 4, CELL_HEIGHT * 6, CELL_HEIGHT * 7};
+// Explicit 320x240 dashboard grid. The side regions are mirror images and all
+// central elements derive from CENTER_X; no center alignment depends on them.
+namespace DashboardLayout
+{
+ static constexpr int WIDTH = 320;
+ static constexpr int HEIGHT = 240;
+ static constexpr int CENTER_X = 160;
+ static constexpr int OUTER_MARGIN = 4;
+ static constexpr int SIDE_COLUMN_WIDTH = 100;
+ static constexpr int SIDE_WIDTH = SIDE_COLUMN_WIDTH - OUTER_MARGIN * 2;
+ static constexpr int LEFT_X = OUTER_MARGIN;
+ static constexpr int RIGHT_X = WIDTH - SIDE_COLUMN_WIDTH + OUTER_MARGIN;
+ static constexpr int LEFT_DIVIDER_X = SIDE_COLUMN_WIDTH;
+ static constexpr int RIGHT_DIVIDER_X = WIDTH - SIDE_COLUMN_WIDTH;
+ static constexpr int INNER_PADDING = 1;
+ static constexpr int LEFT_TEXT_X = LEFT_X + INNER_PADDING;
+ static constexpr int RIGHT_TEXT_X = RIGHT_X + INNER_PADDING;
+
+ static constexpr int RPM_BOTTOM = 48;
+ static constexpr int CONTENT_TOP = 50;
+ static constexpr int CONTENT_BOTTOM = 192;
+ static constexpr int BOTTOM_DIVIDER_Y = 193;
+ static constexpr int SIDE_PANEL_Y = CONTENT_TOP;
+ static constexpr int SIDE_PANEL_H = CONTENT_BOTTOM - CONTENT_TOP + 1;
+ static constexpr int LEFT_PANEL_X = 2;
+ static constexpr int RIGHT_PANEL_X = RIGHT_DIVIDER_X + 1;
+ static constexpr int LEFT_PANEL_W = LEFT_DIVIDER_X - LEFT_PANEL_X - 1;
+ static constexpr int RIGHT_PANEL_W = WIDTH - RIGHT_PANEL_X - 2;
+ static constexpr int BOTTOM_PANEL_X = 2;
+ static constexpr int BOTTOM_PANEL_Y = 194;
+ static constexpr int BOTTOM_PANEL_W = WIDTH - 4;
+ static constexpr int BOTTOM_PANEL_H = HEIGHT - BOTTOM_PANEL_Y - 2;
+
+ static constexpr int GEAR_CENTER_X = CENTER_X;
+ static constexpr int GEAR_CENTER_Y = 108;
+ static constexpr int GEAR_RADIUS = 53;
+ static constexpr int GEAR_VALUE_W = 104;
+ static constexpr int GEAR_VALUE_H = 100;
+ static constexpr int GEAR_VALUE_X = GEAR_CENTER_X - GEAR_VALUE_W / 2;
+ static constexpr int GEAR_VALUE_Y = GEAR_CENTER_Y - GEAR_VALUE_H / 2;
+
+ static constexpr int TYRE_W = 69;
+ static constexpr int TYRE_H = 25;
+ static constexpr int TYRE_X = CENTER_X - TYRE_W / 2;
+ static constexpr int TYRE_Y = 164;
+
+ static constexpr int SPEED_LABEL_Y = 52;
+ static constexpr int SPEED_VALUE_Y = 70;
+ static constexpr int SPEED_VALUE_H = 43;
+ static constexpr int SPEED_UNIT_Y = 114;
+ static constexpr int LEFT_SEPARATOR_Y = 126;
+ static constexpr int DELTA_LABEL_Y = 131;
+ static constexpr int DELTA_VALUE_Y = 150;
+ static constexpr int DELTA_VALUE_H = 38;
+
+ static constexpr int LAP_LABEL_Y[3] = {52, 99, 146};
+ static constexpr int LAP_VALUE_Y[3] = {70, 117, 164};
+ static constexpr int LAP_SEPARATOR_Y[2] = {95, 142};
+ static constexpr int LAP_VALUE_H = 24;
+
+ static constexpr int BOTTOM_LABEL_Y = 196;
+ static constexpr int BOTTOM_VALUE_Y = 214;
+ // Keep dynamic clears above the panel's bottom border at y=237.
+ static constexpr int BOTTOM_VALUE_H = 22;
+ static constexpr int BOTTOM_LINE_TOP = 196;
+ static constexpr int BOTTOM_LINE_H = 42;
+ // Three cells per half; BOTTOM_X[3] is the exact dashboard center divider.
+ static constexpr int BOTTOM_X[6] = {0, 56, 108, CENTER_X, 205, 262};
+ static constexpr int BOTTOM_W[6] = {56, 52, 52, 45, 57, 58};
+
+ static constexpr int RPM_SEGMENTS = 32;
+ static constexpr int RPM_SEGMENT_PITCH = 10;
+ static constexpr int RPM_SEGMENT_X = 1;
+ static constexpr int RPM_SEGMENT_W = 8;
+ static constexpr int RPM_SEGMENT_THICKNESS = 10;
+ static constexpr int RPM_LABEL_LEFT_X = 8;
+ static constexpr int RPM_LABEL_RIGHT_X = WIDTH - RPM_LABEL_LEFT_X;
+}
+
+// Keep the previous five-column dashboard available for A/B testing.
+// Set to 1 in the build flags to restore it without reverting this file.
+#ifndef GT7_DASHBOARD_LEGACY_UI
+#define GT7_DASHBOARD_LEGACY_UI 0
+#endif
+
std::map<String, String> prevData;
std::map<String, int32_t> prevColor;
@@ -429,7 +514,9 @@ public:
100.0f);
}
- brakeBias = String(fuelPercent, 0);
+ brakeBias = data.fuelCapacity > 0.0f
+ ? String(fuelPercent, 0)
+ : "--";
fuelAlertActive = String(fuelPercent, 1);
for (int tyreIndex = 0; tyreIndex < 4; tyreIndex++)
@@ -780,7 +867,11 @@ public:
if (currentPage == 1)
{
+ #if GT7_DASHBOARD_LEGACY_UI
+ drawPage1Legacy(forceUpdate);
+ #else
drawPage1(forceUpdate);
+ #endif
}
else if (forceUpdate)
{
@@ -1004,6 +1095,454 @@ public:
}
void drawPage1(bool forceUpdate = false)
+ {
+ static LGFX_Sprite speedSprite(&tft);
+ static LGFX_Sprite currentLapSprite(&tft);
+ static LGFX_Sprite gearSprite(&tft);
+ static bool speedSpriteCreated = false;
+ static bool currentLapSpriteCreated = false;
+ static bool gearSpriteCreated = false;
+ const uint16_t panelLine = tft.color565(82, 86, 92);
+ const uint16_t labelColor = tft.color565(155, 158, 162);
+
+ if (forceUpdate)
+ {
+ tft.fillScreen(TFT_BLACK);
+ tft.setTextPadding(0);
+ tft.setTextDatum(TL_DATUM);
+
+ // Three restrained panel outlines match the target dashboard grouping.
+ tft.drawRoundRect(DashboardLayout::LEFT_PANEL_X, DashboardLayout::SIDE_PANEL_Y,
+ DashboardLayout::LEFT_PANEL_W, DashboardLayout::SIDE_PANEL_H, 5, panelLine);
+ tft.drawRoundRect(DashboardLayout::RIGHT_PANEL_X, DashboardLayout::SIDE_PANEL_Y,
+ DashboardLayout::RIGHT_PANEL_W, DashboardLayout::SIDE_PANEL_H, 5, panelLine);
+ tft.drawRoundRect(DashboardLayout::BOTTOM_PANEL_X, DashboardLayout::BOTTOM_PANEL_Y,
+ DashboardLayout::BOTTOM_PANEL_W, DashboardLayout::BOTTOM_PANEL_H, 5, panelLine);
+ tft.drawFastHLine(DashboardLayout::LEFT_TEXT_X, DashboardLayout::LEFT_SEPARATOR_Y,
+ DashboardLayout::SIDE_WIDTH - 3, panelLine);
+ for (int i = 0; i < 2; ++i)
+ tft.drawFastHLine(DashboardLayout::RIGHT_TEXT_X, DashboardLayout::LAP_SEPARATOR_Y[i],
+ DashboardLayout::SIDE_WIDTH - 2, panelLine);
+
+ drawMeasuredText("SPEED", DashboardLayout::LEFT_TEXT_X,
+ DashboardLayout::SPEED_LABEL_Y, DashboardLayout::SIDE_WIDTH, 18,
+ &fonts::FreeSans9pt7b, labelColor, ML_DATUM, 0.72f, 0.74f);
+ drawMeasuredText("km/h", DashboardLayout::LEFT_X,
+ DashboardLayout::SPEED_UNIT_Y, DashboardLayout::SIDE_WIDTH - 5, 13,
+ &fonts::FreeSans9pt7b, labelColor, MR_DATUM, 0.62f, 0.64f);
+ drawMeasuredText("DELTA", DashboardLayout::LEFT_TEXT_X,
+ DashboardLayout::DELTA_LABEL_Y, DashboardLayout::SIDE_WIDTH, 18,
+ &fonts::FreeSans9pt7b, labelColor, ML_DATUM, 0.72f, 0.74f);
+ const char *lapLabels[] = {"BEST", "LAST", "CURRENT"};
+ for (int i = 0; i < 3; ++i)
+ drawMeasuredText(lapLabels[i], DashboardLayout::RIGHT_TEXT_X,
+ DashboardLayout::LAP_LABEL_Y[i], DashboardLayout::SIDE_WIDTH, 18,
+ &fonts::FreeSans9pt7b, labelColor, ML_DATUM, 0.72f, 0.74f);
+
+ const char *bottomLabels[] = {"FUEL", "LEFT", "LAP", "POS", "ABS", "TCS"};
+ for (int i = 0; i < 6; ++i)
+ {
+ if (i > 0) tft.drawFastVLine(DashboardLayout::BOTTOM_X[i],
+ DashboardLayout::BOTTOM_LINE_TOP, DashboardLayout::BOTTOM_LINE_H, panelLine);
+ drawMeasuredText(bottomLabels[i], DashboardLayout::BOTTOM_X[i],
+ DashboardLayout::BOTTOM_LABEL_Y, DashboardLayout::BOTTOM_W[i], 17,
+ &fonts::FreeSans9pt7b, labelColor, MC_DATUM, 0.70f, 0.72f);
+ }
+ tft.setTextDatum(TL_DATUM);
+ }
+
+ drawRpmMeterGT3(forceUpdate);
+ drawDashboardValueBuffered(DashboardLayout::LEFT_X, DashboardLayout::SPEED_VALUE_Y,
+ DashboardLayout::SIDE_WIDTH, DashboardLayout::SPEED_VALUE_H,
+ speed, "gt3Speed", TFT_WHITE, &fonts::DejaVu56,
+ MC_DATUM, forceUpdate, speedSprite, speedSpriteCreated, 0.72f, 0.72f);
+
+ uint16_t deltaColor = TFT_WHITE;
+ if (sessionBestLiveDeltaSeconds.startsWith("-")) deltaColor = TFT_GREEN;
+ else if (sessionBestLiveDeltaSeconds.startsWith("+") && sessionBestLiveDeltaSeconds != "+0.000") deltaColor = TFT_RED;
+ drawDashboardValue(DashboardLayout::LEFT_X, DashboardLayout::DELTA_VALUE_Y,
+ DashboardLayout::SIDE_WIDTH, DashboardLayout::DELTA_VALUE_H,
+ sessionBestLiveDeltaSeconds, "gt3Delta", deltaColor, &fonts::FreeSans18pt7b,
+ MC_DATUM, forceUpdate, 0.72f, 0.92f);
+
+ // The gear datum is tied to the physical screen center, independent of side columns.
+ drawCenteredGear(forceUpdate, gearSprite, gearSpriteCreated);
+ drawGearShiftArcs(forceUpdate);
+ drawTyreTemperatureStrip(DashboardLayout::TYRE_X, DashboardLayout::TYRE_Y,
+ DashboardLayout::TYRE_W, DashboardLayout::TYRE_H, forceUpdate, 1);
+
+ drawDashboardValue(DashboardLayout::RIGHT_TEXT_X, DashboardLayout::LAP_VALUE_Y[0],
+ DashboardLayout::SIDE_WIDTH - DashboardLayout::INNER_PADDING, DashboardLayout::LAP_VALUE_H,
+ bestLapTime, "gt3Best", TFT_WHITE, &fonts::FreeSans12pt7b,
+ MC_DATUM, forceUpdate, 0.72f, 0.90f);
+ drawDashboardValue(DashboardLayout::RIGHT_TEXT_X, DashboardLayout::LAP_VALUE_Y[1],
+ DashboardLayout::SIDE_WIDTH - DashboardLayout::INNER_PADDING, DashboardLayout::LAP_VALUE_H,
+ lastLapTime, "gt3Last", TFT_WHITE, &fonts::FreeSans12pt7b,
+ MC_DATUM, forceUpdate, 0.72f, 0.90f);
+ drawDashboardValueBuffered(DashboardLayout::RIGHT_TEXT_X, DashboardLayout::LAP_VALUE_Y[2],
+ DashboardLayout::SIDE_WIDTH - DashboardLayout::INNER_PADDING, DashboardLayout::LAP_VALUE_H,
+ currentLapTime, "gt3Current",
+ lapInvalidated == "True" ? TFT_RED : TFT_WHITE, &fonts::FreeSans12pt7b,
+ MC_DATUM, forceUpdate, currentLapSprite, currentLapSpriteCreated, 0.72f, 0.90f);
+
+ const bool absOn = isActiveValue(absActive);
+ const bool tcsOn = isActiveValue(tcActive);
+ String lapCounterDisplay = tyrePressureRearLeft;
+ lapCounterDisplay.replace("/", " / ");
+ drawFuelIndicator(DashboardLayout::BOTTOM_X[0] + 4, DashboardLayout::BOTTOM_VALUE_Y,
+ DashboardLayout::BOTTOM_W[0] - 8, DashboardLayout::BOTTOM_VALUE_H, brakeBias, forceUpdate);
+ drawDashboardValue(DashboardLayout::BOTTOM_X[1] + 2, DashboardLayout::BOTTOM_VALUE_Y,
+ DashboardLayout::BOTTOM_W[1] - 4, DashboardLayout::BOTTOM_VALUE_H,
+ tyrePressureFrontLeft, "gt3Left", TFT_WHITE, &fonts::FreeSans12pt7b,
+ MC_DATUM, forceUpdate, 0.82f, 0.80f);
+ drawDashboardValue(DashboardLayout::BOTTOM_X[2] + 2, DashboardLayout::BOTTOM_VALUE_Y,
+ DashboardLayout::BOTTOM_W[2] - 4, DashboardLayout::BOTTOM_VALUE_H,
+ lapCounterDisplay, "gt3Lap", TFT_WHITE, &fonts::FreeSans12pt7b,
+ MC_DATUM, forceUpdate, 0.56f, 0.74f);
+ drawDashboardValue(DashboardLayout::BOTTOM_X[3] + 2, DashboardLayout::BOTTOM_VALUE_Y,
+ DashboardLayout::BOTTOM_W[3] - 4, DashboardLayout::BOTTOM_VALUE_H,
+ tyrePressureFrontRight, "gt3Pos", tft.color565(160, 60, 255), &fonts::FreeSans12pt7b,
+ MC_DATUM, forceUpdate, 0.82f, 0.80f);
+ drawCompactStatus(DashboardLayout::BOTTOM_X[4] + 2, DashboardLayout::BOTTOM_VALUE_Y,
+ DashboardLayout::BOTTOM_W[4] - 4, DashboardLayout::BOTTOM_VALUE_H,
+ "gt3Abs", absOn, tft.color565(57, 255, 20), forceUpdate);
+ drawCompactStatus(DashboardLayout::BOTTOM_X[5] + 2, DashboardLayout::BOTTOM_VALUE_Y,
+ DashboardLayout::BOTTOM_W[5] - 6, DashboardLayout::BOTTOM_VALUE_H,
+ "gt3Tcs", tcsOn, tft.color565(0, 200, 255), forceUpdate);
+ }
+
+ void drawMeasuredText(const String &value, int32_t x, int32_t y,
+ int32_t width, int32_t height, const lgfx::IFont *font, uint16_t color,
+ textdatum_t datum, float scaleX = 1.0f, float scaleY = 1.0f)
+ {
+ tft.setTextPadding(0);
+ tft.setTextColor(color, TFT_BLACK);
+ tft.setTextSize(scaleX, scaleY);
+ tft.setFont(font);
+
+ const int32_t measuredWidth = tft.textWidth(value);
+ const int32_t measuredHeight = tft.fontHeight();
+ int32_t drawX = x;
+ if (datum == MC_DATUM || datum == TC_DATUM || datum == BC_DATUM)
+ drawX = x + (width - measuredWidth) / 2;
+ else if (datum == MR_DATUM || datum == TR_DATUM || datum == BR_DATUM)
+ drawX = x + width - measuredWidth;
+
+ const int32_t drawY = y + (height - measuredHeight) / 2;
+ tft.setTextDatum(TL_DATUM);
+ tft.drawString(value, drawX, drawY);
+ tft.setFont(&fonts::Font0);
+ tft.setTextSize(1.0f);
+ tft.setTextDatum(TL_DATUM);
+ }
+
+ void drawGearGaugeArcs(uint16_t color)
+ {
+ const int radiusOuter = DashboardLayout::GEAR_RADIUS;
+ const int angleStep = 2;
+
+ auto drawOneArc = [&](int startAngle, int endAngle, int radius)
+ {
+ float previousRadians = startAngle * DEG_TO_RAD;
+ int previousX = DashboardLayout::GEAR_CENTER_X + lroundf(cosf(previousRadians) * radius);
+ int previousY = DashboardLayout::GEAR_CENTER_Y + lroundf(sinf(previousRadians) * radius);
+ for (int angle = startAngle + angleStep; angle <= endAngle; angle += angleStep)
+ {
+ const float radians = angle * DEG_TO_RAD;
+ const int currentX = DashboardLayout::GEAR_CENTER_X + lroundf(cosf(radians) * radius);
+ const int currentY = DashboardLayout::GEAR_CENTER_Y + lroundf(sinf(radians) * radius);
+ tft.drawLine(previousX, previousY, currentX, currentY, color);
+ previousX = currentX;
+ previousY = currentY;
+ }
+ };
+
+ // Equal 44-degree openings at twelve and six o'clock.
+ // Two closely spaced traces create a smooth, readable gauge outline
+ // without turning it into a heavy four-pixel bracket.
+ for (int radius = radiusOuter; radius >= radiusOuter - 1; --radius)
+ {
+ drawOneArc(-68, 68, radius);
+ drawOneArc(112, 248, radius);
+ }
+ }
+
+ void drawGearShiftArcs(bool forceUpdate)
+ {
+ const String id = "gt3GearArcs";
+ if (!forceUpdate && prevData[id] == gear) return;
+
+ const int gearNumber = gear.toInt();
+ const int radius = 54;
+ const int segmentSweep = 18;
+ const int segmentStep = 29;
+ const uint16_t currentGearColor = tft.color565(72, 76, 82);
+ const uint16_t otherGearColor = tft.color565(218, 220, 224);
+
+ auto drawArcSegment = [&](int startAngle, int endAngle, uint16_t color)
+ {
+ for (int thickness = 0; thickness < 3; ++thickness)
+ {
+ const int r = radius - thickness;
+ float previousRadians = startAngle * DEG_TO_RAD;
+ int previousX = DashboardLayout::GEAR_CENTER_X + lroundf(cosf(previousRadians) * r);
+ int previousY = DashboardLayout::GEAR_CENTER_Y + lroundf(sinf(previousRadians) * r);
+ for (int angle = startAngle + 2; angle <= endAngle; angle += 2)
+ {
+ const float radians = angle * DEG_TO_RAD;
+ const int currentX = DashboardLayout::GEAR_CENTER_X + lroundf(cosf(radians) * r);
+ const int currentY = DashboardLayout::GEAR_CENTER_Y + lroundf(sinf(radians) * r);
+ tft.drawLine(previousX, previousY, currentX, currentY, color);
+ previousX = currentX;
+ previousY = currentY;
+ }
+ }
+ };
+
+ // Segment zero starts at the bottom; higher gears illuminate upward.
+ for (int segment = 0; segment < 4; ++segment)
+ {
+ const int rightStart = 34 - segment * segmentStep;
+ const int rightEnd = rightStart + segmentSweep;
+ const bool marksCurrentGear = gearNumber >= 1 && gearNumber <= 4 &&
+ segment == gearNumber - 1;
+ const uint16_t color = marksCurrentGear ? currentGearColor : otherGearColor;
+ drawArcSegment(rightStart, rightEnd, color);
+ drawArcSegment(180 - rightEnd, 180 - rightStart, color);
+ }
+
+ prevData[id] = gear;
+ }
+
+ void drawDashboardValue(int32_t x, int32_t y, int32_t width, int32_t height,
+ const String &value, const String &id, uint16_t color, const lgfx::IFont *font,
+ textdatum_t datum, bool forceUpdate, float scaleX = 1.0f, float scaleY = 1.0f)
+ {
+ if (!forceUpdate && prevData[id] == value && prevColor[id] == color) return;
+ tft.fillRect(x, y, width, height, TFT_BLACK);
+ drawMeasuredText(value, x, y, width, height, font, color, datum, scaleX, scaleY);
+ prevData[id] = value;
+ prevColor[id] = color;
+ }
+
+ void drawDashboardValueBuffered(int32_t x, int32_t y, int32_t width, int32_t height,
+ const String &value, const String &id, uint16_t color, const lgfx::IFont *font,
+ textdatum_t datum, bool forceUpdate, LGFX_Sprite &sprite, bool &spriteCreated,
+ float scaleX = 1.0f, float scaleY = 1.0f)
+ {
+ if (!forceUpdate && prevData[id] == value && prevColor[id] == color) return;
+
+ if (!spriteCreated)
+ {
+ sprite.setColorDepth(16);
+ spriteCreated = sprite.createSprite(width, height) != nullptr;
+ }
+
+ // Fall back safely if heap fragmentation prevents this small allocation.
+ if (!spriteCreated)
+ {
+ drawDashboardValue(x, y, width, height, value, id, color, font,
+ datum, forceUpdate, scaleX, scaleY);
+ return;
+ }
+
+ sprite.fillSprite(TFT_BLACK);
+ sprite.setTextPadding(0);
+ sprite.setTextColor(color, TFT_BLACK);
+ sprite.setTextSize(scaleX, scaleY);
+ sprite.setFont(font);
+
+ const int32_t measuredWidth = sprite.textWidth(value);
+ const int32_t measuredHeight = sprite.fontHeight();
+ int32_t drawX = 0;
+ if (datum == MC_DATUM || datum == TC_DATUM || datum == BC_DATUM)
+ drawX = (width - measuredWidth) / 2;
+ else if (datum == MR_DATUM || datum == TR_DATUM || datum == BR_DATUM)
+ drawX = width - measuredWidth;
+ const int32_t drawY = (height - measuredHeight) / 2;
+
+ sprite.setTextDatum(TL_DATUM);
+ sprite.drawString(value, drawX, drawY);
+ sprite.pushSprite(x, y);
+ sprite.setFont(&fonts::Font0);
+ sprite.setTextSize(1.0f);
+
+ prevData[id] = value;
+ prevColor[id] = color;
+ }
+
+ void drawCenteredGear(bool forceUpdate, LGFX_Sprite &sprite, bool &spriteCreated)
+ {
+ const String id = "gt3Gear";
+ if (!forceUpdate && prevData[id] == gear) return;
+
+ const int width = DashboardLayout::GEAR_VALUE_W;
+ const int height = DashboardLayout::GEAR_VALUE_H;
+ if (!spriteCreated)
+ {
+ sprite.setColorDepth(16);
+ spriteCreated = sprite.createSprite(width, height) != nullptr;
+ }
+
+ if (!spriteCreated)
+ {
+ drawDashboardValue(DashboardLayout::GEAR_VALUE_X, DashboardLayout::GEAR_VALUE_Y,
+ width, height, gear, id, TFT_WHITE, &fonts::DejaVu72,
+ MC_DATUM, forceUpdate, 1.25f, 1.25f);
+ return;
+ }
+
+ sprite.setTextPadding(0);
+ sprite.setTextColor(TFT_WHITE, TFT_BLACK);
+ sprite.setTextSize(1.25f, 1.25f);
+ sprite.setFont(&fonts::DejaVu72);
+ sprite.setTextDatum(TL_DATUM);
+
+ const int initialX = (width - sprite.textWidth(gear)) / 2;
+ const int initialY = (height - sprite.fontHeight()) / 2;
+ sprite.fillSprite(TFT_BLACK);
+ sprite.drawString(gear, initialX, initialY);
+
+ int minX = width;
+ int minY = height;
+ int maxX = -1;
+ int maxY = -1;
+ for (int py = 0; py < height; ++py)
+ {
+ for (int px = 0; px < width; ++px)
+ {
+ if (sprite.readPixel(px, py) == TFT_BLACK) continue;
+ minX = min(minX, px);
+ maxX = max(maxX, px);
+ minY = min(minY, py);
+ maxY = max(maxY, py);
+ }
+ }
+
+ int correctedX = initialX;
+ int correctedY = initialY;
+ if (maxX >= minX && maxY >= minY)
+ {
+ correctedX += (width - 1 - minX - maxX) / 2;
+ correctedY += (height - 1 - minY - maxY) / 2;
+ }
+
+ sprite.fillSprite(TFT_BLACK);
+ sprite.drawString(gear, correctedX, correctedY);
+ sprite.pushSprite(DashboardLayout::GEAR_VALUE_X, DashboardLayout::GEAR_VALUE_Y);
+ sprite.setFont(&fonts::Font0);
+ sprite.setTextSize(1.0f);
+ prevData[id] = gear;
+ }
+
+ void drawFuelIndicator(int32_t x, int32_t y, int32_t width, int32_t height,
+ const String &value, bool forceUpdate)
+ {
+ const String id = "gt3Fuel";
+ if (!forceUpdate && prevData[id] == value) return;
+
+ tft.fillRect(x, y, width, height, TFT_BLACK);
+ const uint16_t color = TFT_WHITE;
+ const int32_t pumpX = x + 2;
+ const int32_t pumpHeight = 18;
+ const int32_t pumpY = y + (height - pumpHeight) / 2 - 1;
+
+ // Allocation-free monochrome fuel pump: body, window, base and hose.
+ tft.drawRect(pumpX, pumpY, 8, 13, color);
+ tft.drawRect(pumpX + 2, pumpY + 2, 4, 4, color);
+ tft.drawFastHLine(pumpX - 1, pumpY + 17, 11, color);
+ tft.drawFastVLine(pumpX + 10, pumpY + 4, 8, color);
+ tft.drawLine(pumpX + 7, pumpY + 2, pumpX + 10, pumpY + 5, color);
+ tft.drawLine(pumpX + 10, pumpY + 12, pumpX + 12, pumpY + 15, color);
+
+ const int32_t valueX = x + 16;
+ const int32_t valueWidth = width - 16;
+ drawMeasuredText(value, valueX, y, valueWidth, height,
+ &fonts::FreeSans12pt7b, color, MC_DATUM, 0.70f, 0.80f);
+ prevData[id] = value;
+ }
+
+ void drawCompactStatus(int32_t x, int32_t y, int32_t width, int32_t height,
+ const String &id, bool active, uint16_t activeColor, bool forceUpdate)
+ {
+ const String state = active ? "1" : "0";
+ if (!forceUpdate && prevData[id] == state) return;
+ tft.fillRect(x, y, width, height, TFT_BLACK);
+ const uint16_t color = activeColor;
+ const int32_t centerY = y + (height - 1) / 2 - 2;
+ tft.drawCircle(x + width / 2, centerY, 7, color);
+ if (active) tft.fillCircle(x + width / 2, centerY, 4, color);
+ prevData[id] = state;
+ }
+
+ void drawRpmMeterGT3(bool forceUpdate)
+ {
+ const int segmentCount = DashboardLayout::RPM_SEGMENTS;
+ const int active = constrain((rpmPercent * segmentCount + 99) / 100, 0, segmentCount);
+ const int previous = forceUpdate ? -1 : constrain((prev_rpmPercent * segmentCount + 99) / 100, 0, segmentCount);
+ const bool redlineChanged = prevData["gt3Redline"] != String(rpmRedLineSetting);
+ if (!forceUpdate && active == previous && !redlineChanged) return;
+ const int gradientStops[] = {0, 11, 20, 26, 31};
+ const uint8_t gradientRgb[][3] = {
+ {86, 90, 96}, {245, 245, 245}, {255, 220, 0},
+ {255, 118, 0}, {255, 20, 28}};
+
+ for (int i = 0; i < segmentCount; ++i)
+ {
+ if (!forceUpdate && !redlineChanged && i < min(active, previous)) continue;
+ if (!forceUpdate && !redlineChanged && i >= max(active, previous)) continue;
+ int stop = 0;
+ while (stop < 3 && i > gradientStops[stop + 1]) ++stop;
+ const int span = gradientStops[stop + 1] - gradientStops[stop];
+ const int offset = constrain(i - gradientStops[stop], 0, span);
+ int red = gradientRgb[stop][0] +
+ (gradientRgb[stop + 1][0] - gradientRgb[stop][0]) * offset / span;
+ int green = gradientRgb[stop][1] +
+ (gradientRgb[stop + 1][1] - gradientRgb[stop][1]) * offset / span;
+ int blue = gradientRgb[stop][2] +
+ (gradientRgb[stop + 1][2] - gradientRgb[stop][2]) * offset / span;
+ if (i >= active)
+ {
+ red /= 4;
+ green /= 4;
+ blue /= 4;
+ }
+ const uint16_t color = tft.color565(red, green, blue);
+ // A shallow parabola gives an inexpensive GT-style arc. Each segment is
+ // a four-point strip made from two filled triangles, with a 3 px gap.
+ const int x0 = DashboardLayout::RPM_SEGMENT_X + i * DashboardLayout::RPM_SEGMENT_PITCH;
+ const int x1 = x0 + DashboardLayout::RPM_SEGMENT_W;
+ const int dx0 = x0 - DashboardLayout::CENTER_X;
+ const int dx1 = x1 - DashboardLayout::CENTER_X;
+ const int y0 = 11 + (dx0 * dx0) / 1000;
+ const int y1 = 11 + (dx1 * dx1) / 1000;
+ const int thickness = DashboardLayout::RPM_SEGMENT_THICKNESS;
+ tft.fillTriangle(x0, y0, x1, y1, x0, y0 + thickness, color);
+ tft.fillTriangle(x1, y1, x1, y1 + thickness, x0, y0 + thickness, color);
+ }
+ if (forceUpdate)
+ {
+ const uint16_t rpmTextColor = tft.color565(160, 163, 168);
+ const char *labels[] = {"0", "2", "4", "6", "8", "10"};
+ for (int i = 0; i < 6; ++i)
+ {
+ const int labelX = DashboardLayout::RPM_LABEL_LEFT_X +
+ (DashboardLayout::RPM_LABEL_RIGHT_X - DashboardLayout::RPM_LABEL_LEFT_X) * i / 5;
+ const int dx = labelX - DashboardLayout::CENTER_X;
+ const int labelY = 1 + (dx * dx) / 1100;
+ drawMeasuredText(labels[i], labelX - 10, labelY, 20, 10,
+ &fonts::FreeSans9pt7b, rpmTextColor, MC_DATUM, 0.54f, 0.52f);
+ }
+
+ // Dedicated center caption band below the arc; it cannot overlap ticks.
+ drawMeasuredText("RPM x1000", DashboardLayout::CENTER_X - 55, 28, 110, 18,
+ &fonts::FreeSans9pt7b, rpmTextColor, MC_DATUM, 0.74f, 0.72f);
+ }
+ prev_rpmPercent = rpmPercent;
+ prevData["gt3Redline"] = String(rpmRedLineSetting);
+ }
+
+ void drawPage1Legacy(bool forceUpdate = false)
{
drawRpmMeter(0, 0, SCREEN_WIDTH, HALF_CELL_HEIGHT);
drawGear(COL[2], COL[1]);
@@ -1568,9 +2107,9 @@ public:
int32_t y,
int width,
int height,
- bool forceUpdate = false)
+ bool forceUpdate = false,
+ uint8_t gap = 2)
{
- const int gap = 2;
const int blockWidth = (width - gap) / 2;
const int blockHeight = (height - gap) / 2;
const String gearId = "tyreTemperatureGear";