From 4be97eca96cbf6d1bd729c1bdacadc0c84085c67 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Wed, 12 Jun 2024 09:55:36 +1000 Subject: [PATCH] fix(bw212): main view sliders, omitted sensor count display (#5154) --- radio/src/gui/212x64/model_telemetry.cpp | 23 +++++++++++++++++++++-- radio/src/gui/212x64/view_main.cpp | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/212x64/model_telemetry.cpp b/radio/src/gui/212x64/model_telemetry.cpp index f1d7bfe3b..18f676947 100644 --- a/radio/src/gui/212x64/model_telemetry.cpp +++ b/radio/src/gui/212x64/model_telemetry.cpp @@ -110,6 +110,18 @@ void onDeleteAllSensorsConfirm(const char * result) } } +uint8_t getTelemetrySensorCount() +{ + uint8_t count = 0; + + for (uint8_t index = 0; index <= MAX_TELEMETRY_SENSORS; index++) { + if (isTelemetryFieldAvailable(index)) { + count++; + } + } + return count; +} + void menuModelTelemetry(event_t event) { MENU(STR_MENUTELEMETRY, menuTabModel, MENU_MODEL_TELEMETRY, HEADER_LINE+ITEM_TELEMETRY_MAX, { HEADER_LINE_COLUMNS SENSORS_ROWS RSSI_ROWS VARIO_ROWS }); @@ -171,15 +183,22 @@ void menuModelTelemetry(event_t event) switch (k) { case ITEM_TELEMETRY_SENSORS_LABEL: + { telemExpandState.sensors = expandableSection(y, STR_TELEMETRY_SENSORS, telemExpandState.sensors, attr, event); - if (telemExpandState.sensors) { + uint8_t sensorCount = getTelemetrySensorCount(); + if (sensorCount && !telemExpandState.sensors) { + lcdDrawChar(TELEM_COL3, y, '(', 0); + lcdDrawNumber(lcdNextPos, y, sensorCount, 0); + lcdDrawChar(lcdNextPos, y, ')', 0); + } else if (telemExpandState.sensors) { lcdDrawText(TELEM_COL2, y, STR_VALUE, 0); if (!g_model.ignoreSensorIds /*&& !IS_SPEKTRUM_PROTOCOL()*/) { lcdDrawText(TELEM_COL3, y, STR_ID, 0); } } break; - + } + case ITEM_TELEMETRY_DISCOVER_SENSORS: lcdDrawText(INDENT_WIDTH, y, allowNewSensors ? STR_STOP_DISCOVER_SENSORS : STR_DISCOVER_SENSORS, attr); if (attr && event==EVT_KEY_BREAK(KEY_ENTER)) { diff --git a/radio/src/gui/212x64/view_main.cpp b/radio/src/gui/212x64/view_main.cpp index 1b3087f08..dc70467eb 100644 --- a/radio/src/gui/212x64/view_main.cpp +++ b/radio/src/gui/212x64/view_main.cpp @@ -214,7 +214,7 @@ void drawSliders() if (!IS_SLIDER(i)) continue; #else // Skip POT3 - if (i == 2) continue; + if (i == 2 && !IS_SLIDER(i)) continue; #endif coord_t x = _pot_slots[slot_idx++];