Flash digital value reading synchronously with arc alarm in red zone
This commit is contained in:
parent
259c4d6bbf
commit
117d3082b0
1 changed files with 136 additions and 49 deletions
|
|
@ -800,9 +800,17 @@ void plotNumeric4(uint8_t cell, float data, int warn, bool digit, String unit) {
|
|||
uint8_t pidIdx = pidInCell[cell];
|
||||
uint16_t col = getMeterColor(pidIdx, data, warn);
|
||||
|
||||
if (col == TFT_RED) {
|
||||
wasInRedAlarm[cell] = true;
|
||||
} else {
|
||||
wasInRedAlarm[cell] = false;
|
||||
}
|
||||
|
||||
uint16_t txtCol = (col == TFT_RED && !arcFlashVisible) ? TFT_BLACK : col;
|
||||
|
||||
String numStr = String(data, digit);
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_44);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(w - 12);
|
||||
tft.drawRightString(numStr.c_str(), x + w - 10, y + 46, 1);
|
||||
tft.setTextPadding(0);
|
||||
|
|
@ -910,8 +918,10 @@ void plotArc4(uint8_t cell, float data, int warn, int min, int max, bool digit,
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t txtCol = (col == TFT_RED && !arcFlashVisible) ? TFT_BLACK : col;
|
||||
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_34);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(114);
|
||||
tft.drawRightString(numStr.c_str(), x + 152, y + 74, 1);
|
||||
tft.setTextPadding(0);
|
||||
|
|
@ -1068,17 +1078,26 @@ void plotFullScreen(uint8_t cell, float data, int warn, int min, int max,
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t txtCol = (col == TFT_RED && !arcFlashVisible) ? TFT_BLACK : col;
|
||||
|
||||
// Value bottom-right using DSEG7 Modern smooth font
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(240);
|
||||
tft.drawRightString(numStr.c_str(), 312, 148, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
} else {
|
||||
// Digital numeric mode full screen with DSEG7 Smooth Font (Anti-Aliased)
|
||||
if (col == TFT_RED) {
|
||||
wasInRedAlarm[cell] = true;
|
||||
} else {
|
||||
wasInRedAlarm[cell] = false;
|
||||
}
|
||||
uint16_t txtCol = (col == TFT_RED && !arcFlashVisible) ? TFT_BLACK : col;
|
||||
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(295);
|
||||
tft.drawRightString(numStr.c_str(), 295, 98, 1);
|
||||
tft.setTextPadding(0);
|
||||
|
|
@ -1288,7 +1307,7 @@ void updateMeter(uint8_t pidNo, String response) { // update parameter on screen
|
|||
}
|
||||
/*-------------------------------*/
|
||||
|
||||
// Non-blocking handler to blink/flash arcs on alarm (when in TFT_RED)
|
||||
// Non-blocking handler to blink/flash arcs and numerical values on alarm (when in TFT_RED)
|
||||
void handleArcAlarmFlash() {
|
||||
uint32_t now = millis();
|
||||
bool toggleTick = false;
|
||||
|
|
@ -1300,16 +1319,19 @@ void handleArcAlarmFlash() {
|
|||
|
||||
if (fullScreenCell >= 0 && fullScreenCell < 4) {
|
||||
uint8_t cell = fullScreenCell;
|
||||
if (!cellIsNumeric[cell] && last_valid_data[cell] != -999) {
|
||||
if (last_valid_data[cell] != -999) {
|
||||
uint8_t pidIdx = pidInCell[cell];
|
||||
int warn = warningValue[pidIdx].toInt();
|
||||
float data = last_valid_data[cell];
|
||||
uint16_t col = getMeterColor(pidIdx, data, warn);
|
||||
bool inRed = (col == TFT_RED);
|
||||
bool digit = pidConfig[pidIdx][7].toInt();
|
||||
String numStr = String(data, digit);
|
||||
|
||||
if (wasInRedAlarm[cell] && !inRed) {
|
||||
// Exited red alarm: restore steady arc
|
||||
// Exited red alarm: restore steady arc and text
|
||||
wasInRedAlarm[cell] = false;
|
||||
if (!cellIsNumeric[cell]) {
|
||||
int min = pidConfig[pidIdx][4].toInt();
|
||||
int max = pidConfig[pidIdx][5].toInt();
|
||||
int newBlocks = calcMeterBlocks(data, min, max);
|
||||
|
|
@ -1319,9 +1341,25 @@ void handleArcAlarmFlash() {
|
|||
for (uint8_t i = newBlocks; i < NUM_BAR_BLOCKS; i++) {
|
||||
drawBarBlock(i, TFT_DARKGREY);
|
||||
}
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextPadding(240);
|
||||
tft.drawRightString(numStr.c_str(), 312, 148, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
} else {
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextPadding(295);
|
||||
tft.drawRightString(numStr.c_str(), 295, 98, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
}
|
||||
} else if (inRed) {
|
||||
wasInRedAlarm[cell] = true;
|
||||
if (toggleTick) {
|
||||
uint16_t txtCol = arcFlashVisible ? TFT_RED : TFT_BLACK;
|
||||
if (!cellIsNumeric[cell]) {
|
||||
int min = pidConfig[pidIdx][4].toInt();
|
||||
int max = pidConfig[pidIdx][5].toInt();
|
||||
int newBlocks = calcMeterBlocks(data, min, max);
|
||||
|
|
@ -1338,22 +1376,41 @@ void handleArcAlarmFlash() {
|
|||
drawBarBlock(i, TFT_BLACK);
|
||||
}
|
||||
}
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(240);
|
||||
tft.drawRightString(numStr.c_str(), 312, 148, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
} else {
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(295);
|
||||
tft.drawRightString(numStr.c_str(), 295, 98, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 4 quadrants mode
|
||||
for (uint8_t cell = 0; cell < 4; cell++) {
|
||||
if (!cellIsNumeric[cell] && last_valid_data[cell] != -999) {
|
||||
if (last_valid_data[cell] != -999) {
|
||||
uint8_t pidIdx = pidInCell[cell];
|
||||
int warn = warningValue[pidIdx].toInt();
|
||||
float data = last_valid_data[cell];
|
||||
uint16_t col = getMeterColor(pidIdx, data, warn);
|
||||
bool inRed = (col == TFT_RED);
|
||||
bool digit = pidConfig[pidIdx][7].toInt();
|
||||
String numStr = String(data, digit);
|
||||
int x = cell4_x[cell];
|
||||
int y = cell4_y[cell];
|
||||
|
||||
if (wasInRedAlarm[cell] && !inRed) {
|
||||
// Exited red alarm: restore steady arc
|
||||
// Exited red alarm: restore steady arc and text
|
||||
wasInRedAlarm[cell] = false;
|
||||
if (!cellIsNumeric[cell]) {
|
||||
int min = pidConfig[pidIdx][4].toInt();
|
||||
int max = pidConfig[pidIdx][5].toInt();
|
||||
int newBlocks = calcMeterBlocks(data, min, max);
|
||||
|
|
@ -1363,9 +1420,25 @@ void handleArcAlarmFlash() {
|
|||
for (uint8_t i = newBlocks; i < NUM_BAR_BLOCKS; i++) {
|
||||
drawQuadBarBlock(cell, i, TFT_DARKGREY);
|
||||
}
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_34);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextPadding(114);
|
||||
tft.drawRightString(numStr.c_str(), x + 152, y + 74, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
} else {
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_44);
|
||||
tft.setTextColor(col, TFT_BLACK);
|
||||
tft.setTextPadding(160 - 12);
|
||||
tft.drawRightString(numStr.c_str(), x + 160 - 10, y + 46, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
}
|
||||
} else if (inRed) {
|
||||
wasInRedAlarm[cell] = true;
|
||||
if (toggleTick) {
|
||||
uint16_t txtCol = arcFlashVisible ? TFT_RED : TFT_BLACK;
|
||||
if (!cellIsNumeric[cell]) {
|
||||
int min = pidConfig[pidIdx][4].toInt();
|
||||
int max = pidConfig[pidIdx][5].toInt();
|
||||
int newBlocks = calcMeterBlocks(data, min, max);
|
||||
|
|
@ -1382,6 +1455,20 @@ void handleArcAlarmFlash() {
|
|||
drawQuadBarBlock(cell, i, TFT_BLACK);
|
||||
}
|
||||
}
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_34);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(114);
|
||||
tft.drawRightString(numStr.c_str(), x + 152, y + 74, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
} else {
|
||||
tft.loadFont(DSEG7_Modern_BoldItalic_44);
|
||||
tft.setTextColor(txtCol, TFT_BLACK);
|
||||
tft.setTextPadding(160 - 12);
|
||||
tft.drawRightString(numStr.c_str(), x + 160 - 10, y + 46, 1);
|
||||
tft.setTextPadding(0);
|
||||
tft.unloadFont();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue