diff --git a/sketch/obd2_gauge/meter.h b/sketch/obd2_gauge/meter.h index 8596beb..36582c2 100644 --- a/sketch/obd2_gauge/meter.h +++ b/sketch/obd2_gauge/meter.h @@ -1778,16 +1778,19 @@ inline void renderPage1ToSprite(TFT_eSprite &s, int x_offset, int y_slice, // Value text using authentic DSEG7 34pt font matching drawTriTempCard String numStr = (val <= -900.0f) ? "---" : (isInt ? String((int)val) : String(val, 1)); - int numY = cardY + 20; + 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 + 270, numY, 1); + s.drawRightString(numStr.c_str(), cardX + 262, numY, 1); s.fontLoaded = false; - // Unit "`C" during transition animation aligned to digit base - s.setTextColor(accentCol, cardBg); - s.drawString("`C", cardX + 276, cardY + 37, 2); + } + + int unitY = cardY + 32; + if (unitY < slice_h && unitY + 16 > 0) { + s.setTextColor(0xC618, cardBg); + s.drawString("`C", cardX + 268, unitY, 2); } } } diff --git a/sketch/obd2_gauge/tri_temp.h b/sketch/obd2_gauge/tri_temp.h index da71d34..dc37e28 100644 --- a/sketch/obd2_gauge/tri_temp.h +++ b/sketch/obd2_gauge/tri_temp.h @@ -78,84 +78,7 @@ inline void initTriTemp() { #endif } -// 8-bit anti-aliased alpha mask for digital 7-segment italic "°C" (30x26) -const uint8_t s_dsegUnitAlpha[30 * 26] PROGMEM = { - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x10, 0x11, 0x11, 0x12, 0x0E, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x7A, 0xED, 0xEC, 0xED, 0xED, 0xE4, 0x2A, 0x00, 0x02, - 0x02, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x10, 0x11, 0x03, 0x00, 0x01, - 0x00, 0x00, 0x01, 0x02, 0x0C, 0xA2, 0xFF, 0xF2, 0xF3, 0xF4, 0xF1, 0xFF, 0xD2, 0x12, 0x04, - 0x00, 0x01, 0x97, 0xEE, 0xEC, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEC, 0xEE, 0xC1, 0x13, 0x01, - 0x00, 0x00, 0x04, 0x00, 0x5C, 0xFF, 0x9F, 0x10, 0x14, 0x10, 0x13, 0xD9, 0xFF, 0x2B, 0x00, - 0x12, 0xB6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x00, - 0x00, 0x00, 0x04, 0x00, 0x92, 0xFC, 0x63, 0x00, 0x01, 0x00, 0x19, 0xFC, 0xE1, 0x05, 0x31, - 0xD8, 0xFF, 0xFC, 0xFE, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFB, 0xF9, 0x89, 0x0B, 0x02, - 0x00, 0x00, 0x01, 0x00, 0xC8, 0xFF, 0x38, 0x05, 0x0B, 0x05, 0x4E, 0xFF, 0xAD, 0x00, 0xD4, - 0xFF, 0xFC, 0x66, 0x27, 0x2A, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x23, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x15, 0xF3, 0xE9, 0x00, 0x00, 0x00, 0x00, 0x79, 0xFF, 0x73, 0x09, 0xF8, - 0xFD, 0xF6, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, - 0x00, 0x02, 0x00, 0x2A, 0xFF, 0xDF, 0x7A, 0x7C, 0x7D, 0x7A, 0xDB, 0xFC, 0x28, 0x3B, 0xFF, - 0xFF, 0xD5, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x84, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0x46, 0x00, 0x7E, 0xFF, - 0xFF, 0xA3, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x70, 0x7B, 0x7A, 0x7A, 0x79, 0x22, 0x00, 0x00, 0xAF, 0xFF, - 0xFF, 0x6E, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0xDF, 0xFF, - 0xFF, 0x3A, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x27, 0xFB, 0xFF, - 0xED, 0x11, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x57, 0xFF, 0xFF, - 0xC5, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x8A, 0xFF, 0xFF, - 0x91, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xC0, 0xFF, 0xFF, - 0x5D, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0C, 0xE9, 0xFF, 0xFC, - 0x2D, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x34, 0xFF, 0xFF, 0xE4, - 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x67, 0xFF, 0xFF, 0xB6, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x9C, 0xFF, 0xFF, 0x82, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0xCF, 0xFF, 0xFF, 0x4D, - 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x16, 0xF2, 0xFF, 0xF7, 0x1A, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x4B, 0xFF, 0xFE, 0xD8, 0x12, - 0x12, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x20, 0xE4, 0xFF, 0xF7, 0xED, - 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEB, 0xED, 0x93, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x37, 0xFA, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3D, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x67, 0xF9, 0xF6, - 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF8, 0xF7, 0xE9, 0x5B, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x28, 0x2A, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x29, 0x2A, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -static uint16_t s_unitRenderBuf[30 * 26]; - -// Draw 100% anti-aliased digital 7-segment italic unit "°C" matching DSEG7 typography and color -inline void draw7SegDegreeC(TFT_eSPI &dst, int bx, int by, uint16_t color, uint16_t bgCol) { - for (int j = 0; j < 26; j++) { - int rowOffset = j * 30; - for (int i = 0; i < 30; i++) { - uint8_t a = pgm_read_byte(&s_dsegUnitAlpha[rowOffset + i]); - if (a == 0) { - s_unitRenderBuf[rowOffset + i] = bgCol; - } else if (a >= 250) { - s_unitRenderBuf[rowOffset + i] = color; - } else { - s_unitRenderBuf[rowOffset + i] = fastBlend(a, color, bgCol); - } - } - } - bool oldSwap = dst.getSwapBytes(); - dst.setSwapBytes(true); - dst.pushImage(bx, by, 30, 26, s_unitRenderBuf); - dst.setSwapBytes(oldSwap); -} // Double-buffered 120x8 progress bar sprite (zero jitter) static TFT_eSprite sprBar(&tft); @@ -279,17 +202,14 @@ inline void drawTriTempCard(uint8_t cardIdx, float val, int x_offset = 0) { tft.loadFont(DSEG7_Modern_BoldItalic_34); tft.setTextColor(accentCol, cardBg); + tft.setTextPadding(100); + tft.drawRightString(numStr.c_str(), cardX + 262, cardY + 22, 1); tft.setTextPadding(0); - tft.drawRightString(numStr.c_str(), cardX + 270, cardY + 20, 1); tft.unloadFont(); - // Unit "°C" in authentic 7-segment digital italic matching number typography and aligned to digit base - if (x_offset == 0) { - draw7SegDegreeC(tft, cardX + 276, cardY + 28, accentCol, cardBg); - } else { - tft.setTextColor(accentCol, cardBg); - tft.drawString("`C", cardX + 276, cardY + 37, 2); - } + // Unit "°C" + tft.setTextColor(0xC618, cardBg); + tft.drawString("`C", cardX + 268, cardY + 32, 2); } // Flicker-free dynamic value update for a single temperature card @@ -340,10 +260,9 @@ inline void updateTriTempCardValue(uint8_t cardIdx, float val, float oldVal) { oldAccentCol = accentCol; } - // 1. Accent color changed: update vertical accent bar and unit "°C" + // 1. Accent color changed: update vertical accent bar if (accentCol != oldAccentCol) { tft.fillRoundRect(cardX + 6, cardY + 8, 4, cardH - 16, 2, accentCol); - draw7SegDegreeC(tft, cardX + 276, cardY + 28, accentCol, cardBg); } // 2. Horizontal Progress Gauge Bar update (only redraw when pixel fill changes or accent changes) @@ -375,8 +294,8 @@ inline void updateTriTempCardValue(uint8_t cardIdx, float val, float oldVal) { tft.loadFont(DSEG7_Modern_BoldItalic_34); tft.setTextColor(accentCol, cardBg); - tft.setTextPadding(114); - tft.drawRightString(numStr.c_str(), cardX + 270, cardY + 20, 1); + tft.setTextPadding(100); + tft.drawRightString(numStr.c_str(), cardX + 262, cardY + 22, 1); tft.setTextPadding(0); tft.unloadFont(); }