Skip to content

Commit

Permalink
Merge branch 'master' into handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Dec 29, 2023
2 parents 788257a + 448cb47 commit f3e1a05
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion VortexEngine/src/Menus/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ Menu::MenuAction Menu::run()

// every time the button is clicked, change the target led
if (g_pButton->onShortClick()) {
nextBulbSelection();
do {
nextBulbSelection();
} while (!isValidLedSelection(m_targetLeds));
}
// on a long press of the button, lock in the target led
if (g_pButton->onLongClick()) {
Expand Down
4 changes: 4 additions & 0 deletions VortexEngine/src/Menus/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Menu
// iterate to next bulb selection
void nextBulbSelection();

// an overridable api that allows derived menus to decide which led selections
// should be available before they have actually opened
virtual bool isValidLedSelection(LedMap selection) const { return true; }

// the mode copied from the current mode used to preview changes
Mode m_previewMode;
// the color of this menu
Expand Down
8 changes: 8 additions & 0 deletions VortexEngine/src/Menus/MenuList/ColorSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,11 @@ void ColorSelect::showFullSet(uint8_t offMs, uint8_t onMs)
}
Leds::setIndex(LED_1, 0x001000);
}

bool ColorSelect::isValidLedSelection(LedMap selection) const
{
// if we have a multi-led pattern then we can only select LED_MULTI otherwise
// if we don't have a multi-led pattern then we can't select multi
bool selectedMulti = (selection == MAP_LED(LED_MULTI));
return selectedMulti == m_previewMode.isMultiLed();
}
6 changes: 5 additions & 1 deletion VortexEngine/src/Menus/MenuList/ColorSelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class ColorSelect : public Menu
void onLongClick() override;

private:
enum ColorSelectState
// override the led selection api to choose which led maps can be selected
bool isValidLedSelection(LedMap selection) const override;

// private enumeration for internal state of color selection
enum ColorSelectState : uint32_t
{
STATE_INIT,
STATE_PICK_SLOT,
Expand Down

0 comments on commit f3e1a05

Please sign in to comment.