Skip to content

Commit ca87e23

Browse files
committed
v5.9 Calibration result
1 parent bad6dc6 commit ca87e23

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

OpenCO2_Sensor.ino

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- WiFiManager: https://github.com/tzapu/WiFiManager
1111
- ArduinoMqttClient (if MQTT is defined)
1212
*/
13-
#define VERSION "v5.8"
13+
#define VERSION "v5.9"
1414

1515
#define HEIGHT_ABOVE_SEA_LEVEL 50 // Berlin
1616
#define TZ_DATA "CET-1CEST,M3.5.0,M10.5.0/3" // Europe/Berlin time zone from https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv
@@ -605,7 +605,13 @@ void calibrate() {
605605
delay(500);
606606
uint16_t frcCorrection;
607607
scd4x.performForcedRecalibration((uint16_t)420, frcCorrection);
608-
delay(400);
608+
609+
if (frcCorrection == 65535) DisplayCalibrationFail();
610+
else {
611+
int correction = frcCorrection - 32768;
612+
DisplayCalibrationResult(correction);
613+
}
614+
while (digitalRead(BUTTON) != 0) delay(400); // wait for button press
609615
ESP.restart();
610616
}
611617

@@ -741,6 +747,7 @@ void startWiFi() {
741747
#endif /* MQTT */
742748

743749
#ifdef airgradient
750+
delay(100);
744751
server.on("/", HandleRootClient);
745752
server.on("/metrics", HandleRoot);
746753
server.on("/favicon.ico", handleFavicon);

epd_abstraction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ void displayBattery(uint8_t percentage);
124124
void updateDisplay();
125125
void displayImage(const unsigned char* image_buffer);
126126
void displayCalibrationWarning();
127+
void DisplayCalibrationFail();
128+
void DisplayCalibrationResult(int correction);
127129
void displayWiFi(bool useWiFi);
128130
void displayWiFiStrengh();
129131

epd_abstraction.ino

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,44 @@ void displayCalibrationWarning() {
10051005
updateDisplay();
10061006
}
10071007

1008+
void DisplayCalibrationFail() {
1009+
Paint_Clear(BLACK);
1010+
1011+
// Exclamation Mark !
1012+
Paint_DrawLine( 100, 50, 100, 85, WHITE, DOT_PIXEL_4X4, LINE_STYLE_SOLID);
1013+
Paint_DrawCircle(100, 105, 5, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
1014+
1015+
// Xstart,Ystart,Xend,Yend
1016+
Paint_DrawLine( 100, 20, 35, 120, WHITE, DOT_PIXEL_3X3, LINE_STYLE_SOLID);
1017+
Paint_DrawLine( 100, 20, 165, 120, WHITE, DOT_PIXEL_3X3, LINE_STYLE_SOLID);
1018+
Paint_DrawLine( 37, 120, 163, 120, WHITE, DOT_PIXEL_4X4, LINE_STYLE_SOLID);
1019+
1020+
if (english) {
1021+
Paint_DrawString_EN(6, 128, "Calibration", &Font24, BLACK, WHITE);
1022+
Paint_DrawString_EN(6, 152, "FAILED", &Font24, BLACK, WHITE);
1023+
} else {
1024+
Paint_DrawString_EN(6, 128, "Kalibration", &Font24, BLACK, WHITE);
1025+
Paint_DrawString_EN(6, 152, "FEHLGESCHLAGEN", &Font24, BLACK, WHITE);
1026+
}
1027+
1028+
updateDisplay();
1029+
}
1030+
1031+
void DisplayCalibrationResult(int correction) {
1032+
Paint_Clear(BLACK);
1033+
1034+
Paint_DrawString_EN(74, 100, "OK!", &Font24, BLACK, WHITE);
1035+
Paint_DrawString_EN(6, 152, "correction:", &Font24, BLACK, WHITE);
1036+
1037+
char acorrection[16];
1038+
if (correction < 0) {
1039+
snprintf(acorrection, sizeof(acorrection), "-%d ppm", -correction);
1040+
} else snprintf(acorrection, sizeof(acorrection), "%d ppm", correction);
1041+
Paint_DrawString_EN(0, 176, acorrection, &Font24, BLACK, WHITE);
1042+
1043+
updateDisplay();
1044+
}
1045+
10081046
void displayWiFi(bool useWiFi) {
10091047
Paint_Clear(BLACK);
10101048

0 commit comments

Comments
 (0)