Affiche toutes les infos OLED sur un seul ecran au lieu de 3 pages tournantes
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01StKu9rqrsdz8CAVt1XMxon
This commit is contained in:
@ -10,12 +10,8 @@ namespace OledUi {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t REFRESH_PERIOD_MS = 500;
|
const uint32_t REFRESH_PERIOD_MS = 500;
|
||||||
const uint32_t PAGE_PERIOD_MS = 3000;
|
|
||||||
|
|
||||||
uint32_t g_lastRefreshMs = 0;
|
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) {
|
void drawLine(uint8_t y, const char *text) {
|
||||||
char padded[33];
|
char padded[33];
|
||||||
@ -23,39 +19,24 @@ void drawLine(uint8_t y, const char *text) {
|
|||||||
er_oled_string(0, y, padded, 0);
|
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];
|
char l0[33], l1[33], l2[33], l3[33];
|
||||||
snprintf(l0, sizeof(l0), "TMS320: %s", linkOk ? "OK" : "PERDU");
|
const CommandState &cmd = TmsLink::command();
|
||||||
snprintf(l1, sizeof(l1), "Vin=%.1fV Iin=%.2fA", t.vin, t.iin);
|
snprintf(l0, sizeof(l0), "TMS:%s HT:%s P1:%s P2:%s", linkOk ? "OK" : "KO",
|
||||||
snprintf(l2, sizeof(l2), "Iout=%.2fA", t.iout);
|
cmd.ht ? "ON" : "OFF", cmd.pwm1 ? "ON" : "OFF", cmd.pwm2 ? "ON" : "OFF");
|
||||||
snprintf(l3, sizeof(l3), "HT:%s PWM1:%s PWM2:%s", TmsLink::command().ht ? "ON " : "OFF",
|
snprintf(l1, sizeof(l1), "Vin=%.0fV Iin=%.2fA Iout=%.2fA", t.vin, t.iin, t.iout);
|
||||||
TmsLink::command().pwm1 ? "ON " : "OFF", TmsLink::command().pwm2 ? "ON " : "OFF");
|
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(0, l0);
|
||||||
drawLine(16, l1);
|
drawLine(16, l1);
|
||||||
drawLine(32, l2);
|
drawLine(32, l2);
|
||||||
drawLine(48, l3);
|
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
|
} // namespace
|
||||||
|
|
||||||
void begin() {
|
void begin() {
|
||||||
@ -65,20 +46,10 @@ void begin() {
|
|||||||
|
|
||||||
void update(const Telemetry &t, bool linkOk) {
|
void update(const Telemetry &t, bool linkOk) {
|
||||||
uint32_t now = millis();
|
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;
|
if (now - g_lastRefreshMs < REFRESH_PERIOD_MS) return;
|
||||||
g_lastRefreshMs = now;
|
g_lastRefreshMs = now;
|
||||||
|
|
||||||
switch (g_page) {
|
drawDashboard(t, linkOk);
|
||||||
case 0: drawEntreeCommandes(t, linkOk); break;
|
|
||||||
case 1: drawEtage1(t); break;
|
|
||||||
case 2: drawEtage2(t); break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OledUi
|
} // namespace OledUi
|
||||||
|
|||||||
Reference in New Issue
Block a user