Skip to content

Commit

Permalink
fixed pattern select and quad 5 leds
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Apr 30, 2024
1 parent cb0dcb3 commit 502ac94
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 150 deletions.
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
Loading

0 comments on commit 502ac94

Please sign in to comment.