From 58a0930f33a619c71be5b4d86a4981c6624e68d1 Mon Sep 17 00:00:00 2001 From: nicoboy Date: Sat, 1 Aug 2026 16:51:09 +0200 Subject: [PATCH] Affiche toutes les infos OLED sur un seul ecran au lieu de 3 pages tournantes Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01StKu9rqrsdz8CAVt1XMxon --- src/oled_ui.cpp | 53 +++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/src/oled_ui.cpp b/src/oled_ui.cpp index 5d6b107..541920d 100644 --- a/src/oled_ui.cpp +++ b/src/oled_ui.cpp @@ -10,12 +10,8 @@ namespace OledUi { namespace { const uint32_t REFRESH_PERIOD_MS = 500; -const uint32_t PAGE_PERIOD_MS = 3000; uint32_t g_lastRefreshMs = 0; -uint32_t g_lastPageChangeMs = 0; -uint8_t g_page = 0; -const uint8_t PAGE_COUNT = 3; void drawLine(uint8_t y, const char *text) { char padded[33]; @@ -23,39 +19,24 @@ void drawLine(uint8_t y, const char *text) { er_oled_string(0, y, padded, 0); } -void drawEntreeCommandes(const Telemetry &t, bool linkOk) { +// Tout sur un seul ecran (4 lignes de 32 caracteres) : statut liaison et +// commandes, electrique d'entree, puis un resume par etage. +void drawDashboard(const Telemetry &t, bool linkOk) { char l0[33], l1[33], l2[33], l3[33]; - snprintf(l0, sizeof(l0), "TMS320: %s", linkOk ? "OK" : "PERDU"); - snprintf(l1, sizeof(l1), "Vin=%.1fV Iin=%.2fA", t.vin, t.iin); - snprintf(l2, sizeof(l2), "Iout=%.2fA", t.iout); - snprintf(l3, sizeof(l3), "HT:%s PWM1:%s PWM2:%s", TmsLink::command().ht ? "ON " : "OFF", - TmsLink::command().pwm1 ? "ON " : "OFF", TmsLink::command().pwm2 ? "ON " : "OFF"); + const CommandState &cmd = TmsLink::command(); + snprintf(l0, sizeof(l0), "TMS:%s HT:%s P1:%s P2:%s", linkOk ? "OK" : "KO", + cmd.ht ? "ON" : "OFF", cmd.pwm1 ? "ON" : "OFF", cmd.pwm2 ? "ON" : "OFF"); + snprintf(l1, sizeof(l1), "Vin=%.0fV Iin=%.2fA Iout=%.2fA", t.vin, t.iin, t.iout); + snprintf(l2, sizeof(l2), "E1 F%.0fk D%.0f%% V%.0fV I%.2fA T%.0fC", t.freq1 / 1000.0f, + t.duty1, t.v1, t.i1, t.t1); + snprintf(l3, sizeof(l3), "E2 F%.0fk D%.0f%% V%.0fV I%.2fA T%.0fC", t.freq2 / 1000.0f, + t.duty2, t.vout, t.i2, t.t2); drawLine(0, l0); drawLine(16, l1); drawLine(32, l2); drawLine(48, l3); } -void drawEtage1(const Telemetry &t) { - char l1[33], l2[33]; - snprintf(l1, sizeof(l1), "F=%.0fHz D=%.1f%%", t.freq1, t.duty1); - snprintf(l2, sizeof(l2), "V=%.1fV I=%.2fA T=%.1fC", t.v1, t.i1, t.t1); - drawLine(0, "ETAGE 1"); - drawLine(16, l1); - drawLine(32, l2); - drawLine(48, ""); -} - -void drawEtage2(const Telemetry &t) { - char l1[33], l2[33]; - snprintf(l1, sizeof(l1), "F=%.0fHz D=%.1f%%", t.freq2, t.duty2); - snprintf(l2, sizeof(l2), "V=%.1fV I=%.2fA T=%.1fC", t.vout, t.i2, t.t2); - drawLine(0, "ETAGE 2"); - drawLine(16, l1); - drawLine(32, l2); - drawLine(48, ""); -} - } // namespace void begin() { @@ -65,20 +46,10 @@ void begin() { void update(const Telemetry &t, bool linkOk) { uint32_t now = millis(); - - if (now - g_lastPageChangeMs >= PAGE_PERIOD_MS) { - g_lastPageChangeMs = now; - g_page = (g_page + 1) % PAGE_COUNT; - } - if (now - g_lastRefreshMs < REFRESH_PERIOD_MS) return; g_lastRefreshMs = now; - switch (g_page) { - case 0: drawEntreeCommandes(t, linkOk); break; - case 1: drawEtage1(t); break; - case 2: drawEtage2(t); break; - } + drawDashboard(t, linkOk); } } // namespace OledUi