/** * 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. showSessionRing() 0/30/60 s: Module 5-7 * 7. showIdle() * 8. showStatus() mit 3-Zeichen-Strings * 9. Kombinations-Test: WiFi+MQTT Fehler gleichzeitig mit Laserzeit+Countdown * 10. Realistischer Loop * * Flash: pio run -e test-display-mgr --target upload * Monitor: pio device monitor -e test-display-mgr */ #include #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. showSessionRing() - Module 5-7 // ------------------------------------------------------------------ Serial.println("\n[6] showSessionRing() Tests (Module 5-7):"); Serial.println(" 1 s (1 LED, Anfang)"); display.showSessionRing(1); delay(STEP_MS); Serial.println(" 30 s (halber Ring)"); display.showSessionRing(30); delay(STEP_MS); Serial.println(" 60 s (voller Ring, Minuten\u00fcbergang)"); display.showSessionRing(60); delay(STEP_MS); display.clear(); delay(300); // ------------------------------------------------------------------ // 7. showIdle() - Module 5-7 // ------------------------------------------------------------------ Serial.println("\n[7] showIdle() (Module 5-7)"); display.showIdle(); step("Erwarte: Module 5-7 = ' --', Modul 4 leer"); // ------------------------------------------------------------------ // 8. showStatus() mit 3-Zeichen-Strings // ------------------------------------------------------------------ Serial.println("\n[8] 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); // ------------------------------------------------------------------ // 9. Kombinations-Test: WiFi+MQTT Fehler + Laserzeit + Countdown // ------------------------------------------------------------------ Serial.println("\n[9] 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); // ------------------------------------------------------------------ // 10. Realistischer Betrieb // ------------------------------------------------------------------ Serial.println("\n[10] 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 int ringSec = 0; 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 if (now - lastSec >= 1000) { lastSec = now; if (counting && countdown > 0) { // Phase 1: Countdown herunterzaehlen display.showCountdown(countdown); Serial.printf("[LIVE] Countdown: %d s\n", countdown); countdown--; } else if (counting && countdown == 0) { // Phase 2: Ring-Modus starten counting = false; ringSec = 0; display.showSessionRing(ringSec); Serial.println("[LIVE] Countdown abgelaufen -> SessionRing startet"); } else { // Phase 2: Ring jede Sekunde um eine LED weiter ringSec++; display.showSessionRing(ringSec % 60); Serial.printf("[LIVE] SessionRing: %d s (%d/60)\n", ringSec, ringSec % 60); } } }