From dd61b99f6e334fdb831d3f96a7bf1f58db89964a Mon Sep 17 00:00:00 2001 From: Unreal-Dan <72595612+Unreal-Dan@users.noreply.github.com> Date: Fri, 27 Oct 2023 15:45:06 -0700 Subject: [PATCH] toggles a single selection mask (#131) --- VortexEngine/src/Menus/Menu.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/VortexEngine/src/Menus/Menu.cpp b/VortexEngine/src/Menus/Menu.cpp index 323fb2d22f..1020035cd4 100644 --- a/VortexEngine/src/Menus/Menu.cpp +++ b/VortexEngine/src/Menus/Menu.cpp @@ -253,5 +253,14 @@ void Menu::blinkSelection(uint32_t offMs, uint32_t onMs) // this adds the currently targeted ledPermutation to the selected leds void Menu::addSelectionMask() { - m_targetLeds |= ledPermutations[m_ledSelection]; + // if selecting any of the individual leds then toggle + uint32_t mask = ledPermutations[m_ledSelection]; + // checks if only 1 b it is set in the target mask + if ((mask & (mask - 1)) == 0) { + // if there's only one bit set then toggle that location + m_targetLeds ^= mask; + } else { + // otherwise just add the mask whatever it is + m_targetLeds |= mask; + } }