-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwinkleTie.ino
67 lines (61 loc) · 1.39 KB
/
TwinkleTie.ino
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
#define ARDUINO_SAMD_ZERO
#include "Bluetooth.h"
#include "PatternRunner.h"
//
// combines bluetooth communication with a pattern runner to make a remote control necktie
//
ShapedLED tie;
PatternRunner patterns(&tie);
void setup() {
Serial.begin(115200);
bluetoothSetup();
tie.setupTie();
patterns.initPalettes();
}
void loop(void)
{
patterns.runLoop();
uint8_t len = readBluetoothPacket();
if (len == 0) return;
// Buttons
if (packet_buffer[1] == 'B') {
uint8_t buttnum = packet_buffer[2] - '0';
boolean pressed = packet_buffer[3] - '0';
if (pressed) {
switch (buttnum) {
case 1:
patterns.setMode(MODE_OFF);
break;
case 2:
patterns.setMode(MODE_SOLID);
break;
case 3:
patterns.setMode(MODE_ROLLING);
break;
case 4:
break;
case 5:
patterns.increaseBrightness();
break;
case 6:
patterns.decreaseBrightness();
break;
case 7:
patterns.prevPattern();
break;
case 8:
patterns.nextPattern();
break;
}
}
}
// Color picker
else if (packet_buffer[1] == 'C') {
for (int i=0; i < tie.num_leds; i++) {
tie.leds[i].r = packet_buffer[2];
tie.leds[i].g = packet_buffer[3];
tie.leds[i].b = packet_buffer[4];
}
FastLED.show();
}
}