From c3e8169085625b5b33de77c1560623d91272c081 Mon Sep 17 00:00:00 2001 From: philmoz Date: Tue, 14 Jan 2025 18:44:14 +1100 Subject: [PATCH] Display PPM value in channel monitor on 128x64 B&W radios. --- radio/src/gui/128x64/view_channels.cpp | 32 ++++++++------------------ 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/radio/src/gui/128x64/view_channels.cpp b/radio/src/gui/128x64/view_channels.cpp index 39bd926f217..fe2f5c1965a 100644 --- a/radio/src/gui/128x64/view_channels.cpp +++ b/radio/src/gui/128x64/view_channels.cpp @@ -21,7 +21,7 @@ #include "edgetx.h" -constexpr coord_t CHANNEL_NAME_OFFSET = 1; +constexpr coord_t CHANNEL_NAME_OFFSET = 0; constexpr coord_t CHANNEL_VALUE_OFFSET = CHANNEL_NAME_OFFSET + 42; constexpr coord_t CHANNEL_GAUGE_OFFSET = CHANNEL_VALUE_OFFSET; constexpr coord_t CHANNEL_BAR_WIDTH = 70; @@ -54,29 +54,22 @@ constexpr coord_t CHANNEL_PROPERTIES_OFFSET = CHANNEL_GAUGE_OFFSET + CHANNEL_BAR #define EVT_KEY_PREVIOUS_PAGE EVT_KEY_BREAK(KEY_LEFT) #endif -struct ViewChannelsState { - bool longNames; - bool mixersView; -}; - -static ViewChannelsState viewChannels = { false, false }; +static bool mixersView = false; void menuChannelsViewCommon(event_t event) { - bool newLongNames = false; - uint8_t ch; switch (event) { case EVT_KEY_BREAK(KEY_ENTER): - viewChannels.mixersView = !viewChannels.mixersView; + mixersView = !mixersView; break; } ch = 8 * (g_eeGeneral.view / ALTERNATE_VIEW); // Screen title - lcdDrawText(LCD_W / 2, 0, viewChannels.mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED); + lcdDrawText(LCD_W / 2, 0, mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED); lcdInvertLine(0); int16_t limits = 512 * 2; @@ -85,32 +78,29 @@ void menuChannelsViewCommon(event_t event) for (uint8_t line = 0; line < 8; line++) { LimitData * ld = limitAddress(ch); const uint8_t y = 9 + line * 7; - const int32_t val = viewChannels.mixersView ? ex_chans[ch] : channelOutputs[ch]; + const int32_t val = mixersView ? ex_chans[ch] : channelOutputs[ch]; const uint8_t lenLabel = ZLEN(g_model.limitData[ch].name); // Channel name if present, number if not if (lenLabel > 0) { - if (lenLabel > 4) - viewChannels.longNames = true; lcdDrawSizedText(CHANNEL_NAME_OFFSET, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), SMLSIZE); - } - else { + } else { putsChn(CHANNEL_NAME_OFFSET, y, ch + 1, SMLSIZE); } // Value - if (g_eeGeneral.ppmunit == PPM_US) { - lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT); - } else if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) { + if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) { lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, calcRESXto1000(val), PREC1 | TINSIZE | RIGHT); } else { lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, calcRESXto1000(val) / 10, TINSIZE | RIGHT); } + lcdDrawNumber(LCD_W + 1, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT); + // Gauge drawGauge(CHANNEL_GAUGE_OFFSET, y, CHANNEL_BAR_WIDTH, 6, val, limits); - if (!viewChannels.mixersView) { + if (!mixersView) { // Properties #if defined(OVERRIDE_CHANNEL_FUNCTION) if (safetyCh[ch] != OVERRIDE_CHANNEL_UNDEFINED) @@ -124,8 +114,6 @@ void menuChannelsViewCommon(event_t event) ++ch; } - - viewChannels.longNames = newLongNames; } void menuChannelsView(event_t event)