diff --git a/VortexEngine/VortexLib/VortexLib.cpp b/VortexEngine/VortexLib/VortexLib.cpp index 2dadb22a50..5c8462d58d 100644 --- a/VortexEngine/VortexLib/VortexLib.cpp +++ b/VortexEngine/VortexLib/VortexLib.cpp @@ -464,7 +464,14 @@ EMSCRIPTEN_BINDINGS(Vortex) { .function("onLedSelected", &Menu::onLedSelected) .function("onShortClick", &Menu::onShortClick) .function("onLongClick", &Menu::onLongClick) - .function("leaveMenu", &Menu::leaveMenu); + .function("leaveMenu", &Menu::leaveMenu) + .function("getPreviewMode", &Menu::getPreviewMode) + .function("getMenuColor", &Menu::getMenuColor) + .function("getTargetLeds", &Menu::getTargetLeds) + .function("getCurSelection", &Menu::getCurSelection) + .function("isLedSelected", &Menu::isLedSelected) + .function("isAdvanced", &Menu::isAdvanced); + //.function("setTargetLeds", &Menu::setTargetLeds); class_("Modes") @@ -514,6 +521,7 @@ EMSCRIPTEN_BINDINGS(Vortex) { .class_function("menuEnterClick", &Vortex::menuEnterClick) .class_function("advMenuEnterClick", &Vortex::advMenuEnterClick) .class_function("deleteColClick", &Vortex::deleteColClick) + .class_function("factoryResetClick", &Vortex::factoryResetClick) .class_function("sleepClick", &Vortex::sleepClick) .class_function("forceSleepClick", &Vortex::forceSleepClick) .class_function("pressButton", &Vortex::pressButton) @@ -580,6 +588,7 @@ EMSCRIPTEN_BINDINGS(Vortex) { .class_function("sleepEnabled", &Vortex::sleepEnabled) .class_function("enterSleep", &Vortex::enterSleep) .class_function("isSleeping", &Vortex::isSleeping) + .class_function("wakeup", &Vortex::wakeup) .class_function("enableCommandLog", &Vortex::enableCommandLog) .class_function("getCommandLog", &Vortex::getCommandLog) .class_function("clearCommandLog", &Vortex::clearCommandLog) @@ -921,6 +930,11 @@ bool Vortex::isSleeping() return VortexEngine::isSleeping(); } +void Vortex::wakeup() +{ + VortexEngine::wakeup(); +} + bool Vortex::tick() { if (!m_initialized) { @@ -1007,6 +1021,14 @@ void Vortex::deleteColClick(uint8_t buttonIndex) m_buttonEventQueue.push_back(VortexButtonEvent(buttonIndex, EVENT_DELETE_COL)); } +void Vortex::factoryResetClick(uint8_t buttonIndex) +{ + if (!buttonIndex) { + buttonIndex = m_selectedButton; + } + m_buttonEventQueue.push_back(VortexButtonEvent(buttonIndex, EVENT_FACTORY_RESET_CLICK)); +} + void Vortex::sleepClick(uint8_t buttonIndex) { if (!buttonIndex) { @@ -1790,6 +1812,17 @@ void Vortex::handleInputQueue(Button *buttons, uint32_t numButtons) pButton->m_newRelease = true; DEBUG_LOG("Injecting delete color click"); break; + case EVENT_FACTORY_RESET_CLICK: + // to do this we simply press the button and set the press time + // to something more than the menu trigger threshold that will make + // us immediately enter the menus. But we need to unset the pressed + // button right after so we push a reset click event to reset the button + pButton->m_pressTime = Time::getCurtime(); + pButton->m_holdDuration = FACTORY_RESET_THRESHOLD_TICKS + MS_TO_TICKS(11); + pButton->m_longClick = true; + pButton->m_newRelease = true; + DEBUG_LOG("Injecting factory reset click"); + break; case EVENT_SLEEP_CLICK: // to do this we simply press the button and set the press time // to something more than the menu trigger threshold that will make diff --git a/VortexEngine/VortexLib/VortexLib.h b/VortexEngine/VortexLib/VortexLib.h index dd58ccef30..9b88f1a055 100644 --- a/VortexEngine/VortexLib/VortexLib.h +++ b/VortexEngine/VortexLib/VortexLib.h @@ -129,6 +129,7 @@ class Vortex static void menuEnterClick(uint8_t buttonIndex = 0); static void advMenuEnterClick(uint8_t buttonIndex = 0); static void deleteColClick(uint8_t buttonIndex = 0); + static void factoryResetClick(uint8_t buttonIndex = 0); static void sleepClick(uint8_t buttonIndex = 0); static void forceSleepClick(uint8_t buttonIndex = 0); static void pressButton(uint8_t buttonIndex = 0); @@ -252,6 +253,7 @@ class Vortex // whether the engine is sleeping, and/or to enter sleep static void enterSleep(bool save); static bool isSleeping(); + static void wakeup(); // enable, fetch and clear the internal command log static void enableCommandLog(bool enable) { m_commandLogEnabled = enable; } @@ -341,6 +343,8 @@ class Vortex EVENT_ADV_MENU_ENTER_CLICK, // a press that is long enough to delete a color from col select EVENT_DELETE_COL, + // a press that is long enough to confirm factory reset + EVENT_FACTORY_RESET_CLICK, // a press just long enough to put the device to sleep from main modes EVENT_SLEEP_CLICK, // a press very long so that the chip triggers it's force sleep diff --git a/VortexEngine/src/Menus/Menu.cpp b/VortexEngine/src/Menus/Menu.cpp index 97c904b763..f62ec1ca17 100644 --- a/VortexEngine/src/Menus/Menu.cpp +++ b/VortexEngine/src/Menus/Menu.cpp @@ -97,9 +97,9 @@ Menu::MenuAction Menu::run() void Menu::showBulbSelection() { Leds::clearAll(); - Leds::blinkMap(m_targetLeds, BULB_SELECT_OFF_MS, BULB_SELECT_ON_MS, RGB_MAGENTA1); + Leds::blinkMap(m_targetLeds, BULB_SELECT_OFF_MS, BULB_SELECT_ON_MS, RGB_MENU_BULB_SELECT); // blink when selecting - Menus::showSelection(RGB_MAGENTA1); + Menus::showSelection(RGB_MENU_BULB_SELECT); } void Menu::showExit() diff --git a/VortexEngine/src/Menus/Menu.h b/VortexEngine/src/Menus/Menu.h index 997a46ee9d..42a4226d38 100644 --- a/VortexEngine/src/Menus/Menu.h +++ b/VortexEngine/src/Menus/Menu.h @@ -37,6 +37,14 @@ class Menu // close the current menu virtual void leaveMenu(bool doSave = false); + // exposed getters for wasm and duo tutorial primarily + Mode getPreviewMode() { return m_previewMode; } + RGBColor getMenuColor() { return m_menuColor; } + LedMap getTargetLeds() { return m_targetLeds; } + uint8_t getCurSelection() { return m_curSelection; } + bool isLedSelected() { return m_ledSelected; } + bool isAdvanced() { return m_advanced; } + protected: void showBulbSelection(); void showExit(); diff --git a/VortexEngine/src/VortexConfig.h b/VortexEngine/src/VortexConfig.h index b04345cb0a..c623868659 100644 --- a/VortexEngine/src/VortexConfig.h +++ b/VortexEngine/src/VortexConfig.h @@ -423,26 +423,28 @@ #include "Colors/ColorConstants.h" // Randomizer Menu Color -#define RGB_MENU_RANDOMIZER RGB_WHITE1 +#define RGB_MENU_RANDOMIZER RGB_WHITE4 // Mode Sharing Menu Color -#define RGB_MENU_MODE_SHARING RGB_CYAN1 +#define RGB_MENU_MODE_SHARING RGB_CYAN4 // Editor Connection Menu Color -#define RGB_MENU_EDITOR_CONNECTION RGB_MAGENTA1 +#define RGB_MENU_EDITOR_CONNECTION RGB_MAGENTA4 // Color Select Menu Color -#define RGB_MENU_COLOR_SELECT RGB_GREEN1 +#define RGB_MENU_COLOR_SELECT RGB_GREEN4 // Pattern Select Menu Color -#define RGB_MENU_PATTERN_SELECT RGB_BLUE1 +#define RGB_MENU_PATTERN_SELECT RGB_BLUE4 // Global Brightness Menu Color -#define RGB_MENU_BRIGHTNESS_SELECT RGB_YELLOW1 +#define RGB_MENU_BRIGHTNESS_SELECT RGB_YELLOW4 // Factory Reset Menu Color -#define RGB_MENU_FACTORY_RESET RGB_RED1 +#define RGB_MENU_FACTORY_RESET RGB_RED4 +// Bulb Selection Color +#define RGB_MENU_BULB_SELECT RGB_MAGENTA4 // =================================================================== // Editor Verbs @@ -610,6 +612,7 @@ #undef RGB_MENU_PATTERN_SELECT #undef RGB_MENU_BRIGHTNESS_SELECT #undef RGB_MENU_FACTORY_RESET +#undef RGB_MENU_BULB_SELECT #define RGB_MENU_RANDOMIZER RGB_WHITE4 #define RGB_MENU_MODE_SHARING RGB_CYAN4 #define RGB_MENU_EDITOR_CONNECTION RGB_MAGENTA4 @@ -617,6 +620,7 @@ #define RGB_MENU_PATTERN_SELECT RGB_BLUE4 #define RGB_MENU_BRIGHTNESS_SELECT RGB_YELLOW4 #define RGB_MENU_FACTORY_RESET RGB_RED4 +#define RGB_MENU_BULB_SELECT RGB_MAGENTA4 #endif // ifdef VORTEX_LIB diff --git a/VortexEngine/tests/tests_general.tar.gz b/VortexEngine/tests/tests_general.tar.gz index 86dc18e44d..505c89b055 100644 Binary files a/VortexEngine/tests/tests_general.tar.gz and b/VortexEngine/tests/tests_general.tar.gz differ