Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulled new bounce mode to orbit #238

Merged
merged 7 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 12 additions & 34 deletions VortexEngine/src/Leds/Leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,22 @@ void Leds::clearAllOdds()

void Leds::setQuadrant(Quadrant quadrant, RGBColor col)
{
if (quadrant == QUADRANT_5) {
led(LED_3) = col;
led(LED_10) = col;
led(LED_17) = col;
led(LED_24) = col;
return;
}
// start from tip and go to top
setRange(quadrantFirstLed(quadrant), quadrantLastLed(quadrant), col);
}

void Leds::setQuadrants(Quadrant first, Quadrant last, RGBColor col)
{
// start from tip and go to top
setRange(quadrantFirstLed(first), quadrantLastLed(last), col);
}

void Leds::setQuadrantFive(RGBColor col)
{
led(LED_3) = col;
led(LED_10) = col;
led(LED_17) = col;
led(LED_24) = col;
}

void Leds::clearQuadrantFive()
{
led(LED_3) = RGB_OFF;
led(LED_10) = RGB_OFF;
led(LED_17) = RGB_OFF;
led(LED_24) = RGB_OFF;
for (Quadrant quad = first; quad <= last; ++quad) {
setQuadrant(quad, col);
}
}

void Leds::setRing(Ring ring, RGBColor col)
Expand Down Expand Up @@ -301,13 +293,6 @@ void Leds::blinkQuadrant(Quadrant target, uint16_t offMs, uint16_t onMs, RGBColo
}
}

void Leds::blinkQuadrantFive(uint16_t offMs, uint16_t onMs, RGBColor col)
{
if ((Time::getCurtime() % MS_TO_TICKS(offMs + onMs)) < MS_TO_TICKS(onMs)) {
setQuadrantFive(col);
}
}

void Leds::blinkMap(LedMap targets, uint16_t offMs, uint16_t onMs, RGBColor col)
{
if ((Time::getCurtime() % MS_TO_TICKS(offMs + onMs)) < MS_TO_TICKS(onMs)) {
Expand Down Expand Up @@ -360,17 +345,10 @@ void Leds::breatheIndexVal(LedPos target, uint8_t hue, uint32_t variance, uint32
setIndex(target, HSVColor(hue, sat, 255 - (uint8_t)(val + 128 + ((sin(variance * 0.0174533) + 1) * magnitude))));
}

void Leds::breathQuadrant(Quadrant target, uint32_t hue, uint32_t variance, uint32_t magnitude, uint8_t sat, uint8_t val)
void Leds::breatheQuadrant(Quadrant target, uint32_t hue, uint32_t variance, uint32_t magnitude, uint8_t sat, uint8_t val)
{
for (uint8_t pos = 0; pos < 7; ++pos) {
setIndex((LedPos)((target * 7) + pos), HSVColor((uint8_t)(hue + ((sin(variance * 0.0174533) + 1) * magnitude)), sat, val));
}
}

void Leds::breathQuadrantFive(uint32_t hue, uint32_t variance, uint32_t magnitude, uint8_t sat, uint8_t val)
{
for (int target = 0; target < 4; ++target) {
setIndex((LedPos)((target * 7) + 3), HSVColor((uint8_t)(hue + ((sin(variance * 0.0174533) + 1) * magnitude)), sat, val));
setQuadrant(target, HSVColor((uint8_t)(hue + ((sin(variance * 0.0174533) + 1) * magnitude)), sat, val));
}
}

Expand Down
11 changes: 3 additions & 8 deletions VortexEngine/src/Leds/Leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ class Leds
// Control full quadrants of Leds
static void setQuadrant(Quadrant quadrant, RGBColor col);
static void setQuadrants(Quadrant first, Quadrant last, RGBColor col);
static void setQuadrantFive(RGBColor col);

// Turn off full quadrants
static void clearQuadrant(Quadrant quadrant) { setRange(quadrantFirstLed(quadrant), quadrantLastLed(quadrant), HSV_OFF); }
static void clearQuadrants(Quadrant first, Quadrant last) { setRange(quadrantFirstLed(first), quadrantLastLed(last), HSV_OFF); }
static void clearQuadrantFive();
static void clearQuadrant(Quadrant quadrant) { setQuadrant(quadrant, RGB_OFF); }
static void clearQuadrants(Quadrant first, Quadrant last) { setQuadrants(first, last, RGB_OFF); }

// set a ring of leds
static void setRing(Ring ring, RGBColor col);
Expand Down Expand Up @@ -94,7 +92,6 @@ class Leds
static void blinkRange(LedPos first, LedPos last, uint16_t offMs = 250, uint16_t onMs = 500, RGBColor col = RGB_OFF);
static void blinkQuadrantOffset(Quadrant target, uint32_t time, uint16_t offMs = 250, uint16_t onMs = 500, RGBColor col = RGB_OFF);
static void blinkQuadrant(Quadrant target, uint16_t offMs = 250, uint16_t onMs = 500, RGBColor col = RGB_OFF);
static void blinkQuadrantFive(uint16_t offMs = 250, uint16_t onMs = 500, RGBColor col = RGB_OFF);
static void blinkMap(LedMap targets, uint16_t offMs = 250, uint16_t onMs = 500, RGBColor col = RGB_OFF);
static void blinkAll(uint16_t offMs = 250, uint16_t onMs = 500, RGBColor col = RGB_OFF);
// Blink both LEDs on a pair
Expand All @@ -111,9 +108,7 @@ class Leds
uint32_t magnitude = 15, uint8_t sat = 255, uint8_t val = 210);
static void breatheIndexVal(LedPos target, uint8_t hue, uint32_t variance,
uint32_t magnitude = 15, uint8_t sat = 255, uint8_t val = 210);
static void breathQuadrant(Quadrant target, uint32_t hue, uint32_t variance,
uint32_t magnitude = 15, uint8_t sat = 255, uint8_t val = 210);
static void breathQuadrantFive(uint32_t hue, uint32_t variance,
static void breatheQuadrant(Quadrant target, uint32_t hue, uint32_t variance,
uint32_t magnitude = 15, uint8_t sat = 255, uint8_t val = 210);

// a very specialized api to hold all leds on a color for 250ms
Expand Down
11 changes: 5 additions & 6 deletions VortexEngine/src/Menus/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ void Menu::showExit()
Leds::setAll(RGB_RED);
return;
}
Leds::clearQuadrantFive();
Leds::blinkQuadrantFive(250, 500, RGB_RED0);
Leds::clearQuadrant(QUADRANT_5);
Leds::blinkQuadrant(QUADRANT_5, 250, 500, RGB_RED0);
}

