-
Notifications
You must be signed in to change notification settings - Fork 4
/
Sinelon.cpp
28 lines (25 loc) · 892 Bytes
/
Sinelon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "Sinelon.h"
Sinelon::Sinelon(Strip *strip, State *state) : Fx(strip, state) {
pixel1.setup(strip);
pixel2.setup(strip);
pixel3.setup(strip);
pixel4.setup(strip);
reset();
}
void Sinelon::reset() {
clear();
pixel1.reset();
pixel2.reset();
pixel3.reset();
pixel4.reset();
}
void Sinelon::loop() {
strip->fade(fade);
uint16_t pos1 = beatsin16(freq1, 0, strip->last());
uint16_t pos2 = beatsin16(freq2, 0, strip->last());
uint16_t pos3 = beatsin16(freq3, 0, strip->last());
pixel1.set((pos1 + pos2) / 2, ColorFromPalette(PALETTE, state->rotatingHue));
pixel2.set((pos2 + pos3) / 2, ColorFromPalette(PALETTE, state->rotatingHue + 64));
pixel3.set((pos1 + pos2 + pos3) / 3, ColorFromPalette(PALETTE, state->rotatingHue + 128));
pixel4.set((pos1 + pos3) / 2, ColorFromPalette(PALETTE, state->rotatingHue + 192));
}