diff --git a/radio/src/gui/colorlcd/view_main_decoration.cpp b/radio/src/gui/colorlcd/view_main_decoration.cpp index 0227e87cbc5..8c8b650b79e 100644 --- a/radio/src/gui/colorlcd/view_main_decoration.cpp +++ b/radio/src/gui/colorlcd/view_main_decoration.cpp @@ -116,22 +116,35 @@ rect_t ViewMainDecoration::getMainZone() const void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Window* bc, Window* br) { - sliders[0] = new MainViewHorizontalSlider(bl, 0); + int pot = 0, sl = 0; - if (!IS_POT_AVAILABLE(2)) - bc = br; - - if (IS_POT_MULTIPOS(1)) - sliders[1] = new MainView6POS(bc, 1); - else if (IS_POT_AVAILABLE(1)) - sliders[1] = new MainViewHorizontalSlider(bc, 1); + // Bottom left horizontal slider + if (IS_POT_AVAILABLE(pot)) { + sliders[sl] = new MainViewHorizontalSlider(bl, pot); + sl += 1; + } + pot += 1; + + // Bottom center 6POS + if (IS_POT_AVAILABLE(pot)) { + if (IS_POT_MULTIPOS(pot)) { + // Has 6POS - place bottom center + sliders[sl] = new MainView6POS(bc, pot); + pot += 1; sl += 1; + } + } else { + pot += 1; + } - if (IS_POT_AVAILABLE(2)) - sliders[2] = new MainViewHorizontalSlider(br, 2); + // Bottom right horizontal slider + if (IS_POT_AVAILABLE(pot)) { + sliders[sl] = new MainViewHorizontalSlider(br, pot); + sl += 1; + } + pot += 1; - // TODO: check how many pots are configured instead auto max_pots = adcGetMaxInputs(ADC_INPUT_FLEX); - if (max_pots > 3) { + if (max_pots > pot) { // create containers for the sliders, so that they are at the borders of the display // on top of each other, when there are two sliders to display per side auto leftPots = create_layout_box(ml, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_COLUMN); @@ -140,20 +153,30 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo auto rightPots = create_layout_box(mr, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_COLUMN); rightPots->setHeight(VERTICAL_SLIDERS_HEIGHT); - coord_t lsh = (IS_POT_AVAILABLE(5)) ? VERTICAL_SLIDERS_HEIGHT / 2 : VERTICAL_SLIDERS_HEIGHT; - coord_t rsh = (IS_POT_AVAILABLE(6)) ? VERTICAL_SLIDERS_HEIGHT / 2 : VERTICAL_SLIDERS_HEIGHT; + coord_t lsh = (IS_POT_AVAILABLE(pot + 2)) ? VERTICAL_SLIDERS_HEIGHT / 2 : VERTICAL_SLIDERS_HEIGHT; + coord_t rsh = (IS_POT_AVAILABLE(pot + 3)) ? VERTICAL_SLIDERS_HEIGHT / 2 : VERTICAL_SLIDERS_HEIGHT; - if (IS_POT_AVAILABLE(3)) - sliders[3] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, TRIM_SQUARE_SIZE, lsh}, 3); + if (IS_POT_AVAILABLE(pot)) { + sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, TRIM_SQUARE_SIZE, lsh}, pot); + sl += 1; + } + pot += 1; - if (IS_POT_AVAILABLE(4)) - sliders[4] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, TRIM_SQUARE_SIZE, rsh}, 4); + if (IS_POT_AVAILABLE(pot)) { + sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, TRIM_SQUARE_SIZE, rsh}, pot); + sl += 1; + } + pot += 1; - if (IS_POT_AVAILABLE(5)) - sliders[5] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, TRIM_SQUARE_SIZE, lsh}, 5); + if (IS_POT_AVAILABLE(pot)) { + sliders[sl] = new MainViewVerticalSlider(leftPots, rect_t{0, 0, TRIM_SQUARE_SIZE, lsh}, pot); + sl += 1; + } + pot += 1; - if (IS_POT_AVAILABLE(6)) - sliders[6] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, TRIM_SQUARE_SIZE, rsh}, 6); + if (IS_POT_AVAILABLE(pot)) { + sliders[sl] = new MainViewVerticalSlider(rightPots, rect_t{0, 0, TRIM_SQUARE_SIZE, rsh}, pot); + } } }