18 #ifndef SEQUENCEMODE_H 19 #define SEQUENCEMODE_H 35 SequenceMode(std::vector<seq_t> sequences,
int priority = 0,
double freq = 0.25,
int pulses = 0,
double timeout = 0)
36 :
Mode(priority, freq, pulses, timeout), _init(true), _int_inc(0.0), _int_count(0.0)
38 _seqences = sequences;
52 _int_inc = 1.0/(_seqences[_seqidx].crosstime * UPDATE_RATE_HZ);
60 if(_int_count <= 1.0001)
63 _color = interpolateColor(_actualColor, _seqences[_seqidx].
color, _int_count);
64 _int_count += _int_inc;
65 m_sigColorReady(_color);
71 _int_inc = 1.0/(_seqences[_seqidx].holdtime * UPDATE_RATE_HZ);
72 _actualColor = _color;
73 m_sigColorReady(_color);
80 _int_count += _int_inc;
88 if(_seqidx == _seqences.size())
92 _int_inc = 1.0/(_seqences[_seqidx].crosstime * UPDATE_RATE_HZ);
99 std::string
getName(){
return std::string(
"SequenceMode"); }
129 cr.
h = linearInterpolate(ca.
h, cb.
h, t);
130 cr.
s = linearInterpolate(ca.
s, cb.
s, t);
131 cr.
v = linearInterpolate(ca.
v, cb.
v, t);
149 return a * (1 - t) + b * t;
float linearInterpolate(float a, float b, float t)
static void rgb2hsv(float r, float g, float b, float &h, float &s, float &v)
std::vector< seq_t > _seqences
SequenceMode(std::vector< seq_t > sequences, int priority=0, double freq=0.25, int pulses=0, double timeout=0)
static void hsv2rgb(float h, float s, float v, float &r, float &g, float &b)
color::rgba interpolateColor(color::rgba start, color::rgba goal, float t)