-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathssd1289_demo.c
316 lines (251 loc) · 7.75 KB
/
ssd1289_demo.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#include "leds.h"
#include "buttons.h"
#include "random.h" // small, pseudo random
#include "ssd1289.h"
#include "image_amigawbfloppy.h" // amiga workbench floppy picture
#include "image_windows101.h" // windows 1.01 bootsplash
#include "image_windows31.h" // windows 3.1 bootsplash
#include "image_monkeyisland.h" // scene from monkey island
void ssd1289_demo(void);
void demo_screen0(); // main demo screen
void demo_screen1(); // text console demo
void demo_screen2(); // images demo
void demo_screen3(); // ellipse demo
void demo_blacklight0(); // backlight flash/fade demo
void ssd1289_demo(void) {
for(;;) {
;
}
}
void dos_colors() {
int i;
ssd1289_clear();
ssd1289_set_font(FONT_XGA_8x14);
ssd1289_set_font_color(DOS_COLOR_5, RGB_COL_BLACK);
ssd1289_set_transparency(FALSE);
ssd1289_set_text_cursor(0, 0);
ssd1289_putc(0xC9); // top left corner
for(i = 0; i < 38; i++)
ssd1289_putc(0xCD); // top border
ssd1289_putc(0xBB); // top right corner
ssd1289_set_text_cursor(0, 16);
ssd1289_putc(0xC8); // bottom left corner
for(i = 0; i < 38; i++)
ssd1289_putc(0xCD); // bottom border
ssd1289_putc(0xBC); // bottom right corner
ssd1289_set_text_cursor(7, 0);
ssd1289_set_font_color(RGB_COL_CYAN, RGB_COL_BLACK);
ssd1289_puts(" DOS//IBM VGA 8x14 charset ");
ssd1289_set_font_color(RGB_COL_YELLOW, RGB_COL_BLACK);
ssd1289_set_text_cursor(6, 0);
ssd1289_putc('[');
ssd1289_set_text_cursor(34, 0);
ssd1289_putc(']');
ssd1289_set_font_color(DOS_COLOR_5, DOS_COLOR_0);
for(i = 1; i < 16; i++) {
ssd1289_set_text_cursor(0, i);
ssd1289_putc(0xBA);
ssd1289_set_text_cursor(39, i);
ssd1289_putc(0xBA);
}
ssd1289_set_font_color(DOS_COLOR_7, DOS_COLOR_0);
ssd1289_set_text_cursor(3, 2);
ssd1289_ignore_control_chars(1);
int x, y;
i = 0;
for(y = 0; y < 8; y++) {
ssd1289_set_text_cursor(4, 2+y);
for(x = 0; x < 32; x++) {
ssd1289_putc(i);
i++;
}
}
ssd1289_ignore_control_chars(0);
uint16_t colors[16] = { DOS_COLOR_0, DOS_COLOR_1, DOS_COLOR_2, DOS_COLOR_3, DOS_COLOR_4,
DOS_COLOR_5, DOS_COLOR_6, DOS_COLOR_7, DOS_COLOR_8, DOS_COLOR_9,
DOS_COLOR_10, DOS_COLOR_11, DOS_COLOR_12, DOS_COLOR_13,
DOS_COLOR_14, DOS_COLOR_15 };
for(i = 0; i < 8; i++) {
x = 45+(i*30);
y = 152;
ssd1289_rect (x-1, y-1, x+20, y+26, RGB_COL_YELLOW);
ssd1289_fill_rect(x, y, x+20, y+25, colors[i]);
}
for(i = 0; i < 8; i++) {
x = 45+(i*30);
y = 188;
ssd1289_rect (x-1, y-1, x+20, y+26, RGB_COL_YELLOW);
ssd1289_fill_rect(x, y, x+20, y+25, colors[i+7]);
}
return;
}
void demo_screen4() {
int r0, r1, x, y;
uint16_t color;
ssd1289_clear();
ssd1289_set_text_cursor(0,0);
ssd1289_set_font_color(RGB_COL_YELLOW, RGB_COL_BLACK);
ssd1289_puts("test");
while(btna_hit()) {
asm("nop");
}
ssd1289_puts("text");
for(;;) {
asm("nop");
}
}
void demo_screen3() {
int r0, r1, x, y;
uint16_t color;
while(1) {
x = (random_kiss32()%240);
y = (random_kiss32()%320);
r0 = (random_kiss32()%80);
r1 = (random_kiss32()%80);
color = (uint16_t)(random_kiss32()&0xfffff);
ssd1289_ellipse(x, y, r0, r1, color);
}
return;
}
void demo_screen0() {
int xpos, ypos, rad, x, x2, y, y2, i;
uint16_t color;
ssd1289_clear();
ssd1289_set_text_cursor(0, 0);
ssd1289_set_font_color(RGB_COL_CYAN, RGB_COL_BLACK);
ssd1289_puts(" > SSD1289 DRIVER DEMO <");
ssd1289_rect(5, 20, 239-5, 319-5, RGB_COL_CYAN); // big frame
ssd1289_rect(10, 25, 60, 75, RGB_COL_CYAN); // random pixel frame
ssd1289_rect(65, 25, 239-10, 75, RGB_COL_WHITE); // random lines frame
ssd1289_rect(10, 80, 90, 130, RGB_COL_RED); // fill rect frame
ssd1289_rect(95, 80, 239-10, 130, RGB_COL_YELLOW); // rect frame
ssd1289_rect(120, 190, 239-10, 319-10, RGB_COL_GREEN); // image frame
ssd1289_fill_rect(10, 190, 129-10-5, 319-20-60, RGB_COL_RED); // text "press btn a" frame
ssd1289_rect(10, 320-80+5, 114, 309, RGB_COL_YELLOW); // circle frame
ssd1289_rect(10, 135, 239-10, 185, RGB_COL_MAGENTA); // text demo
ssd1289_print_image(&amiga_wb_floppy, 130, 200);
// put 1000 random pixels
//xDelay = 4 / portTICK_RATE_MS;
for(i = 0; i < 700; i++) {
x = (random_xorshift32()%49)+11;
y = (random_xorshift32()%49)+26;
color = random_xorshift32();
ssd1289_setpx(x, y, color);
//vTaskDelay(xDelay);
}
//xDelay = 5 / portTICK_RATE_MS;
for(i = 0; i < 80; i++) {
x = (random_xorshift32()%165)+66;
y = (random_xorshift32()%49)+26;
x2 = (random_xorshift32()%165)+66;
y2 = (random_xorshift32()%49)+26;
color = random_xorshift32();
ssd1289_line(x, y, x2, y2, color);
//vTaskDelay(xDelay);
}
for(i = 0; i < 400; i++) {
x = (random_xorshift32()%80)+11;
y = (random_xorshift32()%49)+81;
x2 = (random_xorshift32()%80)+11;
y2 = (random_xorshift32()%49)+81;
color = random_xorshift32();
ssd1289_fill_rect(x, y, x2, y2, color);
//vTaskDelay(xDelay);
}
for(i = 0; i < 400; i++) {
x = (random_xorshift32()%130)+96;
y = (random_xorshift32()%49)+81;
x2 = (random_xorshift32()%130)+96;
y2 = (random_xorshift32()%49)+81;
color = random_xorshift32();
ssd1289_rect(x, y, x2, y2, color);
//vTaskDelay(xDelay);
}
// text demo
ssd1289_set_font(FONT_LINUX_8x16);
ssd1289_set_font_color(RGB_COL_WHITE, RGB_COL_BLACK);
ssd1289_puts_at(15, 139, "Linux-Fonts: Std 8x16");
ssd1289_set_font(FONT_LINUX_8x8);
ssd1289_set_font_color(RGB_COL_WHITE, RGB_COL_BLACK);
ssd1289_puts_at(15, 156, "Small 8x8 Font");
ssd1289_set_font(FONT_LINUX_ACORN_8x8);
ssd1289_set_font_color(RGB_COL_WHITE, RGB_COL_BLACK);
ssd1289_puts_at(15, 165, "Small 8x8 Font \"Acorn\"");
ssd1289_set_font(FONT_LINUX_PEARL_8x8);
ssd1289_set_font_color(RGB_COL_WHITE, RGB_COL_BLACK);
ssd1289_puts_at(15, 174, "Small 8x8 Font \"Pearl\"");
ssd1289_set_font(FONT_LINUX_ACORN_8x8);
ssd1289_set_font_color(RGB_COL_WHITE, RGB_COL_RED);
ssd1289_puts_at(15, 200, "Press btn A!");
ssd1289_puts_at(15, 210, "Press btn A!");
ssd1289_puts_at(15, 220, "Press btn A!");
xpos = 42;
ypos = 278;
for(rad = 1; rad <= 30; rad++) {
ssd1289_circle(xpos, ypos, rad, random_kiss32());
ssd1289_circle(xpos+41, ypos, rad, random_kiss32());
}
}
void demo_screen1() {
int l;
int fg, bg;
ssd1289_fill_screen(RGB_COL_BLUE);
ssd1289_set_font(FONT_LINUX_ACORN_8x8);
ssd1289_set_font_color(RGB_COL_WHITE, RGB_COL_BLUE);
ssd1289_set_cursor(0, 0);
ssd1289_set_cursor(0,0);
ssd1289_puts("\rSimple text-console with automatic line-wrap.\n\nCharset:\n");
ssd1289_set_cursor(0, 5);
for(l = 0x20; l < 0xff; l++) {
//fg = random_kiss32();
//bg = random_kiss32();
//ssd1289_set_font_color(fg, bg);
ssd1289_putc(l);
}
ssd1289_inc_cursor_y();
ssd1289_inc_cursor_y();
ssd1289_puts("30x35 chars on 240x320");
ssd1289_inc_cursor_y();
ssd1289_inc_cursor_y();
for(l = 0x20; l < 0xff; l++) {
fg = random_kiss32();
bg = random_kiss32();
ssd1289_set_font_color(fg, bg);
ssd1289_putc(l);
ssd1289_putc(l);
}
for(l = 0x20; l < 0xff; l++) {
fg = random_kiss32();
bg = random_kiss32();
ssd1289_set_font_color(fg, bg);
ssd1289_putc(l);
}
return;
}
void demo_blacklight0() {
int bl;
int loops;
for(loops = 0; loops < 4; loops++) {
for(bl = 0; bl <= 100; bl++) {
ssd1289_bl_set(bl);
vTaskDelay(3);
}
for(bl = 100; bl > 0; bl--) {
ssd1289_bl_set(bl);
vTaskDelay(3);
}
}
for(loops = 0; loops < 20; loops++) {
ssd1289_bl_set(100);
vTaskDelay(50);
ssd1289_bl_set(0);
vTaskDelay(50);
}
ssd1289_bl_set(100);
return;
}
void demo_screen2() {
//ssd1289_print_image(&win31, 0, 0);
//ssd1289_print_image(&mi, 0, 0);
return;
}