-
Notifications
You must be signed in to change notification settings - Fork 2
/
Serial.h
65 lines (57 loc) · 1.44 KB
/
Serial.h
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
#ifndef MODE_SERIAL
#define MODE_SERIAL
#include "Colors.h"
// ------------------------------------------------------------------
// FEATURE PROTOTYPES
// ------------------------------------------------------------------
void setupFeature();
void runFeature();
void SelectcolorById(int index);
// ------------------------------------------------------------------
// FEATURE IMPLEMENTATIONS
// ------------------------------------------------------------------
void setupFeature()
{
Serial.begin(9600);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
}
void runFeature()
{
if (Serial.available() > 0)
{
SelectcolorById(Serial.read()); // incoming serial byte
}
}
void SelectcolorById(int index)
{
switch (index)
{
case 48: // byte 0
selectColorByIndexMode(INDEX_TURN_OFF);
break;
case 49: // byte 1
selectColorByIndexMode(INDEX_COLOR_GREEN);
break;
case 50: // byte 2
selectColorByIndexMode(INDEX_COLOR_BLUE);
break;
case 51: // byte 3
selectColorByIndexMode(INDEX_COLOR_PURPLE);
break;
case 52: // byte 4
selectColorByIndexMode(INDEX_COLOR_YELLOW);
break;
case 53: // byte 5
selectColorByIndexMode(INDEX_COLOR_WHITE);
break;
case 54: // byte 6
selectColorByIndexMode(INDEX_COLOR_RED);
break;
default:
break;
}
}
#endif