From 9a5b120691751c39061498ca073a5394ea4571e6 Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 6 Jun 2025 08:28:02 +1000 Subject: [PATCH 1/3] Ensure value label text is always updated. --- radio/src/gui/colorlcd/widgets/outputs.cpp | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/outputs.cpp b/radio/src/gui/colorlcd/widgets/outputs.cpp index 5b70236f28b..66e0fbf624e 100644 --- a/radio/src/gui/colorlcd/widgets/outputs.cpp +++ b/radio/src/gui/colorlcd/widgets/outputs.cpp @@ -99,12 +99,8 @@ class ChannelValue : public Window { int16_t value = channelOutputs[channel]; - const int lim = (g_model.extendedLimits ? (1024 * LIMIT_EXT_PERCENT / 100) : 1024); - uint16_t w = width() - PAD_TINY; - int16_t scaledValue = divRoundClosest(w * limit(-lim, value, lim), lim * 2); - - if (scaledValue != lastValue) { - lastValue = scaledValue; + if (value != lastValue) { + lastValue = value; std::string s; if (g_eeGeneral.ppmunit == PPM_US) @@ -114,13 +110,24 @@ class ChannelValue : public Window else s = formatNumberAsString(calcRESXto100(value), 0, 0, "", "%"); - lv_label_set_text(valueLabel, s.c_str()); + if (s != lastText) { + lastText = s; + lv_label_set_text(valueLabel, s.c_str()); + } + + const int lim = (g_model.extendedLimits ? (1024 * LIMIT_EXT_PERCENT / 100) : 1024); + uint16_t w = width() - PAD_TINY; + int16_t scaledValue = divRoundClosest(w * limit(-lim, value, lim), lim * 2); - uint16_t fillW = abs(scaledValue); - uint16_t x = value > 0 ? w / 2 : w / 2 - fillW + 1; + if (scaledValue != lastScaledValue) { + lastScaledValue = scaledValue; - lv_obj_set_pos(bar, x, 0); - lv_obj_set_size(bar, fillW, ROW_HEIGHT - 1); + uint16_t fillW = abs(scaledValue); + uint16_t x = value > 0 ? w / 2 : w / 2 - fillW + 1; + + lv_obj_set_pos(bar, x, 0); + lv_obj_set_size(bar, fillW, ROW_HEIGHT - 1); + } } bool hasName = g_model.limitData[channel].name[0] != 0; @@ -135,6 +142,8 @@ class ChannelValue : public Window protected: uint8_t channel; int16_t lastValue = -32768; + int16_t lastScaledValue = -32768; + std::string lastText; bool chanHasName = false; lv_style_t style; lv_obj_t* valueLabel = nullptr; From 650fef88218f049ab98f221e654451a34b7ab8fe Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Fri, 13 Jun 2025 01:01:05 +0000 Subject: [PATCH 2/3] chore: use constant rather than magic number --- radio/src/gui/colorlcd/widgets/outputs.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/outputs.cpp b/radio/src/gui/colorlcd/widgets/outputs.cpp index 66e0fbf624e..d77071da603 100644 --- a/radio/src/gui/colorlcd/widgets/outputs.cpp +++ b/radio/src/gui/colorlcd/widgets/outputs.cpp @@ -21,6 +21,10 @@ #include "edgetx.h" #include "widget.h" +#include +#include + +constexpr int16_t OUTPUT_INVALID_VALUE = std::numeric_limits::min(); #define ETX_STATE_BG_FILL LV_STATE_USER_1 @@ -141,8 +145,8 @@ class ChannelValue : public Window protected: uint8_t channel; - int16_t lastValue = -32768; - int16_t lastScaledValue = -32768; + int16_t lastValue = OUTPUT_INVALID_VALUE; + int16_t lastScaledValue = OUTPUT_INVALID_VALUE; std::string lastText; bool chanHasName = false; lv_style_t style; From 5784b92b274c5066574dcfed58c3af286d01e2d0 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Fri, 13 Jun 2025 01:28:28 +0000 Subject: [PATCH 3/3] chore: drop `numeric_limits` as not used elsewhere --- radio/src/gui/colorlcd/widgets/outputs.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/outputs.cpp b/radio/src/gui/colorlcd/widgets/outputs.cpp index d77071da603..69668714c73 100644 --- a/radio/src/gui/colorlcd/widgets/outputs.cpp +++ b/radio/src/gui/colorlcd/widgets/outputs.cpp @@ -22,9 +22,8 @@ #include "edgetx.h" #include "widget.h" #include -#include -constexpr int16_t OUTPUT_INVALID_VALUE = std::numeric_limits::min(); +constexpr int16_t OUTPUT_INVALID_VALUE = INT16_MIN; #define ETX_STATE_BG_FILL LV_STATE_USER_1