Eliminate placeholder dashes on mode toggle by immediately rendering last valid data
This commit is contained in:
parent
e4daf02c37
commit
449a460f9c
2 changed files with 71 additions and 35 deletions
|
|
@ -35,6 +35,7 @@ uint8_t pidCurrentSkip[maxpidIndex] = {}; // current skip counter
|
|||
uint8_t engine_off_count = 0; // counter to indicate engine is off then sleep
|
||||
float old_data[maxpidIndex] =
|
||||
{}; // keep old data for each gauge to improve speed for pidIndex 0-6
|
||||
float last_valid_data[maxpidIndex] = {-999, -999, -999, -999}; // keep last valid reading across view toggles
|
||||
|
||||
// backlight variable average counter
|
||||
uint8_t low_count = 0;
|
||||
|
|
@ -371,6 +372,13 @@ int get7SegWidth(const char *str, uint8_t dW, uint8_t t) {
|
|||
return total;
|
||||
}
|
||||
|
||||
// Forward declarations
|
||||
void plotNumeric4(uint8_t cell, float data, int warn, bool digit, String unit);
|
||||
void plotArc4(uint8_t cell, float data, int warn, int min, int max, bool digit,
|
||||
String unit);
|
||||
void plotFullScreen(uint8_t cell, float data, int warn, int min, int max,
|
||||
bool digit, String unit);
|
||||
|
||||
// 4-quadrant Numeric Meter (160x120 px)
|
||||
void numericMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
||||
int w = 160;
|
||||
|
|
@ -392,6 +400,13 @@ void numericMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
|||
// Clear only the body below the header to avoid any header flickering
|
||||
tft.fillRect(x + 1, y + 25, w - 2, h - 26, TFT_BLACK);
|
||||
|
||||
int warn = warningValue[pid].toInt();
|
||||
bool digit = pidConfig[pid][7].toInt();
|
||||
|
||||
if (last_valid_data[cell] != -999) {
|
||||
old_data[cell] = -999;
|
||||
plotNumeric4(cell, last_valid_data[cell], warn, digit, unit);
|
||||
} else {
|
||||
// Initial placeholder: right-aligned DSEG7 44pt number
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_44);
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
|
|
@ -399,6 +414,7 @@ void numericMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
|||
tft.drawRightString("---", x + w - 10, y + 46, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
}
|
||||
}
|
||||
|
||||
void plotNumeric4(uint8_t cell, float data, int warn, bool digit, String unit) {
|
||||
|
|
@ -442,11 +458,20 @@ void arcMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
|||
// Clear only the body below the header to avoid any header flickering
|
||||
tft.fillRect(x + 1, y + 25, w - 2, h - 26, TFT_BLACK);
|
||||
|
||||
int min = pidConfig[pid][4].toInt();
|
||||
int max = pidConfig[pid][5].toInt();
|
||||
bool digit = pidConfig[pid][7].toInt();
|
||||
int warn = warningValue[pid].toInt();
|
||||
|
||||
// Lowered smooth arc track (Center Y = y + 96, R = 66, IR = 54, thickness
|
||||
// 13px, sweep 130 deg: 115 to 245)
|
||||
tft.drawSmoothArc(x + 80, y + 96, 66, 54, 115, 245, TFT_DARKGREY, TFT_BLACK,
|
||||
false);
|
||||
|
||||
if (last_valid_data[cell] != -999) {
|
||||
old_data[cell] = -999;
|
||||
plotArc4(cell, last_valid_data[cell], warn, min, max, digit, unit);
|
||||
} else {
|
||||
// Value placeholder using DSEG7 Modern 24pt smooth font
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_24);
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
|
|
@ -454,6 +479,7 @@ void arcMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
|||
tft.drawRightString("---", x + 116, y + 86, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
}
|
||||
}
|
||||
|
||||
void plotArc4(uint8_t cell, float data, int warn, int min, int max, bool digit,
|
||||
|
|
@ -508,6 +534,15 @@ void fullScreenMeter(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
|||
// Clear only below header
|
||||
tft.fillRect(0, 38, 320, 202, TFT_BLACK);
|
||||
|
||||
int min = pidConfig[pid][4].toInt();
|
||||
int max = pidConfig[pid][5].toInt();
|
||||
bool digit = pidConfig[pid][7].toInt();
|
||||
int warn = warningValue[pid].toInt();
|
||||
|
||||
if (last_valid_data[cell] != -999) {
|
||||
old_data[cell] = -999;
|
||||
plotFullScreen(cell, last_valid_data[cell], warn, min, max, digit, unit);
|
||||
} else {
|
||||
if (!cellIsNumeric[cell]) {
|
||||
// Arc mode full screen
|
||||
// Large full screen arc (Center: 160, 195, R: 130, IR: 108, thickness 23px,
|
||||
|
|
@ -530,6 +565,7 @@ void fullScreenMeter(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
|||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void plotFullScreen(uint8_t cell, float data, int warn, int min, int max,
|
||||
|
|
@ -736,6 +772,8 @@ void updateMeter(uint8_t pidNo, String response) { // update parameter on screen
|
|||
}
|
||||
}
|
||||
|
||||
last_valid_data[pidNo] = data;
|
||||
|
||||
// Engine off check if PCM volt or ATRV
|
||||
if (pidConfig[pidIdx][2] == "0142" || pidConfig[pidIdx][2] == "ATRV") {
|
||||
engine_onoff(data, pidNo);
|
||||
|
|
|
|||
|
|
@ -498,7 +498,6 @@ void loop() {
|
|||
// In full screen: single click toggles between arc and number mode without header flicker
|
||||
cellIsNumeric[fullScreenCell] = !cellIsNumeric[fullScreenCell];
|
||||
fullScreenMeter(fullScreenCell, pidInCell[fullScreenCell], false);
|
||||
old_data[fullScreenCell] = -999;
|
||||
} else if (clickQuadrant >= 0 && clickQuadrant < 4) {
|
||||
// In 4 quadrants: single click toggles between arc and number for this quadrant without header flicker
|
||||
cellIsNumeric[clickQuadrant] = !cellIsNumeric[clickQuadrant];
|
||||
|
|
@ -508,7 +507,6 @@ void loop() {
|
|||
} else {
|
||||
arcMeter4(clickQuadrant, pid, false);
|
||||
}
|
||||
old_data[clickQuadrant] = -999;
|
||||
}
|
||||
}
|
||||
//----------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue