From 9ea11b40bb77c6c3ce5d874642b653d61c93d69c Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Mon, 7 Jun 2021 09:32:45 +0200 Subject: [PATCH] Fixed autosource --- radio/src/gui/colorlcd/sourcechoice.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/radio/src/gui/colorlcd/sourcechoice.cpp b/radio/src/gui/colorlcd/sourcechoice.cpp index 5b2232838..53a4c23c1 100644 --- a/radio/src/gui/colorlcd/sourcechoice.cpp +++ b/radio/src/gui/colorlcd/sourcechoice.cpp @@ -72,6 +72,9 @@ void SourceChoice::paint(BitmapBuffer * dc) drawSource(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, textColor); } +// defined in gui/gui_common.cpp +uint8_t switchToMix(uint8_t source); + void SourceChoice::fillMenu(Menu * menu, const std::function & filter) { auto value = getValue(); @@ -95,7 +98,7 @@ void SourceChoice::fillMenu(Menu * menu, const std::function & fi #if defined(AUTOSOURCE) menu->setWaitHandler([=]() { - int16_t val = getMovedSource(0); + int16_t val = getMovedSource(vmin); if (val) { if (filter && filter(val)) { return; @@ -105,17 +108,19 @@ void SourceChoice::fillMenu(Menu * menu, const std::function & fi } this->fillMenu(menu); } +#if defined(AUTOSWITCH) else { - swsrc_t swtch = getMovedSwitch(); - if (swtch) { - div_t info = switchInfo(swtch); - val = info.quot + MIXSRC_FIRST_SWITCH; - if (val && (!filter || !filter(val))) { + swsrc_t swtch = abs(getMovedSwitch()); + if (swtch && !IS_SWITCH_MULTIPOS(swtch)) { + val = switchToMix(swtch); + if (val && (val >= vmin) && (val <= vmax) + && (!filter || !filter(val))) { if (setValue) setValue(val); this->fillMenu(menu); } } } +#endif }); #endif }