From a76288ded530f9d2a5adeefd52e4fe0138c04ae4 Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 13 Jun 2025 11:58:00 +1000 Subject: [PATCH] =?UTF-8?q?fix(color):=20outputs=20widget=20channel=20valu?= =?UTF-8?q?e=20may=20not=20update=20if=20unit=20is=20set=20to=20=CE=BCs=20?= =?UTF-8?q?(#6343)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- radio/src/gui/colorlcd/widgets/outputs.cpp | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/radio/src/gui/colorlcd/widgets/outputs.cpp b/radio/src/gui/colorlcd/widgets/outputs.cpp index 5b70236f2..69668714c 100644 --- a/radio/src/gui/colorlcd/widgets/outputs.cpp +++ b/radio/src/gui/colorlcd/widgets/outputs.cpp @@ -21,6 +21,9 @@ #include "edgetx.h" #include "widget.h" +#include + +constexpr int16_t OUTPUT_INVALID_VALUE = INT16_MIN; #define ETX_STATE_BG_FILL LV_STATE_USER_1 @@ -99,12 +102,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 +113,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()); + } - uint16_t fillW = abs(scaledValue); - uint16_t x = value > 0 ? w / 2 : w / 2 - fillW + 1; + 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); - lv_obj_set_pos(bar, x, 0); - lv_obj_set_size(bar, fillW, ROW_HEIGHT - 1); + if (scaledValue != lastScaledValue) { + lastScaledValue = scaledValue; + + 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; @@ -134,7 +144,9 @@ class ChannelValue : public Window protected: uint8_t channel; - int16_t lastValue = -32768; + int16_t lastValue = OUTPUT_INVALID_VALUE; + int16_t lastScaledValue = OUTPUT_INVALID_VALUE; + std::string lastText; bool chanHasName = false; lv_style_t style; lv_obj_t* valueLabel = nullptr;