Skip to content

Commit

Permalink
Merge branch 'master' into orbit
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Jan 15, 2024
2 parents e9a04ca + 46ec6f5 commit 2e377f8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
35 changes: 28 additions & 7 deletions VortexEngine/src/Menus/MenuList/EditorConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,37 @@ Menu::MenuAction EditorConnection::run()
SerialComs::write(EDITOR_VERB_CLEAR_DEMO_ACK);
m_state = STATE_IDLE;
break;
case STATE_SEND_MODE_VL:
if (!VLSender::isSending() || !VLSender::send()) {
m_state = STATE_IDLE;
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;
}
// continue sending
#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()
{
Expand All @@ -186,9 +207,7 @@ void EditorConnection::onShortClick()

void EditorConnection::onShortClick2()
{
VLSender::loadMode(&m_previewMode);
VLSender::send();
m_state = STATE_SEND_MODE_VL;
sendCurModeVL();
}

void EditorConnection::onLongClick()
Expand Down Expand Up @@ -310,5 +329,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();
}
}
8 changes: 6 additions & 2 deletions VortexEngine/src/Menus/MenuList/EditorConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 onShortClick2() override;
Expand Down Expand Up @@ -62,8 +65,9 @@ class EditorConnection : public Menu
// engine tells gloves to clear the demo preview, gloves acknowledge
STATE_CLEAR_DEMO,

// send the mode over visible light
STATE_SEND_MODE_VL,
// transmit the mode over visible light
STATE_TRANSMIT_MODE_VL,
STATE_TRANSMIT_MODE_VL_DONE,
};

// state of the editor
Expand Down
6 changes: 6 additions & 0 deletions VortexEngine/src/VortexConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down

0 comments on commit 2e377f8

Please sign in to comment.