void Menu::onLedSelected()
Expand Down Expand Up @@ -232,11 +232,10 @@ void Menu::blinkSelection(uint32_t offMs, uint32_t onMs)
// exit thumb breathes red on the tip and is either blank or red on the top
// depending on whether you've held for the short click threshold or not
if (g_pButton->isPressed() && g_pButton->holdDuration() > SHORT_CLICK_THRESHOLD_TICKS) {
Leds::setQuadrantFive(RGB_WHITE);
Leds::setQuadrant(QUADRANT_5, RGB_WHITE);
} else {
Leds::clearQuadrantFive();
Leds::setQuadrantFive(RGB_RED);
Leds::blinkQuadrantFive(250, 500, RGB_WHITE0);
Leds::setQuadrant(QUADRANT_5, RGB_RED);
Leds::blinkQuadrant(QUADRANT_5, 250, 500, RGB_WHITE0);
}
break;
case QUADRANT_COUNT:
Expand Down
2 changes: 1 addition & 1 deletion VortexEngine/src/Menus/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Menu

protected:
void showBulbSelection();
void showExit();
virtual void showExit();

// blink the selected finger
virtual void blinkSelection(uint32_t offMs = 250, uint32_t onMs = 500);
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 @@ -395,11 +395,11 @@ void ColorSelect::blinkSelection(uint32_t offMs, uint32_t onMs)
// if we're pressing down on a slot then glow the tip white/red
if ((g_pButton->holdDuration() % (DELETE_CYCLE_TICKS * 2)) > DELETE_CYCLE_TICKS) {
// breath red instead of white blink
Leds::breathQuadrant(m_curSelection, 0, g_pButton->holdDuration());
Leds::breatheQuadrant(m_curSelection, 0, g_pButton->holdDuration());
return;
}
} else if (m_slot == (uint32_t)(m_colorset.numColors() + 1)) {
Leds::blinkQuadrantFive(150, 350, RGB_WHITE);
Leds::blinkQuadrant(QUADRANT_5, 150, 350, RGB_WHITE);
}
}
// otherwise run the default blink logic
Expand Down
4 changes: 1 addition & 3 deletions VortexEngine/src/Menus/MenuList/FactoryReset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,14 @@ void FactoryReset::showReset()
// the off/on ms blink faster based on the progress
uint32_t offMs = 150 - ((65 / LED_COUNT) * ledProgress);
uint32_t onMs = 200 - ((25 / LED_COUNT) * ledProgress);
// the hue gets more red starting at 20 going in steps of 4 to min 0
int8_t hue = (ledProgress < 6) ? 20 - (4 * ledProgress) : 0;
// the 'endled' is the tip of the reset progress bar, since the progress
// bar starts full red and empties down to the pinky that means it is
// inverted from the 'ledProgress' which starts at 0 and grows
LedPos endLed = (LedPos)(LED_LAST - ledProgress);
// clear all the leds so that 'blinkRange' will blink from off to the designated color
Leds::clearRange(LED_FIRST, LED_LAST);
// blink to the calculated redish hue from pinky to the end led
Leds::blinkRange(LED_FIRST, endLed, offMs, onMs, HSVColor(hue, 255, 180));
Leds::blinkRange(LED_FIRST, endLed, offMs, onMs, HSVColor(0, 255 - (progress * 170), 180));
// and blink the background the regular blank color
Leds::blinkRange((LedPos)(endLed + 1), LED_LAST, offMs, onMs, RGB_WHITE0);
}
Expand Down
Loading