-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtftespi.ino
101 lines (74 loc) · 1.94 KB
/
tftespi.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
#include <TFT_eSPI.h> // Include the graphics library (this includes the sprite functions)
TFT_eSPI tft = TFT_eSPI(); // Create object "tft"
TFT_eSprite spr = TFT_eSprite(&tft); // Create Sprite object "img" with pointer to "tft" object
// the pointer is used by pushSprite() to push it onto the TFT
void setup(void) {
Serial.begin(250000);
tft.init();
tft.setRotation(3);
tft.fillScreen(TFT_BLACK);
//tft.fillCircle(120, 120, 120, TFT_WHITE);
tft.fillEllipse(160, 120, 160, 120, TFT_WHITE);
spr.setColorDepth(8);
spr.createSprite(150,150);
spr.fillSprite(TFT_TRANSPARENT);
spr.fillCircle(75,75,70, TFT_WHITE);
spr.fillCircle(75,75,66, TFT_BLUE);
spr.fillCircle(75,75,36, TFT_BLACK);
//tft.fillCircle(160,120,66, TFT_BLUE);
//tft.fillCircle(160,120,36, TFT_BLACK);
spr.pushSprite(90,45 , TFT_TRANSPARENT);
pinMode(TFT_BL, OUTPUT);
}
int eyex = 85;
int lidy = 0;
int pick;
void loop() {
pick = random(10);
switch (pick) {
case 1:
lookleft();
break;
case 2:
lookright();
break;
case 3 ... 4:
blink();
break;
default:
// statements
break;
}
delay(1000);
}
void lookleft(){
while (eyex>0){
spr.pushSprite(eyex,45, TFT_TRANSPARENT);
eyex=eyex-3;
}
delay(2000);
while (eyex<=85){
spr.pushSprite(eyex,45 , TFT_TRANSPARENT);
eyex=eyex+3;
}
}
void lookright(){
while (eyex<170){
spr.pushSprite(eyex,45, TFT_TRANSPARENT);
eyex=eyex+3;
}
delay(2000);
while (eyex>=85){
spr.pushSprite(eyex,45, TFT_TRANSPARENT);
eyex=eyex-3;
}
}
void blink(){
// tft.fillEllipse(160, 120, 160, 120, TFT_BLACK);
digitalWrite(TFT_BL, LOW);
delay(500);
digitalWrite(TFT_BL, HIGH);
// tft.fillEllipse(160, 120, 160, 120, TFT_WHITE);
// tft.fillCircle(160,120,66, TFT_BLUE);
// tft.fillCircle(160,120,36, TFT_BLACK);
}