fix(color): trims are still displayed even when turned off in view settings (#4811)
This commit is contained in:
@@ -44,23 +44,39 @@ void MainViewTrim::setRange()
|
||||
}
|
||||
}
|
||||
|
||||
void MainViewTrim::checkEvents()
|
||||
void MainViewTrim::setVisible(bool visible)
|
||||
{
|
||||
Window::checkEvents();
|
||||
int8_t stickIndex = inputMappingConvertMode(idx);
|
||||
hidden = !visible;
|
||||
setDisplayState();
|
||||
}
|
||||
|
||||
trim_t v = getRawTrimValue(mixerCurrentFlightMode, stickIndex);
|
||||
if (v.mode == TRIM_MODE_NONE || v.mode == TRIM_MODE_3POS) {
|
||||
bool MainViewTrim::setDisplayState()
|
||||
{
|
||||
trim_t v = getRawTrimValue(mixerCurrentFlightMode, inputMappingConvertMode(idx));
|
||||
if (hidden || v.mode == TRIM_MODE_NONE || v.mode == TRIM_MODE_3POS) {
|
||||
// Hide trim if not being used
|
||||
if (!lv_obj_has_flag(lvobj, LV_OBJ_FLAG_HIDDEN))
|
||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
if (lv_obj_has_flag(lvobj, LV_OBJ_FLAG_HIDDEN))
|
||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
int newValue = getTrimValue(mixerCurrentFlightMode, stickIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainViewTrim::checkEvents()
|
||||
{
|
||||
Window::checkEvents();
|
||||
|
||||
// Do nothing if trims turned off
|
||||
if (hidden) return;
|
||||
|
||||
// Don't update if not visible
|
||||
if (!setDisplayState()) return;
|
||||
|
||||
int newValue = getTrimValue(mixerCurrentFlightMode, inputMappingConvertMode(idx));
|
||||
|
||||
setRange();
|
||||
newValue = min(max(newValue, trimMin), trimMax);
|
||||
|
||||
@@ -31,14 +31,19 @@ class MainViewTrim : public Window
|
||||
void checkEvents() override;
|
||||
void paint(BitmapBuffer * dc) override;
|
||||
|
||||
void setVisible(bool visible);
|
||||
|
||||
protected:
|
||||
uint8_t idx;
|
||||
int value = 0;
|
||||
bool showChange = false;
|
||||
int trimMin = 0, trimMax = 0;
|
||||
bool hidden = false;
|
||||
|
||||
void setRange();
|
||||
|
||||
bool setDisplayState();
|
||||
|
||||
virtual coord_t sx() { return 0; }
|
||||
virtual coord_t sy() { return 0; }
|
||||
|
||||
|
||||
@@ -83,10 +83,9 @@ void ViewMainDecoration::setSlidersVisible(bool visible)
|
||||
|
||||
void ViewMainDecoration::setTrimsVisible(bool visible)
|
||||
{
|
||||
auto fct = !visible ? lv_obj_add_flag : lv_obj_clear_flag;
|
||||
for (int i=0; i < TRIMS_MAX; i++) {
|
||||
if (trims[i]) {
|
||||
fct(trims[i]->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
trims[i]->setVisible(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
constexpr coord_t FM_LABEL_HEIGHT = 20;
|
||||
|
||||
class MainViewTrim;
|
||||
|
||||
class ViewMainDecoration
|
||||
{
|
||||
public:
|
||||
@@ -69,7 +71,7 @@ class ViewMainDecoration
|
||||
Window* w_br;
|
||||
|
||||
Window* sliders[SLIDERS_MAX];
|
||||
Window* trims[TRIMS_MAX];
|
||||
MainViewTrim* trims[TRIMS_MAX];
|
||||
Window* flightMode;
|
||||
|
||||
void createSliders(Window* ml, Window* mr, Window* bl, Window* bc, Window* br);
|
||||
|
||||
Reference in New Issue
Block a user