Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Sep 15, 2024
1 parent 6770057 commit 79a1af5
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 45 deletions.
3 changes: 1 addition & 2 deletions VortexEngine/src/Leds/Leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ void Leds::holdAll(RGBColor col)
void Leds::update()
{
#ifdef VORTEX_EMBEDDED
// TODO: fixme
FastLED.show(5);
FastLED.show(m_brightness);
#endif
#ifdef VORTEX_LIB
Vortex::vcallbacks()->ledsShow();
Expand Down
21 changes: 19 additions & 2 deletions VortexEngine/src/Menus/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,32 @@ void Menu::onLedSelected()
{
}

void Menu::onShortClick()
void Menu::onShortClickL()
{
}

void Menu::onLongClick()
void Menu::onShortClickM()
{
}

void Menu::onShortClickR()
{
}

void Menu::onLongClickL()
{
leaveMenu(false);
}

void Menu::onLongClickM()
{
leaveMenu(false);
}

void Menu::onLongClickR()
{
}

void Menu::leaveMenu(bool doSave)
{
m_shouldClose = true;
Expand Down
8 changes: 6 additions & 2 deletions VortexEngine/src/Menus/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ class Menu
virtual void onLedSelected();

// optional handlers for clicks
virtual void onShortClick();
virtual void onLongClick();
virtual void onShortClickL();
virtual void onShortClickM();
virtual void onShortClickR();
virtual void onLongClickL();
virtual void onLongClickM();
virtual void onLongClickR();

// close the current menu
virtual void leaveMenu(bool doSave = false);
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/ColorSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void ColorSelect::onLedSelected()
}
}

void ColorSelect::onShortClick()
void ColorSelect::onShortClickM()
{
// increment selection
m_curSelection++;
Expand All @@ -109,7 +109,7 @@ void ColorSelect::onShortClick()
}
}

