-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
105 lines (90 loc) · 2.29 KB
/
main.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <Arduino.h>
#define FASTLED_INTERNAL
#include "FastLED.h"
#include <Adafruit_DotStar.h>
#include <SPI.h>
#include <MyKnob.h>
#include <Encoder.h>
#include "config.h"
#include "Radio.h"
#include "animations/DiamondNecklace.h"
#include "animations/Crossfade.h"
#include "animations/FuckMyEyes.h"
#include "animations/ColorChooser.h"
#include "animations/FindMyBike.h"
#include "animations/Race.h"
// Pins for the rotary
uint8_t rotary1 = 2;
uint8_t rotary2 = 3;
int buttonPin = A0;
CRGB leds[NUMPIXELS];
MyKnob knob(rotary1, rotary2);
// Load animations...
ColorChooser color_chooser(knob, leds);
Crossfade crossfade(knob, leds);
DiamondNecklace diamond_necklace(knob, leds);
FindMyBike find_my_bike(knob, leds);
FuckMyEyes fuck_my_eyes(knob, leds);
Race race(knob, leds);
Radio radio(knob);
Animation *current_animation = &color_chooser;
int animation_index = 0;
int previous_animation_index = -1;
void playAnimation()
{
if (animation_index != previous_animation_index)
{
// Serial.print("Coming from ");
// Serial.print(previous_animation_index);
// Serial.print(" to ");
// Serial.println(animation_index);
if (animation_index > 5)
animation_index = 0;
// BUG CAUTION
// never follow one animation function immediately with itself in the the
// next case
switch (animation_index)
{
case 0:
current_animation = &color_chooser;
break;
case 1:
current_animation = &fuck_my_eyes;
break;
case 2:
current_animation = ∽̱
break;
case 3:
current_animation = &crossfade;
break;
case 4:
current_animation = &diamond_necklace;
break;
case 5:
current_animation = &find_my_bike;
break;
}
current_animation->setup();
previous_animation_index = animation_index;
}
current_animation->run();
}
void setup()
{
FastLED.addLeds<WS2811, DATAPIN, BGR>(leds, NUMPIXELS);
// FastLED.addLeds<DOTSTAR, DATAPIN, CLOCKPIN, RGB>(leds, NUMPIXELS);
Serial.begin(57600);
pinMode(buttonPin, INPUT_PULLUP);
button_debouncer.attach(buttonPin);
button_debouncer.interval(5);
pinMode(rotary1, INPUT_PULLUP);
pinMode(rotary2, INPUT_PULLUP);
radio.setup();
}
void loop()
{
radio.check();
button_debouncer.update();
playAnimation();
knob.check(&animation_index);
}