-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutManager.cpp
89 lines (78 loc) · 2 KB
/
OutManager.cpp
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
#include "OutManager.h"
#include "MatrixImages.h"
void OutManager::exec(){
if(objectActive){
currentMillis = millis();
if (currentMillis > previousMillis + interval) {
previousMillis = currentMillis;
task();
} else if (currentMillis > previousMillis + (interval-50)) { //(interval-1000) se si vuole un black fisso di 1 secondo
closeAll();
}
}
}
void OutManager::closeAll(){
for(uint32_t i=0; i<leds->size(); i++){
leds->get(i)->execStop();
}
for(uint32_t i=0; i<matrixs->size(); i++){
matrixs->get(i)->execStop();
}
}
void OutManager::task(){
uint32_t ledIdx = rand() % leds->size();
leds->get(ledIdx)->execStart();
uint32_t imgIdx = rand() % images->size();
byte* image = images->get(imgIdx);
for(uint32_t i=0; i<matrixs->size(); i++){
matrixs->get(i)->setImage(image);
matrixs->get(i)->execStart();
}
}
void OutManager::taskBoot(){
closeAll();
task();
}
void OutManager::taskShutdown(){
closeAll();
}
OutManager::OutManager(LinkedList<LedSimple*>* _leds, LinkedList<Matrix*>* _matrixs){
matrixs=_matrixs;
leds=_leds;
images = new LinkedList<byte*>();
//images->add(new byte[8] IMAGE_FA);
//images->add(new byte[8] IMAGE_FB);
images->add(new byte[8] IMAGE_FC);
images->add(new byte[8] IMAGE_FD);
images->add(new byte[8] IMAGE_FE);
images->add(new byte[8] IMAGE_FF);
setInterval(100);
init();
}
void OutManager::bootAnimation(){
//cose scenografiche
for(uint32_t i=0; i<leds->size(); i++){
leds->get(i)->setLed(true);
delay(200);
}
for(uint32_t i=0; i<matrixs->size(); i++){
for(uint32_t j=0; j<8; j++){
for(uint32_t k=0; k<8; k++){
matrixs->get(i)->setLed(j, k, true);
delay(50);
}
}
for(uint32_t j=0; j<8; j++){
for(uint32_t k=0; k<8; k++){
matrixs->get(i)->setLed(k, j, false);
delay(50);
}
}
}
for(uint32_t i=0; i<leds->size(); i++){
leds->get(leds->size()-i-1)->setLed(false);
delay(200);
}
closeAll();
delay(2000);
}