Skip to content

Commit

Permalink
fixes for spark
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Dec 5, 2024
1 parent 4c0c6f2 commit 4d8deeb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 47 deletions.
58 changes: 19 additions & 39 deletions VortexEngine/src/Menus/MenuList/ModeSharing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ bool ModeSharing::init()
}
// skip led selection
m_ledSelected = true;
// start on receive because it's the more responsive of the two
// the odds of opening receive and then accidentally receiving
// a mode that is being broadcast nearby is completely unlikely
beginReceivingVL();
if (m_advanced) {
// start on receive because it's the more responsive of the two
// the odds of opening receive and then accidentally receiving
// a mode that is being broadcast nearby is completely unlikely
beginReceivingVL();
} else {
beginReceivingIR();
}
DEBUG_LOG("Entering Mode Sharing");
return true;
}
Expand Down Expand Up @@ -78,7 +82,7 @@ Menu::MenuAction ModeSharing::run()
}

// handlers for clicks
void ModeSharing::onShortClickM()
void ModeSharing::onShortClick()
{
switch (m_sharingMode) {
case ModeShareState::SHARE_RECEIVE_VL:
Expand All @@ -104,15 +108,9 @@ void ModeSharing::onShortClickM()
Leds::clearAll();
}

// handlers for clicks
void ModeSharing::onShortClickL()
{
switchVLIR();
}

void ModeSharing::onShortClickR()
void ModeSharing::onLongClick()
{
switchVLIR();
leaveMenu();
}

void ModeSharing::switchVLIR()
Expand All @@ -132,12 +130,6 @@ void ModeSharing::switchVLIR()
Leds::clearAll();
}

void ModeSharing::onLongClickM()
{
Modes::updateCurMode(&m_previewMode);
leaveMenu(true);
}

void ModeSharing::beginSendingIR()
{
// if the sender is sending then cannot start again
Expand Down Expand Up @@ -208,11 +200,9 @@ void ModeSharing::receiveModeIR()
return;
}
DEBUG_LOGF("Success receiving mode: %u", m_previewMode.getPatternID());
if (!m_advanced) {
Modes::updateCurMode(&m_previewMode);
// leave menu and save settings, even if the mode was the same whatever
leaveMenu(true);
}
Modes::updateCurMode(&m_previewMode);
// leave menu and save settings, even if the mode was the same whatever
leaveMenu(true);
}

void ModeSharing::beginSendingVL()
Expand Down Expand Up @@ -275,11 +265,9 @@ void ModeSharing::receiveModeVL()
return;
}
DEBUG_LOGF("Success receiving mode: %u", m_previewMode.getPatternID());
if (!m_advanced) {
Modes::updateCurMode(&m_previewMode);
// leave menu and save settings, even if the mode was the same whatever
leaveMenu(true);
}
Modes::updateCurMode(&m_previewMode);
// leave menu and save settings, even if the mode was the same whatever
leaveMenu(true);
}

void ModeSharing::showSendModeVL()
Expand All @@ -302,11 +290,7 @@ void ModeSharing::showReceiveModeVL()
Leds::clearAll();
Leds::setRange(LED_FIRST, (LedPos)(VLReceiver::percentReceived() / 10), RGBColor(0, 1, 0));
} else {
if (m_advanced) {
m_previewMode.play();
} else {
Leds::setAll(0x010101);
}
Leds::setAll(0x010101);
}
}

Expand All @@ -317,10 +301,6 @@ void ModeSharing::showReceiveModeIR()
Leds::clearAll();
Leds::setRange(LED_FIRST, (LedPos)(VLReceiver::percentReceived() / 10), RGBColor(0, 1, 0));
} else {
if (m_advanced) {
m_previewMode.play();
} else {
Leds::setAll(RGB_CYAN0);
}
Leds::setAll(RGB_CYAN0);
}
}
6 changes: 2 additions & 4 deletions VortexEngine/src/Menus/MenuList/ModeSharing.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ class ModeSharing : public Menu
MenuAction run() override;

// handlers for clicks
void onShortClickM() override;
void onShortClickL() override;
void onShortClickR() override;
void onLongClickM() override;
void onShortClick() override;
void onLongClick() override;

private:
void beginSendingVL();
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Wireless/IRConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#define IR_DIVIDER_SPACE_MIN IR_HEADER_MARK_MIN
#define IR_DIVIDER_SPACE_MAX IR_HEADER_MARK_MAX

#define IR_SEND_PWM_PIN 0
#define IR_RECEIVER_PIN 2
#define IR_SEND_PWM_PIN 3
#define IR_RECEIVER_PIN 4

#endif
4 changes: 2 additions & 2 deletions VortexEngine/src/Wireless/VLConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Whether to enable the Visible Light system as a whole
//
#define VL_ENABLE_SENDER 1
#define VL_ENABLE_RECEIVER 0
#define VL_ENABLE_RECEIVER 1

// the size of IR blocks in bits
#define VL_DEFAULT_BLOCK_SIZE 256
Expand Down Expand Up @@ -42,6 +42,6 @@
#define VL_DIVIDER_SPACE_MAX VL_HEADER_MARK_MAX

#define VL_SEND_PWM_PIN 0
#define VL_RECEIVER_PIN 0
#define VL_RECEIVER_PIN 1

#endif

0 comments on commit 4d8deeb

Please sign in to comment.