Skip to content

fix(color): outputs widget channel value may not update if units is set to μs #6343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions radio/src/gui/colorlcd/widgets/outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include "edgetx.h"
#include "widget.h"
#include <cstdint>

constexpr int16_t OUTPUT_INVALID_VALUE = INT16_MIN;

#define ETX_STATE_BG_FILL LV_STATE_USER_1

Expand Down Expand Up @@ -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<int16_t>(-lim, value, lim), lim * 2);

if (scaledValue != lastValue) {
lastValue = scaledValue;
if (value != lastValue) {
lastValue = value;

std::string s;
if (g_eeGeneral.ppmunit == PPM_US)
Expand All @@ -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());
}

const int lim = (g_model.extendedLimits ? (1024 * LIMIT_EXT_PERCENT / 100) : 1024);
uint16_t w = width() - PAD_TINY;
int16_t scaledValue = divRoundClosest(w * limit<int16_t>(-lim, value, lim), lim * 2);

if (scaledValue != lastScaledValue) {
lastScaledValue = scaledValue;

uint16_t fillW = abs(scaledValue);
uint16_t x = value > 0 ? w / 2 : w / 2 - fillW + 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);
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;
Expand All @@ -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;
Expand Down