New module assignment: Module 0 : WiFi error indicator (showWifiError) - 'W' / blank Module 1-3 : laser time in full minutes, 3-digit right-aligned Module 4 : MQTT error indicator (showMqttError) - 'M' / blank Module 5-7 : countdown seconds / idle / status, 3-digit right-aligned Changes in display_manager.h: - Update zone layout comments - showLaserTime: integer minutes only, writes modules 1-3 (module 0 untouched) - showCountdown: writes modules 5-7 only (module 4 untouched) - showIdle: ' --' on modules 5-7 - showStatus: 3-char string on modules 5-7 - Add showWifiError(bool): module 0 - Add showMqttError(bool): module 4 Changes in display_manager.cpp: - Add BMP_M character bitmap - Add 'M' case in charBitmap() - Rewrite showLaserTime() - round to int, 3 chars, modules 1-3 - Rewrite showCountdown() - 3 chars, modules 5-7 - Rewrite showIdle() - ' --' on modules 5-7 - Rewrite showStatus() - 3 chars, modules 5-7 - Add showWifiError() / showMqttError() implementations - Update printToSerial() log output Changes in test_sketch: - 9 test steps covering all new methods incl. combination test - Tested on hardware: all steps passed
183 lines
6.5 KiB
C++
183 lines
6.5 KiB
C++
/**
|
|
* TEST SKETCH 4.3 - DisplayManager Verifikation (angepasstes Layout)
|
|
*
|
|
* Modul-Aufteilung:
|
|
* Modul 0 : WiFi-Fehler-Indikator (showWifiError)
|
|
* Module 1-3 : Laserzeit in ganzen Minuten, 3-stellig rechtsbuendig
|
|
* Modul 4 : MQTT-Fehler-Indikator (showMqttError)
|
|
* Module 5-7 : Countdown-Sekunden / Idle / Status, 3-stellig rechtsbuendig
|
|
*
|
|
* Testet:
|
|
* 1. Alle LEDs EIN/AUS (Modul-Check)
|
|
* 2. WiFi-Fehler EIN/AUS (Modul 0)
|
|
* 3. MQTT-Fehler EIN/AUS (Modul 4)
|
|
* 4. showLaserTime() Grenzwerte: ganze Minuten, Module 1-3
|
|
* 5. showCountdown() Grenzwerte: Module 5-7
|
|
* 6. showIdle()
|
|
* 7. showStatus() mit 3-Zeichen-Strings
|
|
* 8. Kombinations-Test: WiFi+MQTT Fehler gleichzeitig mit Laserzeit+Countdown
|
|
* 9. Realistischer Loop
|
|
*
|
|
* Flash: pio run -e test-display-mgr --target upload
|
|
* Monitor: pio device monitor -e test-display-mgr
|
|
*/
|
|
|
|
#include <Arduino.h>
|
|
#include "display_manager.h"
|
|
|
|
#define STEP_MS 1500
|
|
|
|
static void step(const char* desc) {
|
|
Serial.printf("[STEP] %s\n", desc);
|
|
delay(STEP_MS);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(500);
|
|
|
|
Serial.println("\n========================================");
|
|
Serial.println(" TEST 4.3 - DisplayManager (neues Layout)");
|
|
Serial.println("========================================");
|
|
|
|
display.begin();
|
|
display.printToSerial();
|
|
|
|
// ------------------------------------------------------------------
|
|
// 1. Alle LEDs EIN -> alle 8 Module muessen leuchten
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[1] Alle LEDs EIN (2s) - alle 8 Module pruefen");
|
|
display.allLedsOn();
|
|
delay(2000);
|
|
display.allLedsOff();
|
|
delay(500);
|
|
|
|
// ------------------------------------------------------------------
|
|
// 2. WiFi-Fehler Modul 0
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[2] WiFi-Fehler Modul 0:");
|
|
Serial.println(" EIN: Modul 0 zeigt 'W'");
|
|
display.showWifiError(true);
|
|
step("Erwarte: Modul 0 = 'W', Rest leer");
|
|
Serial.println(" AUS: Modul 0 leer");
|
|
display.showWifiError(false);
|
|
step("Erwarte: Modul 0 = leer");
|
|
|
|
// ------------------------------------------------------------------
|
|
// 3. MQTT-Fehler Modul 4
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[3] MQTT-Fehler Modul 4:");
|
|
Serial.println(" EIN: Modul 4 zeigt 'M'");
|
|
display.showMqttError(true);
|
|
step("Erwarte: Modul 4 = 'M', Rest leer");
|
|
Serial.println(" AUS: Modul 4 leer");
|
|
display.showMqttError(false);
|
|
step("Erwarte: Modul 4 = leer");
|
|
|
|
// ------------------------------------------------------------------
|
|
// 4. showLaserTime() - ganze Minuten, Module 1-3
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[4] showLaserTime() Grenzwerte (Module 1-3, ganze Minuten):");
|
|
int testMins[] = { 0, 1, 9, 10, 42, 99, 100, 123, 999 };
|
|
for (int m : testMins) {
|
|
Serial.printf(" %d min\n", m);
|
|
display.showLaserTime((float)m);
|
|
delay(1200);
|
|
}
|
|
display.clear();
|
|
delay(300);
|
|
|
|
// ------------------------------------------------------------------
|
|
// 5. showCountdown() - Module 5-7
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[5] showCountdown() 9..0 (Module 5-7):");
|
|
for (int s = 9; s >= 0; s--) {
|
|
Serial.printf(" %d s\n", s);
|
|
display.showCountdown(s);
|
|
delay(700);
|
|
}
|
|
Serial.println(" 120 s");
|
|
display.showCountdown(120);
|
|
delay(STEP_MS);
|
|
display.clear();
|
|
delay(300);
|
|
|
|
// ------------------------------------------------------------------
|
|
// 6. showIdle() - Module 5-7
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[6] showIdle() (Module 5-7)");
|
|
display.showIdle();
|
|
step("Erwarte: Module 5-7 = ' --', Modul 4 leer");
|
|
|
|
// ------------------------------------------------------------------
|
|
// 7. showStatus() mit 3-Zeichen-Strings
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[7] showStatus() Tests (Module 5-7):");
|
|
const char* msgs[] = { "Err", "AP ", "oFF", " " };
|
|
for (const char* m : msgs) {
|
|
Serial.printf(" '%s'\n", m);
|
|
display.showStatus(m);
|
|
delay(STEP_MS);
|
|
}
|
|
display.clear();
|
|
delay(300);
|
|
|
|
// ------------------------------------------------------------------
|
|
// 8. Kombinations-Test: WiFi+MQTT Fehler + Laserzeit + Countdown
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[8] Kombinations-Test:");
|
|
Serial.println(" Modul 0='W', 1-3=042, Modul 4='M', 5-7= 20");
|
|
display.showWifiError(true);
|
|
display.showLaserTime(42.0f);
|
|
display.showMqttError(true);
|
|
display.showCountdown(20);
|
|
step("Erwarte: W | 042 | M | 20");
|
|
|
|
Serial.println(" Fehler weg: Modul 0 und 4 leer");
|
|
display.showWifiError(false);
|
|
display.showMqttError(false);
|
|
step("Erwarte: leer | 042 | leer | 20");
|
|
|
|
display.clear();
|
|
delay(300);
|
|
|
|
// ------------------------------------------------------------------
|
|
// 9. Realistischer Betrieb
|
|
// ------------------------------------------------------------------
|
|
Serial.println("\n[9] Realistischer Betrieb: Laserzeit steigt, Countdown->Idle");
|
|
display.showWifiError(false);
|
|
display.showMqttError(false);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
void loop() {
|
|
static float totalMin = 42.0f;
|
|
static int countdown = 20;
|
|
static bool counting = true;
|
|
static uint32_t lastSec = 0;
|
|
static uint32_t lastTenth = 0;
|
|
|
|
uint32_t now = millis();
|
|
|
|
// Alle 100ms: Laserzeit um ~0.001 min erhoehen
|
|
if (now - lastTenth >= 100) {
|
|
lastTenth = now;
|
|
totalMin += 0.001f;
|
|
display.showLaserTime(totalMin);
|
|
}
|
|
|
|
// Jede Sekunde: Countdown herunterzaehlen
|
|
if (now - lastSec >= 1000) {
|
|
lastSec = now;
|
|
if (counting && countdown > 0) {
|
|
display.showCountdown(countdown);
|
|
countdown--;
|
|
} else if (counting && countdown == 0) {
|
|
counting = false;
|
|
display.showIdle();
|
|
Serial.println("[LIVE] Countdown abgelaufen -> Idle");
|
|
}
|
|
Serial.printf("[LIVE] %d min, countdown=%d\n", (int)(totalMin + 0.5f), countdown);
|
|
}
|
|
} |