Skip to content

Commit

Permalink
Fix main view slider & 6POS display if pots/sliders are disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Dec 12, 2023
1 parent cb7fafc commit 7716a8c
Showing 1 changed file with 45 additions and 22 deletions.
67 changes: 45 additions & 22 deletions radio/src/gui/colorlcd/view_main_decoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit 7716a8c

Please sign in to comment.