/** * TEST SKETCH 4.3 – DisplayManager Verifikation * * Testet alle Methoden des DisplayManagers: * 1. Alle LEDs EIN/AUS (Modul-Check) * 2. showLaserTime() mit verschiedenen Werten (Grenzwerttest) * 3. showCountdown() hochzählend * 4. showIdle() * 5. showStatus() mit "Err", "AP", "WiFi" * 6. Realistischer Loop: laufende Laserzeit + Countdown simuliert * * Flash: pio run -e test-display-mgr --target upload * Monitor: pio device monitor -e test-display-mgr */ #include #include "display_manager.h" // Pause zwischen Testschritten #define STEP_MS 2000 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"); Serial.println("========================================"); display.begin(); display.printToSerial(); // ------------------------------------------------------------------ // 1. Alle LEDs EIN → alle 8 Module müssen leuchten // ------------------------------------------------------------------ Serial.println("\n[1] Alle LEDs EIN (2s) – alle 8 Module pruefen"); display.allLedsOn(); delay(2000); display.allLedsOff(); delay(500); // ------------------------------------------------------------------ // 2. showLaserTime() – Grenzwerttests // ------------------------------------------------------------------ Serial.println("\n[2] showLaserTime() Grenzwerte:"); float testTimes[] = { 0.0f, 0.5f, 1.0f, 9.9f, 10.0f, 42.5f, 99.9f, 100.0f, 123.0f, 999.0f, 1000.0f, 9999.0f }; for (float t : testTimes) { Serial.printf(" %.1f min → oben\n", t); display.showLaserTime(t); delay(1500); } display.clear(); delay(500); // ------------------------------------------------------------------ // 3. showCountdown() von 120 → 0 (jede Sekunde) // ------------------------------------------------------------------ Serial.println("\n[3] showCountdown() 5..0:"); for (int s = 5; s >= 0; s--) { Serial.printf(" %d s\n", s); display.showCountdown(s); delay(1000); } delay(500); // ------------------------------------------------------------------ // 4. showIdle() // ------------------------------------------------------------------ Serial.println("\n[4] showIdle() (2s)"); display.showIdle(); step("Erwarte ' --' auf unterer Reihe"); // ------------------------------------------------------------------ // 5. showStatus() mit verschiedenen Strings // ------------------------------------------------------------------ Serial.println("\n[5] showStatus() Tests:"); const char* statMsgs[] = { "Err ", "AP ", "WiFi", " oF" }; for (const char* m : statMsgs) { Serial.printf(" '%s'\n", m); display.showStatus(m); delay(STEP_MS); } display.clear(); delay(500); // ------------------------------------------------------------------ // 6. Realistischer Betrieb: Laserzeit wächst, Countdown läuft // ------------------------------------------------------------------ Serial.println("\n[6] Realistischer Betrieb (30s): Laserzeit + Countdown"); Serial.println(" Erwarte: oben steigt, unten zaehlt runter, dann '--'"); } // --------------------------------------------------------------------------- void loop() { static float totalMin = 42.3f; static int countdown = 20; static bool counting = true; static uint32_t lastSec = 0; static uint32_t lastTenth = 0; uint32_t now = millis(); // Jede 100ms: Laserzeit um ~0.001 min erhöhen (0.06 min/min = 1x Normal) if (now - lastTenth >= 100) { lastTenth = now; totalMin += 0.001f; display.showLaserTime(totalMin); } // Jede Sekunde: Countdown herunterzählen 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] %.2f min, countdown=%d\n", totalMin, countdown); } }