fix(color): remove unnecessary updates of channel bar (#5136)
This commit is contained in:
@@ -32,8 +32,8 @@
|
|||||||
ChannelBar::ChannelBar(Window* parent, const rect_t& rect, uint8_t channel,
|
ChannelBar::ChannelBar(Window* parent, const rect_t& rect, uint8_t channel,
|
||||||
std::function<int16_t()> getValueFunc, LcdColorIndex barColorIndex,
|
std::function<int16_t()> getValueFunc, LcdColorIndex barColorIndex,
|
||||||
LcdColorIndex txtColorIndex) :
|
LcdColorIndex txtColorIndex) :
|
||||||
Window(parent, rect), getValue(std::move(getValueFunc)),
|
Window(parent, rect), channel(channel),
|
||||||
channel(channel)
|
getValue(std::move(getValueFunc))
|
||||||
{
|
{
|
||||||
etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX);
|
etx_solid_bg(lvobj, COLOR_THEME_PRIMARY2_INDEX);
|
||||||
|
|
||||||
@@ -81,9 +81,11 @@ void ChannelBar::checkEvents()
|
|||||||
else
|
else
|
||||||
s = formatNumberAsString(calcRESXto100(value), 0, 0, "", "%");
|
s = formatNumberAsString(calcRESXto100(value), 0, 0, "", "%");
|
||||||
|
|
||||||
|
if (s != valStr) {
|
||||||
|
valStr = s;
|
||||||
lv_label_set_text(valText, s.c_str());
|
lv_label_set_text(valText, s.c_str());
|
||||||
|
|
||||||
if (newValue < 0)
|
if (s[0] == '-')
|
||||||
lv_obj_clear_state(valText, LV_STATE_USER_1);
|
lv_obj_clear_state(valText, LV_STATE_USER_1);
|
||||||
else
|
else
|
||||||
lv_obj_add_state(valText, LV_STATE_USER_1);
|
lv_obj_add_state(valText, LV_STATE_USER_1);
|
||||||
@@ -99,6 +101,7 @@ void ChannelBar::checkEvents()
|
|||||||
lv_obj_set_size(bar, size, height());
|
lv_obj_set_size(bar, size, height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class ChannelBar : public Window
|
|||||||
protected:
|
protected:
|
||||||
uint8_t channel = 0;
|
uint8_t channel = 0;
|
||||||
int16_t value = -10000;
|
int16_t value = -10000;
|
||||||
|
std::string valStr;
|
||||||
std::function<int16_t()> getValue;
|
std::function<int16_t()> getValue;
|
||||||
lv_obj_t* valText = nullptr;
|
lv_obj_t* valText = nullptr;
|
||||||
lv_point_t divPoints[2];
|
lv_point_t divPoints[2];
|
||||||
|
|||||||
Reference in New Issue
Block a user