#include "effect_sines.h" SinesEffectSinus::SinesEffectSinus(Window* w) { _window = w; _frequency = random16(6<<8, 30<<8); _color_frequency = random16(128, 2<<8); _x = random16(1<<8, (_window->width-2)<<8); accum88 diff = (_window->width<<8) - _x; if (_x > diff) diff=_x; _amplitude = random16(1<<8, diff); _offset = random16(); } void SinesEffectSinus::loop(uint16_t ms) { accum88 x = beatsin88(_frequency, _x-_amplitude, _x+_amplitude, _offset); CRGB color = CHSV(beat88(_color_frequency, _offset)>>8, 255, 255); _window->setSubPixel(x, 0, &color); } SinesEffect::SinesEffect() { _init(); } void SinesEffect::_init() { _count = settings.effects.sines.count; _sinus = new SinesEffectSinus*[_count]; for (int i=0; i<_count; i++) { _sinus[i] = new SinesEffectSinus(window); } } SinesEffect::~SinesEffect() { _delete(); } void SinesEffect::_delete() { for (int i=0; i<_count; i++) { delete _sinus[i]; } delete [] _sinus; } boolean SinesEffect::can_be_shown_with_clock() { return true; } void SinesEffect::loop(uint16_t ms) { if (settings.effects.sines.count != _count) { _delete(); _init(); } // do stuff window->shift_down_and_blur(); for (int i=0; i<_count; i++) { _sinus[i]->loop(ms); } }