This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
250 lines (205 loc) · 6.07 KB
/
test.c
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/* These functions are based on the Arduino test program at
* https://github.com/adafruit/Adafruit-SSD1351-library/blob/master/examples/test/test.ino
*
* You can use these high-level routines to implement your
* test program.
*/
// TODO Configure SPI port and use these libraries to implement
// an OLED test program. See SPI example program.
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1351.h"
#include "test.h"
extern int cursor_x;
extern int cursor_y;
float p = 3.1415926;
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
//*****************************************************************************
// function delays 3*ulCount cycles
void delay(unsigned long ulCount){
int i;
do{
ulCount--;
for (i=0; i< 65535; i++) ;
}while(ulCount);
}
//*****************************************************************************
void testfastlines(unsigned int color1, unsigned int color2) {
unsigned int x;
unsigned int y;
fillScreen(BLACK);
for (y=0; y < height()-1; y+=8) {
drawFastHLine(0, y, width()-1, color1);
}
delay(100);
for (x=0; x < width()-1; x+=8) {
drawFastVLine(x, 0, height()-1, color2);
}
delay(100);
}
//*****************************************************************************
void testdrawrects(unsigned int color) {
unsigned int x;
fillScreen(BLACK);
for (x=0; x < height()-1; x+=6) {
drawRect((width()-1)/2 -x/2, (height()-1)/2 -x/2 , x, x, color);
delay(10);
}
}
//*****************************************************************************
void testfillrects(unsigned int color1, unsigned int color2) {
unsigned char x;
fillScreen(BLACK);
for (x=height()-1; x > 6; x-=6) {
fillRect((width()-1)/2 -x/2, (height()-1)/2 -x/2 , x, x, color1);
drawRect((width()-1)/2 -x/2, (height()-1)/2 -x/2 , x, x, color2);
delay(10);
}
}
//*****************************************************************************
void testfillcircles(unsigned char radius, unsigned int color) {
unsigned char x;
unsigned char y;
for (x=radius; x < width()-1; x+=radius*2) {
for (y=radius; y < height()-1; y+=radius*2) {
fillCircle(x, y, radius, color);
delay(10);
}
}
}
//*****************************************************************************
void testdrawcircles(unsigned char radius, unsigned int color) {
unsigned char x;
unsigned char y;
for (x=0; x < width()-1+radius; x+=radius*2) {
for (y=0; y < height()-1+radius; y+=radius*2) {
drawCircle(x, y, radius, color);
delay(10);
}
}
}
//*****************************************************************************
void testtriangles() {
int color = 0xF800;
int t;
int w = width()/2;
int x = height()-1;
int y = 0;
int z = width()-1;
fillScreen(BLACK);
for(t = 0 ; t <= 15; t+=1) {
drawTriangle(w, y, y, x, z, x, color);
x-=4;
y+=4;
z-=4;
color+=100;
delay(10);
}
}
//*****************************************************************************
void testroundrects() {
int color = 100;
int i;
int x = 0;
int y = 0;
int w = width();
int h = height();
fillScreen(BLACK);
for(i = 0 ; i <= 24; i++) {
drawRoundRect(x, y, w, h, 5, color);
x+=2;
y+=3;
w-=4;
h-=6;
color+=1100;
}
}
//*****************************************************************************
void testlines(unsigned int color) {
unsigned int x;
unsigned int y;
fillScreen(BLACK);
for (x=0; x < width()-1; x+=6) {
drawLine(0, 0, x, height()-1, color);
}
delay(10);
for (y=0; y < height()-1; y+=6) {
drawLine(0, 0, width()-1, y, color);
}
delay(100);
fillScreen(BLACK);
for (x=0; x < width()-1; x+=6) {
drawLine(width()-1, 0, x, height()-1, color);
}
delay(100);
for (y=0; y < height()-1; y+=6) {
drawLine(width()-1, 0, 0, y, color);
}
delay(100);
fillScreen(BLACK);
for (x=0; x < width()-1; x+=6) {
drawLine(0, height()-1, x, 0, color);
}
delay(100);
for (y=0; y < height()-1; y+=6) {
drawLine(0, height()-1, width()-1, y, color);
}
delay(100);
fillScreen(BLACK);
for (x=0; x < width()-1; x+=6) {
drawLine(width()-1, height()-1, x, 0, color);
}
delay(100);
for (y=0; y < height()-1; y+=6) {
drawLine(width()-1, height()-1, 0, y, color);
}
delay(100);
}
//*****************************************************************************
void lcdTestPattern(void)
{
unsigned int i,j;
goTo(0, 0);
for(i=0;i<128;i++)
{
for(j=0;j<128;j++)
{
if(i<16){writeData(RED>>8); writeData((unsigned char) RED);}
else if(i<32) {writeData(YELLOW>>8);writeData((unsigned char) YELLOW);}
else if(i<48){writeData(GREEN>>8);writeData((unsigned char) GREEN);}
else if(i<64){writeData(CYAN>>8);writeData((unsigned char) CYAN);}
else if(i<80){writeData(BLUE>>8);writeData((unsigned char) BLUE);}
else if(i<96){writeData(MAGENTA>>8);writeData((unsigned char) MAGENTA);}
else if(i<112){writeData(BLACK>>8);writeData((unsigned char) BLACK);}
else {writeData(WHITE>>8); writeData((unsigned char) WHITE);}
}
}
}
/**************************************************************************/
void lcdTestPattern2(void)
{
unsigned int i,j;
goTo(0, 0);
for(i=0;i<128;i++)
{
for(j=0;j<128;j++)
{
if(j<16){writeData(RED>>8); writeData((unsigned char) RED);}
else if(j<32) {writeData(YELLOW>>8);writeData((unsigned char) YELLOW);}
else if(j<48){writeData(GREEN>>8);writeData((unsigned char) GREEN);}
else if(j<64){writeData(CYAN>>8);writeData((unsigned char) CYAN);}
else if(j<80){writeData(BLUE>>8);writeData((unsigned char) BLUE);}
else if(j<96){writeData(MAGENTA>>8);writeData((unsigned char) MAGENTA);}
else if(j<112){writeData(BLACK>>8);writeData((unsigned char) BLACK);}
else {writeData(WHITE>>8);writeData((unsigned char) WHITE);}
}
}
}
/**************************************************************************/