fix(color): outputs widget channel value may not update if unit is set to μs (#6343)
This commit is contained in:
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
#include "edgetx.h"
|
#include "edgetx.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
constexpr int16_t OUTPUT_INVALID_VALUE = INT16_MIN;
|
||||||
|
|
||||||
#define ETX_STATE_BG_FILL LV_STATE_USER_1
|
#define ETX_STATE_BG_FILL LV_STATE_USER_1
|
||||||
|
|
||||||
@@ -99,12 +102,8 @@ class ChannelValue : public Window
|
|||||||
{
|
{
|
||||||
int16_t value = channelOutputs[channel];
|
int16_t value = channelOutputs[channel];
|
||||||
|
|
||||||
const int lim = (g_model.extendedLimits ? (1024 * LIMIT_EXT_PERCENT / 100) : 1024);
|
if (value != lastValue) {
|
||||||
uint16_t w = width() - PAD_TINY;
|
lastValue = value;
|
||||||
int16_t scaledValue = divRoundClosest(w * limit<int16_t>(-lim, value, lim), lim * 2);
|
|
||||||
|
|
||||||
if (scaledValue != lastValue) {
|
|
||||||
lastValue = scaledValue;
|
|
||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
if (g_eeGeneral.ppmunit == PPM_US)
|
if (g_eeGeneral.ppmunit == PPM_US)
|
||||||
@@ -114,13 +113,24 @@ class ChannelValue : public Window
|
|||||||
else
|
else
|
||||||
s = formatNumberAsString(calcRESXto100(value), 0, 0, "", "%");
|
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);
|
const int lim = (g_model.extendedLimits ? (1024 * LIMIT_EXT_PERCENT / 100) : 1024);
|
||||||
uint16_t x = value > 0 ? w / 2 : w / 2 - fillW + 1;
|
uint16_t w = width() - PAD_TINY;
|
||||||
|
int16_t scaledValue = divRoundClosest(w * limit<int16_t>(-lim, value, lim), lim * 2);
|
||||||
|
|
||||||
lv_obj_set_pos(bar, x, 0);
|
if (scaledValue != lastScaledValue) {
|
||||||
lv_obj_set_size(bar, fillW, ROW_HEIGHT - 1);
|
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;
|
bool hasName = g_model.limitData[channel].name[0] != 0;
|
||||||
@@ -134,7 +144,9 @@ class ChannelValue : public Window
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t channel;
|
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;
|
bool chanHasName = false;
|
||||||
lv_style_t style;
|
lv_style_t style;
|
||||||
lv_obj_t* valueLabel = nullptr;
|
lv_obj_t* valueLabel = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user