Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[color] properly filter sources in drop-downs #739

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions radio/src/gui/colorlcd/model_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,24 @@ class InputEditWindow : public Page

// Source
new StaticText(window, grid.getLabelSlot(), STR_SOURCE, 0, COLOR_THEME_PRIMARY1);
new SourceChoice(window, grid.getFieldSlot(), INPUTSRC_FIRST, INPUTSRC_LAST,
GET_DEFAULT(line->srcRaw),
[=] (int32_t newValue) {
line->srcRaw = newValue;
if (line->srcRaw > MIXSRC_Ail && line->carryTrim == TRIM_ON) {
line->carryTrim = TRIM_OFF;
trimChoice->invalidate();
}
SET_DIRTY();
}
);
Choice *src = new SourceChoice(
window, grid.getFieldSlot(), INPUTSRC_FIRST, INPUTSRC_LAST,
GET_DEFAULT(line->srcRaw), [=](int32_t newValue) {
line->srcRaw = newValue;
if (line->srcRaw > MIXSRC_Ail && line->carryTrim == TRIM_ON) {
line->carryTrim = TRIM_OFF;
trimChoice->invalidate();
}
SET_DIRTY();
});
src->setAvailableHandler(
[](int v) { return isSourceAvailableInInputs(v); });

/* TODO telemetry current value
if (ed->srcRaw >= MIXSRC_FIRST_TELEM) {
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN+75, y, (ed->srcRaw - MIXSRC_FIRST_TELEM)/3, convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale), LEFT|(menuHorizontalPosition==1?attr:0));
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN+75, y, (ed->srcRaw -
MIXSRC_FIRST_TELEM)/3, convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM +
1, ed->scale), LEFT|(menuHorizontalPosition==1?attr:0));
} */
grid.nextLine();

Expand Down
2 changes: 2 additions & 0 deletions radio/src/gui/colorlcd/sourcechoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ SourceChoice::SourceChoice(FormGroup *parent, const rect_t &rect, int16_t vmin,

return std::string(getSourceString(value));
});

setAvailableHandler([](int v){ return isSourceAvailable(v); });
}

void SourceChoice::fillMenu(Menu *menu,
Expand Down