fix(color): remove unnecessary updates of channel bar (#5136)

This commit is contained in:
philmoz
2024-06-09 09:29:28 +10:00
committed by GitHub
parent 280d3af62c
commit 2c800c0f3c
2 changed files with 17 additions and 13 deletions
+6 -3
View File
@@ -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);
@@ -98,6 +100,7 @@ void ChannelBar::checkEvents()
lv_obj_set_pos(bar, x, 0); lv_obj_set_pos(bar, x, 0);
lv_obj_set_size(bar, size, height()); lv_obj_set_size(bar, size, height());
} }
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
+1
View File
@@ -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];