Skip to content
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
35 changes: 16 additions & 19 deletions VortexEngine/src/Modes/DefaultModes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const DefaultModeEntry defaultModes[] = {
{
{
{
PATTERN_BLEND, 3, {
PATTERN_COMPLEMENTARY_BLEND, 3, {
RGB_RED,
RGB_GREEN,
RGB_BLUE,
Expand Down Expand Up @@ -58,31 +58,28 @@ const DefaultModeEntry defaultModes[] = {
{
{
{
PATTERN_DOPGAP, 8, {
RGB_OFF,
0x56D400,
0x5500AB,
RGB_OFF,
RGB_RED,
0x700000,
RGB_PURPLE,
0x700000
PATTERN_COMPLEMENTARY_BLENDSTROBEGAP, 6, {
RGB_RED5,
RGB_YELLOW5,
RGB_RED5,
RGB_CYAN5,
RGB_BLUE5,
RGB_CYAN5,
}
},
{
PATTERN_DOPGAP, 8, {
RGB_OFF,
0x56D400,
0x5500AB,
RGB_OFF,
RGB_RED,
0x700000,
RGB_PURPLE,
0x700000
PATTERN_COMPLEMENTARY_BLENDSTROBEGAP, 6, {
RGB_RED5,
RGB_YELLOW5,
RGB_RED5,
RGB_CYAN5,
RGB_BLUE5,
RGB_CYAN5,
}
}
}
},

{
{
{
Expand Down
10 changes: 7 additions & 3 deletions VortexEngine/src/Patterns/PatternBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ PatternArgs PatternBuilder::getDefaultArgs(PatternID id)
case PATTERN_TRACER: return PatternArgs(ULTRADOPS_ON_DURATION, 0, 0, 20, 1);
case PATTERN_RIBBON: return PatternArgs(RIBBON_DURATION);
case PATTERN_MINIRIBBON: return PatternArgs(1);
case PATTERN_BLEND: return PatternArgs(DOPS_ON_DURATION, DOPS_OFF_DURATION, 0, 0, 0, 0, 1);
case PATTERN_BLEND: return PatternArgs(BLEND_ON_DURATION, BLEND_OFF_DURATION, 0, 0, 0, 2, 1);
case PATTERN_BLENDSTROBE: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 0, 0, 0, 0, 1);
case PATTERN_COMPLEMENTARY_BLEND: return PatternArgs(2, 13, 0, 0, 0, 0, 2);
case PATTERN_BLENDSTROBEGAP: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 75, 0, 0, 9, 1);
case PATTERN_COMPLEMENTARY_BLEND: return PatternArgs(BLEND_ON_DURATION, BLEND_OFF_DURATION, 0, 0, 0, 2, 2);
case PATTERN_COMPLEMENTARY_BLENDSTROBE: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 0, 0, 0, 0, 2);
case PATTERN_COMPLEMENTARY_BLENDSTROBEGAP: return PatternArgs(STROBE_ON_DURATION, STROBE_OFF_DURATION, 75, 0, 0, 9, 2);
case PATTERN_SOLID: return PatternArgs(250);

// =====================
Expand Down Expand Up @@ -241,8 +243,10 @@ Pattern *PatternBuilder::generate(PatternID id, const PatternArgs *userArgs)
case PATTERN_MINIRIBBON: return new BasicPattern(args);
case PATTERN_BLEND:
case PATTERN_BLENDSTROBE:
case PATTERN_BLENDSTROBEGAP:
case PATTERN_COMPLEMENTARY_BLEND:
case PATTERN_COMPLEMENTARY_BLENDSTROBE: return new BlendPattern(args);
case PATTERN_COMPLEMENTARY_BLENDSTROBE:
case PATTERN_COMPLEMENTARY_BLENDSTROBEGAP: return new BlendPattern(args);
case PATTERN_SOLID: return new SolidPattern(args);

// =====================
Expand Down
2 changes: 2 additions & 0 deletions VortexEngine/src/Patterns/Patterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ enum PatternID : int8_t
PATTERN_MINIRIBBON,
PATTERN_BLEND,
PATTERN_BLENDSTROBE,
PATTERN_BLENDSTROBEGAP,
PATTERN_COMPLEMENTARY_BLEND,
PATTERN_COMPLEMENTARY_BLENDSTROBE,
PATTERN_COMPLEMENTARY_BLENDSTROBEGAP,
PATTERN_SOLID,

// ADD NEW SINGLE LED PATTERNS HERE
Expand Down
69 changes: 31 additions & 38 deletions VortexEngine/src/Patterns/Single/BlendPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,37 @@ void BlendPattern::init()

void BlendPattern::onBlinkOn()
{
// if the current hue has reached the next hue
if (m_cur == m_next) {
// get the next color
m_next = m_colorset.getNext();
}
// only transition the blend once every 4 ticks, this will make sure the blend doesn't go
// to fast and it allows the blendspeed parameter to speed it up to preference
if ((Time::getCurtime() % 4) == 0) {
// transition each value of the current hsv to the next hsv, the 'hue' has a
// special handling where 255 is beside 0 (circular transition)
transitionValue(m_cur.hue, m_next.hue, true);
transitionValue(m_cur.sat, m_next.sat, false);
transitionValue(m_cur.val, m_next.val, false);
}
// make a copy of the current color being rendered so that it can be
// flipped to an inverse color if the flips are enabled
HSVColor hsvCol = m_cur;
// flip the hue if there is any flips
if (m_flip) {
// do a flip as bender would say
doFlip();
} else {
// if there is no flips then just do a normal blink
doBlink();
// note: no division by zero because m_numFlips cannot be 0 if m_flip is non-zero
hsvCol.hue += (m_flip * (255 / m_numFlips));
}
// now if there is a flip amount set
if (m_numFlips > 0) {
// then increase the flip counter and modulate it
m_flip = (m_flip + 1) % m_numFlips;
// convert the HSV to RGB with the generic function because
// this will generate a different appearance from using the
// default hsv_to_rgb_rainbow()
Leds::setIndex(m_ledPos, hsv_to_rgb_generic(hsvCol));
// increase the flip counter and modulate it, this actually takes less space
// on avr than using a modulo of numflips, because you must check for nonzero
m_flip++;
if (m_flip >= m_numFlips) {
m_flip = 0;
}
}

Expand Down Expand Up @@ -87,33 +107,6 @@ void BlendPattern::transitionValue(uint8_t &current, const uint8_t next, bool hu
if (hue) {
// wrap around the hue automatically, this handles for example if step is -1
// and it subtracts past 0 to -1, then adding 256 will result in 255
current = (current + 256) % 256;
}
}

void BlendPattern::doBlink()
{
// if the current hue has reached the next hue
if (m_cur == m_next) {
// get the next color
m_next = m_colorset.getNext();
current += 256;
}
// transition each value of the current hsv to the next hsv, the 'hue' has a
// special handling where 255 is beside 0 (circular transition)
transitionValue(m_cur.hue, m_next.hue, true);
transitionValue(m_cur.sat, m_next.sat, false);
transitionValue(m_cur.val, m_next.val, false);
// set the target led with the current HSV color
Leds::setIndex(m_ledPos, hsv_to_rgb_generic(m_cur));
}

void BlendPattern::doFlip()
{
uint32_t hueOffset = m_flip * (255 / m_numFlips);
// generate an inverse hue based on the current hue position
HSVColor hsvCol((m_cur.hue + hueOffset) % 256, m_cur.sat, m_cur.val);
// convert the HSV to RGB with the generic function because
// this will generate a different appearance from using the
// default hsv_to_rgb_rainbow()
Leds::setIndex(m_ledPos, hsv_to_rgb_generic(hsvCol));
}
}
4 changes: 4 additions & 0 deletions VortexEngine/src/Time/Timings.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
#define SIGNAL_ON_DURATION 10
#define SIGNAL_OFF_DURATION 296

// A blink speed good for blends
#define BLEND_ON_DURATION 2
#define BLEND_OFF_DURATION 13

// Ribbon
#define RIBBON_DURATION 6

Expand Down