From 100d19762e5c3204c1a34bfbe98aec1c88e5de56 Mon Sep 17 00:00:00 2001 From: Sebastian Nieto Date: Tue, 22 Sep 2026 00:39:47 -0300 Subject: [PATCH] fix(display): render authentic DSEG7 34pt font during transition for pixel-perfect match --- sketch/obd2_gauge/meter.h | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/sketch/obd2_gauge/meter.h b/sketch/obd2_gauge/meter.h index b2cc95b..fb8ae09 100644 --- a/sketch/obd2_gauge/meter.h +++ b/sketch/obd2_gauge/meter.h @@ -1374,10 +1374,16 @@ inline void renderPage0ToSprite(TFT_eSprite &s, int x_offset, int y_slice, int s drawQuadBarBlockToSprite(s, qx, qy, i, bCol, slice_h); } - // 4. Digital value string + // 4. Digital value string using authentic DSEG7 34pt font (pixel-perfect match with resting screen) String numStr = (val <= -900.0f) ? "---" : String(val, digit); - s.setTextColor(priCol); - s.drawRightString(numStr.c_str(), qx + 152, qy + 74, 4); + int textY = qy + 74; + if (textY < slice_h && textY + 40 > 0) { + s.fontLoaded = true; + s.setTextColor(priCol, TFT_BLACK); + s.setTextPadding(0); + s.drawRightString(numStr.c_str(), qx + 152, textY, 1); + s.fontLoaded = false; + } } // 5. Eco Badge if active @@ -1470,10 +1476,16 @@ inline void renderPage1ToSprite(TFT_eSprite &s, int x_offset, int y_slice, int s if (fillW < 4) fillW = 4; s.fillRoundRect(barX, barY, fillW, 8, 3, accentCol); - // Value text (clean built-in font 4: zero padding artifacts, zero distortion) + // Value text using authentic DSEG7 34pt font matching drawTriTempCard String numStr = (val <= -900.0f) ? "---" : (isInt ? String((int)val) : String(val, 1)); - s.setTextColor(accentCol, cardBg); - s.drawRightString(numStr.c_str(), cardX + 262, cardY + 24, 4); + int numY = cardY + 22; + if (numY < slice_h && numY + 40 > 0) { + s.fontLoaded = true; + s.setTextColor(accentCol, cardBg); + s.setTextPadding(0); + s.drawRightString(numStr.c_str(), cardX + 262, numY, 1); + s.fontLoaded = false; + } s.setTextColor(0xC618, cardBg); s.drawString("`C", cardX + 268, cardY + 32, 2); @@ -1494,7 +1506,9 @@ inline void animateSlideTransition(bool swipeLeft) { } spr.setTextFont(1); // CRITICAL: initializes textfont=1 and clears uninitialized gfxFont=NULL spr.setFreeFont(NULL); // CRITICAL: prevents crash in textWidth() when drawing Font 1 on stack sprite - Serial.printf(">>> [DB] Sprite created OK. Heap: %u, MaxAlloc: %u\n", ESP.getFreeHeap(), ESP.getMaxAllocHeap()); + spr.loadFont(DSEG7_Modern_BoldItalic_34); + spr.fontLoaded = false; // Default to standard fonts until DSEG7 digits are drawn + Serial.printf(">>> [DB] Sprite created OK with DSEG7. Heap: %u, MaxAlloc: %u\n", ESP.getFreeHeap(), ESP.getMaxAllocHeap()); const uint8_t FRAMES = 28; // High-density sine ease-out deceleration over 28 frames: @@ -1549,6 +1563,8 @@ inline void animateSlideTransition(bool swipeLeft) { delay(7); // Ultra-smooth high density pacing (~330ms total) } + spr.fontLoaded = true; + spr.unloadFont(); spr.deleteSprite(); // Release the 25KB Serial.printf(">>> [DB] animateSlideTransition LEAVE (heap: %u)\n", ESP.getFreeHeap()); }