-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenFrame.ino
115 lines (105 loc) · 3.06 KB
/
screenFrame.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
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
106
107
108
109
110
111
112
113
114
115
#include "screenFrame.h"
#include "frameWeb.h"
void setup()
{
Serial.begin(115200);
randomSeed(analogRead(0));
initPixels();
initWebServer();
xTaskCreatePinnedToCore(
handleBrowserCalls, /* Function to implement the task */
"handleBrowserCalls", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
NULL, /* Task handle. */
1); /* Core where the task should run */
drawFrameFromBothSides(getRandomColor(), 10);
// Scheduled tasks in milliseconds
scheduler.addTask(playModeFrame, 2700000L);
scheduler.addTask(playModeSection, 900000L);
}
void loop()
{
scheduler.runTasks();
delay(1);
}
void playModeFrame(void)
{
if (suspendAnimations)
{
return;
}
Frame_Mode frameMode = static_cast<Frame_Mode>(esp_random() % NUM_FRAME_MODES);
switch (frameMode)
{
case MODE_FRAMING:
pixels.fill(COLOR_BLACK);
pixels.show();
delay(10000L);
drawFrameAround(getRandomColor(), getRandomMillis(5, 50));
playModeSection();
break;
case MODE_FRAME_PULSE:
pulse(getRandomMillis(5, 15), getRandomMillis(10000L, 30000L));
playModeSection();
break;
case MODE_FRAME_BLINK:
blinkFrame(getRandomMillis(100, 500), getRandomMillis(10000L, 20000L));
playModeSection();
case MODE_FRAME_BOTH_SIDES:
pixels.fill(COLOR_BLACK);
pixels.show();
delay(10000L);
drawFrameFromBothSides(getRandomColor(), getRandomMillis(5, 50));
playModeSection();
break;
}
}
void playModeSection(void)
{
if (suspendAnimations)
{
return;
}
Section_Mode sectionMode = static_cast<Section_Mode>(esp_random() % NUM_MODES_SECTION);
Section_Positions sectionPosition = static_cast<Section_Positions>(esp_random() % NUM_SECTION_POSITION);
int *sectionPixels;
switch (sectionPosition)
{
case TopLeft:
sectionPixels = pixelTopLeft;
break;
case TopRight:
sectionPixels = pixelTopRight;
break;
case BottomLeft:
sectionPixels = pixelBottomLeft;
break;
case BottomRight:
sectionPixels = pixelBottomRight;
break;
}
switch (sectionMode)
{
case MODE_SECTION_BLINK:
blinkSection(sectionPixels, getRandomColor(), true, getRandomMillis(25, 500), getRandomMillis(60000L, 120000L));
break;
case MODE_SECTION_CENTER:
showSectionFromCenter(sectionPixels, getRandomColor(), true, getRandomMillis(15, 100), getRandomMillis(60000L, 120000L));
break;
case MODE_SECTION_SCROLL:
scrollSection(sectionPixels, getRandomColor(), true, getRandomMillis(15, 100), getRandomMillis(60000L, 120000L));
break;
}
}
// Task for the web browser
//
void handleBrowserCalls(void *parameter)
{
for (;;)
{
server.handleClient();
delay(1); // allow other tasks to run
}
}