diff --git a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp index c9a3e93c4f..7b0268194d 100644 --- a/VortexEngine/src/Menus/MenuList/EditorConnection.cpp +++ b/VortexEngine/src/Menus/MenuList/EditorConnection.cpp @@ -4,6 +4,7 @@ #include "../../Serial/ByteStream.h" #include "../../Serial/Serial.h" #include "../../Storage/Storage.h" +#include "../../Wireless/VLSender.h" #include "../../Time/TimeControl.h" #include "../../Colors/Colorset.h" #include "../../Modes/Modes.h" @@ -164,10 +165,37 @@ Menu::MenuAction EditorConnection::run() SerialComs::write(EDITOR_VERB_CLEAR_DEMO_ACK); m_state = STATE_IDLE; break; + case STATE_TRANSMIT_MODE_VL: +#if ENABLE_VL_SENDER == 1 + // if still sending and the send command indicated more data + if (VLSender::isSending() && VLSender::send()) { + // then continue sending + break; + } +#endif + // othewrise, done, switch to the transmit done state + m_state = STATE_TRANSMIT_MODE_VL_DONE; + break; + case STATE_TRANSMIT_MODE_VL_DONE: + // done transmitting + m_receiveBuffer.clear(); + SerialComs::write(EDITOR_VERB_TRANSMIT_VL_ACK); + m_state = STATE_IDLE; + break; } return MENU_CONTINUE; } +void EditorConnection::sendCurModeVL() +{ +#if ENABLE_VL_SENDER == 1 + // immediately load the mode and send it now + VLSender::loadMode(&m_previewMode); + VLSender::send(); +#endif + m_state = STATE_TRANSMIT_MODE_VL; +} + // handlers for clicks void EditorConnection::onShortClick() { @@ -291,5 +319,7 @@ void EditorConnection::handleCommand() m_state = STATE_DEMO_MODE; } else if (receiveMessage(EDITOR_VERB_CLEAR_DEMO)) { m_state = STATE_CLEAR_DEMO; + } else if (receiveMessage(EDITOR_VERB_TRANSMIT_VL)) { + sendCurModeVL(); } } diff --git a/VortexEngine/src/Menus/MenuList/EditorConnection.h b/VortexEngine/src/Menus/MenuList/EditorConnection.h index 27dddaccce..56235ee432 100644 --- a/VortexEngine/src/Menus/MenuList/EditorConnection.h +++ b/VortexEngine/src/Menus/MenuList/EditorConnection.h @@ -15,6 +15,9 @@ class EditorConnection : public Menu bool init() override; MenuAction run() override; + // broadcast the current preview mode over VL + void sendCurModeVL(); + // handlers for clicks void onShortClick() override; void onLongClick() override; @@ -59,6 +62,10 @@ class EditorConnection : public Menu // engine tells gloves to clear the demo preview, gloves acknowledge STATE_CLEAR_DEMO, + + // transmit the mode over visible light + STATE_TRANSMIT_MODE_VL, + STATE_TRANSMIT_MODE_VL_DONE, }; // state of the editor diff --git a/VortexEngine/src/VortexConfig.h b/VortexEngine/src/VortexConfig.h index fd02ec5702..72654df7c5 100644 --- a/VortexEngine/src/VortexConfig.h +++ b/VortexEngine/src/VortexConfig.h @@ -495,6 +495,12 @@ // that it's no longer listening #define EDITOR_VERB_GOODBYE "l" +// when the computer wants to send a mode to the duo it tells the device +// to transmit over VL and send the current preview mode to the duo +#define EDITOR_VERB_TRANSMIT_VL "m" +// the response from the device when it's done transmitting the mode +#define EDITOR_VERB_TRANSMIT_VL_ACK "n" + // =================================================================== // Manually Configured Sizes //