-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeoPixel.ino
More file actions
70 lines (63 loc) · 1.98 KB
/
NeoPixel.ino
File metadata and controls
70 lines (63 loc) · 1.98 KB
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
void drawTime() {
strip.clear();
drawPointer(timeReal.hour * 5, 5, strip.Color(255, 0, 0));
drawPointer(timeReal.min, 3, strip.Color(0, 255, 0));
drawPointer(timeReal.sec, 1, strip.Color(0, 0, 255));
strip.show();
}
void drawPointer(byte num, byte size, uint32_t color) {
for (byte i = 1; i <= size; i++) {
int pix = ((59 - (num - ((size + 1) / 2) + i)) + PIXEL_ROTATION_OFFSET) % 60;
pix = pix < 0 ? (pix + 60) : pix;
//Serial.printf("%d ", pix);
strip.setPixelColor(pix, color);
}
//Serial.println("");
}
void drawTimer() {
if (!clockRinging) {
strip.clear();
timerPixelCountFloat = (timerCentSecLength - timerCentSecLeft);
timerPixelCount = (timerPixelCountFloat / timerCentSecLength) * 60;
for (byte i = 0; i < timerPixelCount; i++) {
strip.setPixelColor(59 - i, strip.Color(255, 255, 0));
}
strip.show();
}
}
void ring(bool ringType, byte alarmNumber) {
clockMode = RINGING;
clockRinging = 1;
strip.fill(strip.Color(255, 0, 0));
if (brightness_pv == brightness_flashLow) brightness_sp = brightness_flashHigh;
if (brightness_pv == brightness_flashHigh) brightness_sp = brightness_flashLow;
//Serial.printf("sp:%d,pv:%d\n", brightness_sp, brightness_pv);
byte i = 0;
while (!digitalRead(BTN_PIN)) {
strip.setBrightness(brightness_default);
if (i < 60) {
for (byte j = 0; j <= i; j++) {
strip.setPixelColor(59 - j, strip.Color(255, 255, 0));
}
strip.show();
delay(fadeStepDuration);
i++;
} else {
if (clockRinging) { //entering here only one time
clockRinging = 0;
clockMode = NORMAL;
if (ringType==TIMER_RING) {
onTimer = 0;
timerRing = 0;
} else if (ringType==ALARM_RING) {
if (alarms[alarmNumber].oneTime) { //delete the alarm
deleteAlarm(alarmNumber);
} else {
alarms[alarmNumber].alreadyRinged = 1;
}
}
}
lastTimeBTNPressed = millis();
}
}
}