Skip to content

Commit

Permalink
fix(color): input edit preview refresh, missing switch display (EdgeT…
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored Aug 17, 2024
1 parent f865578 commit f40ff60
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
39 changes: 18 additions & 21 deletions radio/src/gui/colorlcd/model/input_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
LV_STATE_USER_1);
etx_font(headerSwitchName->getLvObj(), FONT_BOLD_INDEX, LV_STATE_USER_1);

active = !isActive();

setTitle();

auto body_obj = body->getLvObj();
Expand Down Expand Up @@ -82,12 +80,6 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
CurveEdit::SetCurrentSource(expoAddress(index)->srcRaw);
}

bool InputEditWindow::isActive()
{
ExpoData* input = expoAddress(index);
return getSwitch(input->swtch);
}

void InputEditWindow::setTitle()
{
headerSwitchName->setText(getSourceString(MIXSRC_FIRST_INPUT + input));
Expand Down Expand Up @@ -226,26 +218,31 @@ void InputEditWindow::checkEvents()
}
}

bool sw = getSwitch(input->swtch);
if (sw != lastSwitchState) {
uint8_t activeIdx = 255;
for (int i = 0; i < MAX_EXPOS; i += 1) {
auto inp = expoAddress(i);
if (inp->chn == input->chn) {
if (getSwitch(inp->swtch)) {
activeIdx = i;
break;
}
}
}
if (activeIdx != lastActiveIndex) {
updatePreview = true;
lastSwitchState = sw;
lastActiveIndex = activeIdx;
}

if (lastActiveIndex == index) {
lv_obj_add_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
} else {
lv_obj_clear_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
}

if (updatePreview) {
updatePreview = false;
if (preview) preview->update();
}

bool act = isActive();
if (active != act) {
active = act;
if (active) {
lv_obj_add_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
} else {
lv_obj_clear_state(headerSwitchName->getLvObj(), LV_STATE_USER_1);
}
}

Page::checkEvents();
}
4 changes: 1 addition & 3 deletions radio/src/gui/colorlcd/model/input_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ class InputEditWindow : public Page
getvalue_t lastWeightVal = 0;
getvalue_t lastOffsetVal = 0;
getvalue_t lastCurveVal = 0;
bool lastSwitchState = false;
bool active = false;
uint8_t lastActiveIndex = 255;
StaticText * headerSwitchName = nullptr;

void setTitle();
void buildBody(Window *window);

bool isActive();
void checkEvents() override;
void deleteLater(bool detach = true, bool trash = true) override;
};
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/model/model_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class InputLineButton : public InputMixButtonBase
}
}

setOpts(s);
setOpts(tmp_str);

setFlightModes(line.flightModes);
}
Expand Down

0 comments on commit f40ff60

Please sign in to comment.