void ColorSelect::onLongClick()
void ColorSelect::onLongClickM()
{
// if we're on 'exit' and we're on any menu past the slot selection
if (m_curSelection == 4 && m_state > STATE_PICK_SLOT) {
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/ColorSelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class ColorSelect : public Menu
void onLedSelected() override;

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

private:
// override the led selection api to choose which led maps can be selected
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/EditorConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ bool EditorConnection::pushModeChromalink()
return true;
}

void EditorConnection::onShortClick()
void EditorConnection::onShortClickM()
{
// if the device has received any commands do not reset!
if (!m_allowReset) {
Expand All @@ -451,7 +451,7 @@ void EditorConnection::onShortClick()
m_allowReset = false;
}

void EditorConnection::onLongClick()
void EditorConnection::onLongClickM()
{
leaveMenu(true);
}
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/EditorConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class EditorConnection : public Menu
bool pushModeChromalink();

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

// menu conn
void leaveMenu(bool doSave = false) override;
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/FactoryReset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ Menu::MenuAction FactoryReset::run()
return MENU_CONTINUE;
}

void FactoryReset::onShortClick()
void FactoryReset::onShortClickM()
{
m_curSelection = (uint8_t)!m_curSelection;
}

void FactoryReset::onLongClick()
void FactoryReset::onLongClickM()
{
if (m_curSelection == 0) {
// if the selection isn't actually on factory reset then just leave
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/FactoryReset.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class FactoryReset : public Menu
MenuAction run() override;

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

private:
void showReset();
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/GlobalBrightness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ Menu::MenuAction GlobalBrightness::run()
return MENU_CONTINUE;
}

void GlobalBrightness::onShortClick()
void GlobalBrightness::onShortClickM()
{
// include one extra option for the exit slot
m_curSelection = (m_curSelection + 1) % (NUM_BRIGHTNESS_OPTIONS + 1);
}

void GlobalBrightness::onLongClick()
void GlobalBrightness::onLongClickM()
{
if (m_curSelection >= NUM_BRIGHTNESS_OPTIONS) {
// no save exit
Expand Down
12 changes: 8 additions & 4 deletions VortexEngine/src/Menus/MenuList/GlobalBrightness.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ class GlobalBrightness : public Menu
MenuAction run() override;

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

private:
void showBrightnessSelection();

// the list of brightness options
const uint8_t m_brightnessOptions[4] = {
const uint8_t m_brightnessOptions[8] = {
BRIGHTNESS_OPTION_1,
BRIGHTNESS_OPTION_2,
BRIGHTNESS_OPTION_3,
BRIGHTNESS_OPTION_4
BRIGHTNESS_OPTION_4,
BRIGHTNESS_OPTION_5,
BRIGHTNESS_OPTION_6,
BRIGHTNESS_OPTION_7,
BRIGHTNESS_OPTION_8,
};
};

Expand Down
26 changes: 22 additions & 4 deletions VortexEngine/src/Menus/MenuList/ModeSharing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Menu::MenuAction ModeSharing::run()
}

// handlers for clicks
void ModeSharing::onShortClick()
void ModeSharing::onShortClickM()
{
switch (m_sharingMode) {
case ModeShareState::SHARE_RECEIVE:
Expand All @@ -78,7 +78,24 @@ void ModeSharing::onShortClick()
Leds::clearAll();
}

void ModeSharing::onLongClick()
// handlers for clicks
void ModeSharing::onShortClickR()
{
switch (m_sharingMode) {
case ModeShareState::SHARE_RECEIVE:
// click while on receive -> end receive, start sending
VLReceiver::endReceiving();
beginSendingVL();
DEBUG_LOG("Switched to send mode");
break;
default:
break;
}
Leds::clearAll();
}


void ModeSharing::onLongClickM()
{
Modes::updateCurMode(&m_previewMode);
leaveMenu(true);
Expand Down Expand Up @@ -159,12 +176,13 @@ void ModeSharing::showReceiveMode()
{
if (VLReceiver::isReceiving()) {
// using uint32_t to avoid overflow, the result should be within 10 to 255
Leds::setAll(RGBColor(0, VLReceiver::percentReceived(), 0));
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_WHITE0);
Leds::setAll(0x010101);
}
}
}
5 changes: 3 additions & 2 deletions VortexEngine/src/Menus/MenuList/ModeSharing.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class ModeSharing : public Menu
MenuAction run() override;

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

private:
void beginSendingVL();
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/PatternSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void PatternSelect::onLedSelected()
m_srcLed = ledmapGetFirstLed(m_targetLeds);
}

void PatternSelect::onShortClick()
void PatternSelect::onShortClickM()
{
if (m_advanced) {
// double click = skip 10
Expand Down Expand Up @@ -120,7 +120,7 @@ void PatternSelect::onShortClick()
DEBUG_LOGF("Iterated to pattern id %d", newID);
}

void PatternSelect::onLongClick()
void PatternSelect::onLongClickM()
{
if (m_advanced) {
m_argIndex++;
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/PatternSelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class PatternSelect : public Menu
void onLedSelected() override;

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

private:
// helpful member
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/Randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Menu::MenuAction Randomizer::run()
return MENU_CONTINUE;
}

void Randomizer::onShortClick()
void Randomizer::onShortClickM()
{
if (m_needToSelect) {
if (m_flags == RANDOMIZE_BOTH) {
Expand All @@ -126,7 +126,7 @@ void Randomizer::onShortClick()
reRoll();
}

void Randomizer::onLongClick()
void Randomizer::onLongClickM()
{
// if done the randomization selection part
if (m_needToSelect) {
Expand Down
4 changes: 2 additions & 2 deletions VortexEngine/src/Menus/MenuList/Randomizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class Randomizer : public Menu
MenuAction run() override;

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

// re-roll a new randomization with a given context on an led
bool reRoll();
Expand Down
18 changes: 15 additions & 3 deletions VortexEngine/src/Menus/Menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool Menus::runMenuSelection()
if (g_pButtonM->pressTime() >= m_openTime) {
// whether to open advanced menus or not
bool openAdv = (g_pButtonM->holdDuration() > ADV_MENU_DURATION_TICKS) && advMenus;
if (g_pButtonM->onShortClick()) {
if (g_pButtonM->onRelease()) {
// ringmenu is open so select the menu
DEBUG_LOGF("Selected ringmenu %s", menuList[m_selection].menuName);
// open the menu we have selected
Expand Down Expand Up @@ -201,11 +201,23 @@ bool Menus::runCurMenu()
return false;
case Menu::MENU_CONTINUE:
// if Menu continue run the click handlers for the menu
if (g_pButtonL->onShortClick()) {
m_pCurMenu->onShortClickL();
}
if (g_pButtonL->onLongClick()) {
m_pCurMenu->onLongClickL();
}
if (g_pButtonM->onShortClick()) {
m_pCurMenu->onShortClick();
m_pCurMenu->onShortClickM();
}
if (g_pButtonM->onLongClick()) {
m_pCurMenu->onLongClick();
m_pCurMenu->onLongClickM();
}
if (g_pButtonR->onShortClick()) {
m_pCurMenu->onShortClickR();
}
if (g_pButtonR->onLongClick()) {
m_pCurMenu->onLongClickR();
}
break;
case Menu::MENU_SKIP:
Expand Down
12 changes: 8 additions & 4 deletions VortexEngine/src/VortexConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,14 @@
//
// These are the four options available in the global brightness menu
// There is only four options, be careful not to go too low
#define BRIGHTNESS_OPTION_1 40
#define BRIGHTNESS_OPTION_2 120
#define BRIGHTNESS_OPTION_3 185
#define BRIGHTNESS_OPTION_4 255
#define BRIGHTNESS_OPTION_1 5
#define BRIGHTNESS_OPTION_2 30
#define BRIGHTNESS_OPTION_3 60
#define BRIGHTNESS_OPTION_4 90
#define BRIGHTNESS_OPTION_5 120
#define BRIGHTNESS_OPTION_6 160
#define BRIGHTNESS_OPTION_7 200
#define BRIGHTNESS_OPTION_8 255

// Saturation Options
//
Expand Down

0 comments on commit 79a1af5

Please sign in to comment.