Skip to content

Commit 055c7e1

Browse files
committed
show info on display while updating via OTA; optimize display output
1 parent 8b80c75 commit 055c7e1

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/main.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ void setupDisplay()
300300
display.setTextSize(1);
301301
display.setCursor(0, 0);
302302
display.print(">> co2 meter <<");
303+
303304
display.display();
304305
}
305306

@@ -309,6 +310,8 @@ void setupOTA()
309310
.setHostname(WiFiSettings.hostname.c_str())
310311
.setPassword(WiFiSettings.password.c_str())
311312
.onStart([]() {
313+
isUpdating = true;
314+
312315
String type;
313316

314317
if (ArduinoOTA.getCommand() == U_FLASH)
@@ -323,7 +326,11 @@ void setupOTA()
323326
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
324327
Serial.println("Start updating " + type);
325328

326-
isUpdating = true;
329+
display.clearDisplay();
330+
display.setTextSize(2);
331+
display.print("updating...");
332+
333+
display.display();
327334
})
328335
.onEnd([]() {
329336
Serial.println("\nEnd");
@@ -332,6 +339,18 @@ void setupOTA()
332339
})
333340
.onProgress([](unsigned int progress, unsigned int total) {
334341
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
342+
343+
display.clearDisplay();
344+
345+
display.setCursor(0, 0);
346+
display.setTextSize(2);
347+
display.print("updating...");
348+
349+
display.setCursor(0, 40);
350+
display.print(progress);
351+
display.print("%");
352+
353+
display.display();
335354
})
336355
.onError([](ota_error_t error) {
337356
Serial.printf("Error[%u]: ", error);
@@ -496,21 +515,20 @@ void loop()
496515
Serial.println(lastCo2Value);
497516

498517
display.clearDisplay();
499-
display.setTextSize(1);
518+
display.setTextSize(2);
500519

501520
display.setCursor(0, 0);
502-
display.print("temp: ");
503-
display.print(lastTemperature);
504521

505522
display.setCursor(0, 10);
506-
display.print("co2: ");
523+
display.print("CO2: ");
507524
display.print(lastCo2Value);
525+
display.print(" ppm");
508526

509527
if (lastCo2Value >= CO2_WARN_PPM)
510528
{
511529
display.setCursor(0, 40);
512530
display.setTextSize(2);
513-
display.print("L Ü F T E N");
531+
display.print("VENTILATE");
514532
}
515533

516534
display.display();

0 commit comments

Comments
 (0)