Skip to content

Commit

Permalink
Merge branch 'orbit' into daniel/orbit/new_test_pattern_select_bulb_i…
Browse files Browse the repository at this point in the history
…ssue
  • Loading branch information
Unreal-Dan committed Jan 15, 2024
2 parents aab4da4 + 2e377f8 commit 491c32c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 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
9 changes: 7 additions & 2 deletions VortexEngine/src/Menus/MenuList/Randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,13 @@ bool Randomizer::rollCustomPattern(Random &ctx, Mode *pMode, LedPos pos)
// colors instead of blinking each color in the set
if (!ctx.next8(0, 3)) {
newPat = PATTERN_BLEND;
// this is the number of blinks to a complementary color
args.arg7 = ctx.next8(0, 3);
// set the blend speed
args.arg6 = ctx.next8(1, 10);
// 1/2 chance to make the blend a flipping blend of some kind
if (!ctx.next8(0, 2)) {
// this is the number of blinks to a complementary color
args.arg7 = ctx.next8(0, 3);
}
// up to arg7 is filled now
args.numArgs = 7;
}
Expand Down
5 changes: 4 additions & 1 deletion VortexEngine/src/Patterns/Single/BlendPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ void BlendPattern::onBlinkOn()
interpolate(m_cur.green, m_next.green);
interpolate(m_cur.blue, m_next.blue);
RGBColor col = m_cur;
if (m_flip) {
// it should be impossible for m_numFlips to be 0 and m_flip to be 1
// unless the pattern arg is changed mid-play which could happen with
// and editor or something, so check both for 0
if (m_flip && m_numFlips) {
// convert to hsv
HSVColor hsvCol = m_cur;
// shift the hue by a flip size
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 491c32c

Please sign in to comment.