Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion VortexEngine/VortexLib/VortexLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("Modes")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -921,6 +930,11 @@ bool Vortex::isSleeping()
return VortexEngine::isSleeping();
}

void Vortex::wakeup()
{
VortexEngine::wakeup();
}

bool Vortex::tick()
{
if (!m_initialized) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions VortexEngine/VortexLib/VortexLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions VortexEngine/src/Menus/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 11 additions & 7 deletions VortexEngine/src/VortexConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -610,13 +612,15 @@
#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
#define RGB_MENU_COLOR_SELECT RGB_GREEN4
#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

Expand Down
Binary file modified VortexEngine/tests/tests_general.tar.gz
Binary file not shown.