-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnimationEye.h
80 lines (68 loc) · 1.64 KB
/
AnimationEye.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef ANIMATIONEYE_H
#define ANIMATIONEYE_H
#include "Animation.h"
#include "Achojoao_Nesduino.h"
class AnimationEye: public Animation {
public:
AnimationEye() {}
~AnimationEye() {}
virtual void start() {
resetValues();
}
virtual void display() {
long currentMillis = millis();
if (currentMillis - lastMillis >= animationMillis) {
lastMillis = currentMillis;
if (action >= 1 && action <= 9) {
action = random(11);
int randDelay = 1000 * ( 1 + random(10));
Nesduino.clearScreen();
Nesduino.fillRoundRect(1,1,6,6,1,HIGH);
Nesduino.fillRoundRect(4-(action%3),2+(action/4),2,2,0,LOW);
Nesduino.write();
animationMillis = randDelay;
} else {
animationMillis = 50;
if (j < 2) {
if (i < 10) {
Nesduino.clearScreen();
Nesduino.fillRoundRect(1,1,6,6,1,HIGH);
Nesduino.fillRoundRect(3,3,2,2,0,LOW);
i++;
} else if (i < 16) {
Nesduino.drawLine(0,i-10,7,i-10,LOW);
if (i == 15) {
i = 0;
j++;
} else {
i++;
}
}
} else {
j = 0;
action = random(11);
}
Nesduino.write();
}
}
}
virtual void finish() {
resetValues();
}
private:
long lastMillis;
long animationMillis;
int action;
int i;
int j;
void resetValues() {
Nesduino.clearScreen();
Nesduino.setIntensity(3);
lastMillis = 0;
animationMillis = 0;
action = 0;
i = 0;
j = 0;
}
};
#endif