-
Notifications
You must be signed in to change notification settings - Fork 0
/
lights.ino
66 lines (48 loc) · 1.55 KB
/
lights.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
void writeLights() {
digitalWrite(PIN_LIGHTS_STCP, LOW);
for (int i = LIGHTS_COUNT - 1; i >= 0; i--) {
digitalWrite(PIN_LIGHTS_SHCP, LOW);
digitalWrite(PIN_LIGHTS_DS, lights[i]);
digitalWrite(PIN_LIGHTS_SHCP, HIGH);
}
digitalWrite(PIN_LIGHTS_STCP, HIGH);
}
void toggleMainLights() {
for (int i = 0; i < MAIN_LIGHTS_COUNT; i++) {
lights[mainLightIndexes[i]] = !lights[mainLightIndexes[i]];
}
redrawLights = true;
}
void updateTurningLights() {
if (driveStatus == DRIVING_LEFT) {
int x = (millis() / TURNING_BLINKING_TIME) % 2;
if (lights[LIGHTS_HEAD_TURN_LEFT] != x) {
lights[LIGHTS_HEAD_TURN_LEFT] = x;
lights[LIGHTS_TAIL_TURN_LEFT] = x;
redrawLights = true;
}
}
if (driveStatus == DRIVING_RIGHT) {
bool x = (millis() / TURNING_BLINKING_TIME) % 2;
if (lights[LIGHTS_HEAD_TURN_RIGHT] != x) {
lights[LIGHTS_HEAD_TURN_RIGHT] = x;
lights[LIGHTS_TAIL_TURN_RIGHT] = x;
redrawLights = true;
}
}
}
void setReverseLights(boolean newState) {
lights[LIGHTS_REVERSE_LEFT] = newState;
lights[LIGHTS_REVERSE_RIGHT] = newState;
redrawLights = true;
}
void setTurnLeftLights(boolean newState) {
lights[LIGHTS_HEAD_TURN_LEFT] = newState;
lights[LIGHTS_TAIL_TURN_LEFT] = newState;
redrawLights = true;
}
void setTurnRightLights(boolean newState) {
lights[LIGHTS_HEAD_TURN_RIGHT] = newState;
lights[LIGHTS_TAIL_TURN_RIGHT] = newState;
redrawLights = true;
}