Skip to content

Commit

Permalink
Only show 'Invert' button on touch-screen radios.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Sep 27, 2023
1 parent 9948b2c commit c27d848
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions radio/src/gui/colorlcd/sourcechoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include "switches.h"

#if LCD_W > LCD_H
#define FILTER_COLUMNS 3
#define FILTER_COLUMNS 3
#else
#define FILTER_COLUMNS 2
#define FILTER_COLUMNS 2
#endif

class SourceChoiceMenuToolbar : public MenuToolbar
Expand Down Expand Up @@ -102,7 +102,8 @@ class SourceChoiceMenuToolbar : public MenuToolbar
addButton(STR_CHAR_TELEMETRY, MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM,
nullptr, STR_MENU_TELEMETRY);

if ((nxtBtnPos > filterColumns) && choice->isValueAvailable && choice->isValueAvailable(0))
if ((nxtBtnPos > filterColumns) && choice->isValueAvailable &&
choice->isValueAvailable(0))
addButton(STR_SELECT_MENU_CLR, 0, 0, nullptr, nullptr, true);
}
};
Expand Down
7 changes: 6 additions & 1 deletion radio/src/gui/colorlcd/switchchoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ class SwitchChoiceMenuToolbar : public MenuToolbar
},
STR_MENU_OTHER);

if ((nxtBtnPos > filterColumns) && choice->isValueAvailable && choice->isValueAvailable(0))
if ((nxtBtnPos > filterColumns) && choice->isValueAvailable &&
choice->isValueAvailable(0))
addButton(STR_SELECT_MENU_CLR, 0, 0, nullptr, nullptr, true);

coord_t y =
height() - MENUS_TOOLBAR_BUTTON_WIDTH - MENUS_TOOLBAR_BUTTON_PADDING;
coord_t w = width() - MENUS_TOOLBAR_BUTTON_PADDING * 2;

#if defined(HARDWARE_TOUCH)
invertBtn = new MenuToolbarButton(
this, {MENUS_TOOLBAR_BUTTON_PADDING, y, w, MENUS_TOOLBAR_BUTTON_WIDTH},
STR_SELECT_MENU_INV);
Expand All @@ -74,14 +76,17 @@ class SwitchChoiceMenuToolbar : public MenuToolbar
longPress();
return choice->inverted;
});
#endif
}

void longPress()
{
SwitchChoice* switchChoice = (SwitchChoice*)choice;
switchChoice->inverted = !switchChoice->inverted;
switchChoice->fillMenu(menu, filter);
#if defined(HARDWARE_TOUCH)
invertBtn->check(switchChoice->inverted);
#endif
}

protected:
Expand Down

0 comments on commit c27d848

Please sign in to comment.