switch and display cleaning

This commit is contained in:
richonguzman 2024-06-05 23:20:34 -04:00
parent 01cee5d51e
commit 18de124c04
2 changed files with 18 additions and 47 deletions

View file

@ -122,13 +122,10 @@ namespace BME_Utils {
switch (strTemp.length()) {
case 1:
return "00" + strTemp;
break;
case 2:
return "0" + strTemp;
break;
case 3:
return strTemp;
break;
default:
return "-999";
}
@ -140,17 +137,14 @@ namespace BME_Utils {
switch (strHum.length()) {
case 1:
return "0" + strHum;
break;
case 2:
return strHum;
break;
case 3:
if ((int)bmeHum == 100) {
return "00";
} else {
return "-99";
}
break;
default:
return "-99";
}
@ -162,19 +156,14 @@ namespace BME_Utils {
switch (strPress.length()) {
case 1:
return "000" + strPress + decPress;
break;
case 2:
return "00" + strPress + decPress;
break;
case 3:
return "0" + strPress + decPress;
break;
case 4:
return strPress + decPress;
break;
case 5:
return strPress;
break;
default:
return "-99999";
}

View file

@ -123,6 +123,7 @@ bool shouldCleanTFT(const String& header, const String& line1, const String& lin
void show_display(const String& header, const String& line1, const String& line2, const String& line3, int wait) {
#ifdef HAS_DISPLAY
const String* const lines[] = {&line1, &line2, &line3};
#ifdef HAS_TFT
if (shouldCleanTFT(header, line1, line2, line3)) {
cleanTFT();
@ -132,24 +133,20 @@ void show_display(const String& header, const String& line1, const String& line2
tft.setCursor(0, 0);
tft.print(header);
tft.setTextSize(smallSizeFont);
tft.setCursor(0, ((lineSpacing * 2) - 2));
tft.print(line1);
tft.setCursor(0, ((lineSpacing * 3) - 2));
tft.print(line2);
tft.setCursor(0, ((lineSpacing * 4) - 2));
tft.print(line3);
for (int i = 0; i < 3; i++) {
tft.setCursor(0, ((lineSpacing * (2 + i)) - 2));
tft.print(*lines[i]);
}
#else
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println(header);
display.setCursor(0, 8);
display.println(line1);
display.setCursor(0, 16);
display.println(line2);
display.setCursor(0, 24);
display.println(line3);
for (int i = 0; i < 3; i++) {
display.setCursor(0, 8 + (8 * i));
display.println(*lines[i]);
}
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();
@ -160,6 +157,7 @@ void show_display(const String& header, const String& line1, const String& line2
void show_display(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6, int wait) {
#ifdef HAS_DISPLAY
const String* const lines[] = {&line1, &line2, &line3, &line4, &line5, &line6};
#ifdef HAS_TFT
if (shouldCleanTFT(header, line1, line2, line3, line4, line5, line6)) {
cleanTFT();
@ -169,18 +167,10 @@ void show_display(const String& header, const String& line1, const String& line2
tft.setCursor(0, 0);
tft.print(header);
tft.setTextSize(smallSizeFont);
tft.setCursor(0, ((lineSpacing * 2) - 2));
tft.print(line1);
tft.setCursor(0, ((lineSpacing * 3) - 2));
tft.print(line2);
tft.setCursor(0, ((lineSpacing * 4) - 2));
tft.print(line3);
tft.setCursor(0, ((lineSpacing * 5) - 2));
tft.print(line4);
tft.setCursor(0, ((lineSpacing * 6) - 2));
tft.print(line5);
tft.setCursor(0, ((lineSpacing * 7) - 2));
tft.print(line6);
for (int i = 0; i < 6; i++) {
tft.setCursor(0, ((lineSpacing * (2 + i)) - 2));
tft.print(*lines[i]);
}
#else
display.clearDisplay();
display.setTextColor(WHITE);
@ -188,18 +178,10 @@ void show_display(const String& header, const String& line1, const String& line2
display.setCursor(0, 0);
display.println(header);
display.setTextSize(1);
display.setCursor(0, 16);
display.println(line1);
display.setCursor(0, 24);
display.println(line2);
display.setCursor(0, 32);
display.println(line3);
display.setCursor(0, 40);
display.println(line4);
display.setCursor(0, 48);
display.println(line5);
display.setCursor(0, 56);
display.println(line6);
for (int i = 0; i < 6; i++) {
display.setCursor(0, 16 + (8 * i));
display.println(*lines[i]);
}
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();