-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdemo.c
791 lines (661 loc) · 20.1 KB
/
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include "ili9340.h"
#include "tjpgd3/decode_jpeg.h"
#include "pngle/decode_png.h"
#define JAPANESE 0
#define _DEBUG_ 0
#define _TEST_ 0
//When you'd like to wait by a keyboard entries, enable this line.
//#define WAIT inputKey()
//When you'd like to wait in the waiting time, enable this line.
#define WAIT sleep(5)
void inputKey() {
char ch;
printf("Hit any key");
scanf("%c",&ch);
}
int ReadTFTConfig(char *path, int *width, int *height, int *offsetx, int *offsety) {
FILE *fp;
char buff[128];
//printf("path=%s\n",path);
fp = fopen(path,"r");
if(fp == NULL) return 0;
while (fgets(buff,128,fp) != NULL) {
//printf("buf=%s\n",buff);
//printf("buff[0]=%x\n",buff[0]);
if (buff[0] == '#') continue;
if (buff[0] == 0x0a) continue;
if (strncmp(buff, "width=", 6) == 0) {
sscanf(buff, "width=%d height=%d",width,height);
if(_DEBUG_)printf("width=%d height=%d\n",*width,*height);
} else if (strncmp(buff, "offsetx=", 8) == 0) {
sscanf(buff, "offsetx=%d",offsetx);
if(_DEBUG_)printf("offsetx=%d\n",*offsetx);
} else if (strncmp(buff, "offsety=", 8) == 0) {
sscanf(buff, "offsety=%d",offsety);
if(_DEBUG_)printf("offsety=%d\n",*offsety);
}
}
fclose(fp);
return 1;
}
time_t elapsedTime(struct timeval startTime, struct timeval endTime) {
time_t diffsec = difftime(endTime.tv_sec, startTime.tv_sec);
suseconds_t diffsub = endTime.tv_usec - startTime.tv_usec;
//printf("diffsec=%ld diffsub=%ld\n",diffsec, diffsub);
if(diffsub < 0) {
diffsec--;
diffsub = (endTime.tv_usec+1000000) - startTime.tv_usec;
}
uint16_t diffmsec = diffsub / 1000;
time_t diff = (diffsec * 1000) + diffmsec;
return diff;
}
time_t ColorBarTest(int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
uint16_t y1 = height/3;
uint16_t y2 = (height/3)*2;
lcdDrawFillRect(0, 0, width-1, y1-1, RED);
lcdDrawFillRect(0, y1-1, width-1, y2-1, GREEN);
lcdDrawFillRect(0, y2-1, width-1, height-1, BLUE);
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t ArrowTest(FontxFile *fx, int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
// get font width & height
uint8_t buffer[FontxGlyphBufSize];
uint8_t fontWidth;
uint8_t fontHeight;
GetFontx(fx, 0, buffer, &fontWidth, &fontHeight);
if(_DEBUG_)printf("fontWidth=%d fontHeight=%d\n",fontWidth,fontHeight);
uint16_t xpos;
uint16_t ypos;
int stlen;
uint16_t color;
//lcdFillScreen(WHITE);
lcdFillScreen(BLACK);
lcdSetFontDirection(0);
color = RED;
uint8_t ascii[10];
lcdDrawFillArrow(10, 10, 0, 0, 5, color);
strcpy((char *)ascii, "0,0");
lcdDrawUTF8String(fx, 0, 20, ascii, color);
color = GREEN;
lcdDrawFillArrow(width-11, 10, width-1, 0, 5, color);
sprintf((char *)ascii, "%d,0",width-1);
stlen = strlen((char *)ascii);
xpos = (width-1) - (fontWidth*stlen);
lcdDrawUTF8String(fx, xpos, 20, ascii, color);
color = GRAY;
lcdDrawFillArrow(10, height-11, 0, height-1, 5, color);
sprintf((char *)ascii, "0,%d",height-1);
ypos = (height-11) - (fontHeight) - 5;
lcdDrawUTF8String(fx, 0, ypos, ascii, color);
color = CYAN;
lcdDrawFillArrow(width-11, height-11, width-1, height-1, 5, color);
sprintf((char *)ascii, "%d,%d",width-1, height-1);
stlen = strlen((char *)ascii);
xpos = (width-1) - (fontWidth*stlen);
lcdDrawUTF8String(fx, xpos, ypos, ascii, color);
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t DirectionTest(FontxFile *fx, int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
// get font width & height
uint8_t buffer[FontxGlyphBufSize];
uint8_t fontWidth;
uint8_t fontHeight;
GetFontx(fx, 0, buffer, &fontWidth, &fontHeight);
if(_DEBUG_)printf("fontWidth=%d fontHeight=%d\n",fontWidth,fontHeight);
uint16_t color;
lcdFillScreen(BLACK);
uint8_t ascii[20];
color = RED;
strcpy((char *)ascii, "Direction=0");
lcdSetFontDirection(DIRECTION0);
lcdDrawUTF8String(fx, 0, height-fontHeight-1, ascii, color);
color = BLUE;
strcpy((char *)ascii, "Direction=180");
lcdSetFontDirection(DIRECTION180);
lcdDrawUTF8String(fx, width-1, fontHeight-1, ascii, color);
color = CYAN;
strcpy((char *)ascii, "Direction=90");
lcdSetFontDirection(DIRECTION90);
lcdDrawUTF8String(fx, width-fontHeight-1, height-1, ascii, color);
color = GREEN;
strcpy((char *)ascii, "Direction=270");
lcdSetFontDirection(DIRECTION270);
lcdDrawUTF8String(fx, fontHeight-1, 0, ascii, color);
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t HorizontalTest(FontxFile *fx, int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
// get font width & height
uint8_t buffer[FontxGlyphBufSize];
uint8_t fontWidth;
uint8_t fontHeight;
GetFontx(fx, 0, buffer, &fontWidth, &fontHeight);
if(_DEBUG_)printf("fontWidth=%d fontHeight=%d\n",fontWidth,fontHeight);
uint16_t color;
lcdFillScreen(BLACK);
uint8_t ascii[20];
color = RED;
strcpy((char *)ascii, "Direction=0");
lcdSetFontDirection(DIRECTION0);
uint16_t ypos = height - fontHeight - 1;
lcdDrawUTF8String(fx, 0, ypos, ascii, color);
lcdSetFontUnderLine(RED);
ypos = ypos - fontHeight;
lcdDrawUTF8String(fx, 0, ypos, ascii, color);
lcdUnsetFontUnderLine();
lcdSetFontFill(GREEN);
ypos = ypos - fontHeight;
ypos = ypos - fontHeight;
lcdDrawUTF8String(fx, 0, ypos, ascii, color);
lcdSetFontUnderLine(RED);
ypos = ypos - fontHeight;
lcdDrawUTF8String(fx, 0, ypos, ascii, color);
lcdUnsetFontFill();
lcdUnsetFontUnderLine();
color = BLUE;
strcpy((char *)ascii, "Direction=180");
lcdSetFontDirection(DIRECTION180);
ypos = fontHeight - 1;
lcdDrawUTF8String(fx, width-1, ypos, ascii, color);
lcdSetFontUnderLine(BLUE);
ypos = ypos + fontHeight;
lcdDrawUTF8String(fx, width-1, ypos, ascii, color);
lcdUnsetFontUnderLine();
lcdSetFontFill(YELLOW);
ypos = ypos + fontHeight;
ypos = ypos + fontHeight;
lcdDrawUTF8String(fx, width-1, ypos, ascii, color);
lcdSetFontUnderLine(BLUE);
ypos = ypos + fontHeight;
lcdDrawUTF8String(fx, width-1, ypos, ascii, color);
lcdUnsetFontFill();
lcdUnsetFontUnderLine();
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t VerticalTest(FontxFile *fx, int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
// get font width & height
uint8_t buffer[FontxGlyphBufSize];
uint8_t fontWidth;
uint8_t fontHeight;
GetFontx(fx, 0, buffer, &fontWidth, &fontHeight);
if(_DEBUG_)printf("fontWidth=%d fontHeight=%d\n",fontWidth,fontHeight);
uint16_t color;
lcdFillScreen(BLACK);
uint8_t ascii[20];
color = RED;
strcpy((char *)ascii, "Direction=90");
lcdSetFontDirection(DIRECTION90);
uint16_t xpos = width - fontHeight - 1;
lcdDrawUTF8String(fx, xpos, height-1, ascii, color);
lcdSetFontUnderLine(RED);
xpos = xpos - fontHeight;
lcdDrawUTF8String(fx, xpos, height-1, ascii, color);
lcdUnsetFontUnderLine();
lcdSetFontFill(GREEN);
xpos = xpos - fontHeight;
xpos = xpos - fontHeight;
lcdDrawUTF8String(fx, xpos, height-1, ascii, color);
lcdSetFontUnderLine(RED);
xpos = xpos - fontHeight;
lcdDrawUTF8String(fx, xpos, height-1, ascii, color);
lcdUnsetFontFill();
lcdUnsetFontUnderLine();
color = BLUE;
strcpy((char *)ascii, "Direction=270");
lcdSetFontDirection(DIRECTION270);
xpos = fontHeight -1;
lcdDrawUTF8String(fx, xpos, 0, ascii, color);
lcdSetFontUnderLine(BLUE);
xpos = xpos + fontHeight;
lcdDrawUTF8String(fx, xpos, 0, ascii, color);
lcdUnsetFontUnderLine();
lcdSetFontFill(YELLOW);
xpos = xpos + fontHeight;
xpos = xpos + fontHeight;
lcdDrawUTF8String(fx, xpos, 0, ascii, color);
lcdSetFontUnderLine(BLUE);
xpos = xpos + fontHeight;
lcdDrawUTF8String(fx, xpos, 0, ascii, color);
lcdUnsetFontFill();
lcdUnsetFontUnderLine();
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t LineTest(int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
uint16_t color;
lcdFillScreen(BLACK);
color = RED;
uint16_t xpos;
uint16_t ypos;
for(ypos=0;ypos<height;ypos=ypos+10) {
lcdDrawLine(0, ypos, width, ypos, color);
}
for(xpos=0;xpos<width;xpos=xpos+10) {
lcdDrawLine(xpos, 0, xpos, height, color);
}
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t CircleTest(int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
uint16_t color;
lcdFillScreen(BLACK);
color = GRAY;
uint16_t xpos = width/2;
uint16_t ypos = height/2;
int i;
for(i=5;i<height;i=i+5) {
lcdDrawCircle(xpos, ypos, i, color);
}
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t RoundRectTest(int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
uint16_t color;
uint16_t limit = width;
if (width > height) limit = height;
lcdFillScreen(BLACK);
color = BLUE;
int i;
for(i=5;i<limit;i=i+5) {
if (i > (limit-i-1) ) break;
lcdDrawRoundRect(i, i, (width-i-1), (height-i-1), 10, color);
}
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t FillRectTest(int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
uint16_t color;
lcdFillScreen(CYAN);
uint16_t red;
uint16_t green;
uint16_t blue;
srand( (unsigned int)time( NULL ) );
int i;
for(i=1;i<100;i++) {
red=rand()%255;
green=rand()%255;
blue=rand()%255;
color=rgb565(red, green, blue);
uint16_t xpos=rand()%width;
uint16_t ypos=rand()%height;
uint16_t size=rand()%(width/5);
lcdDrawFillRect(xpos, ypos, xpos+size, ypos+size, color);
}
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t ColorTest(int width, int height) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
uint16_t color;
lcdFillScreen(WHITE);
color = RED;
uint16_t delta = height/16;
uint16_t ypos = 0;
int i;
for(i=0;i<16;i++) {
lcdDrawFillRect(0, ypos, width-1, ypos+delta, color);
color = color >> 1;
ypos = ypos + delta;
}
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t JPEGTest(char * file, int width, int height, bool reverse) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
// open JPEG file
FILE* fp = fopen(file, "rb");
if (fp == NULL) {
printf("File not found [%s]\n", file);
return 0;
}
fclose(fp);
lcdFillScreen(BLACK);
int _width = width;
if (width > 240) _width = 240;
int _height = height;
if (height > 320) _height = 320;
pixel_jpeg **pixels;
uint16_t imageWidth;
uint16_t imageHeight;
int err = decode_jpeg(&pixels, file, _width, _height, &imageWidth, &imageHeight);
if (err == 0) {
//printf("imageWidth=%d imageHeight=%d\n", imageWidth, imageHeight);
uint16_t jpegWidth = width;
uint16_t offsetX = 0;
if (width > imageWidth) {
jpegWidth = imageWidth;
offsetX = (width - imageWidth) / 2;
}
//printf("jpegWidth=%d offsetX=%d\n", jpegWidth, offsetX);
uint16_t jpegHeight = height;
uint16_t offsetY = 0;
if (height > imageHeight) {
jpegHeight = imageHeight;
offsetY = (height - imageHeight) / 2;
}
//printf("jpegHeight=%d offsetY=%d\n", jpegHeight, offsetY);
int ypos;
if (reverse) {
ypos = offsetY;
} else {
ypos = (height-1) - offsetY;
}
for(int y = 0; y < jpegHeight; y++){
for(int x = 0;x < jpegWidth; x++){
uint16_t color = pixels[y][x];
//lcdDrawPixel(x+offsetX, y+offsetY, color);
if (reverse) {
lcdDrawPixel(offsetX+jpegWidth-x, ypos, color);
} else {
lcdDrawPixel(offsetX+x, ypos, color);
}
}
if (reverse) {
ypos++;
} else {
ypos--;
}
}
release_jpeg(&pixels, _width, _height);
//printf("Finish\n");
} else {
printf("%s decode_jpeg err=%d imageWidth=%d imageHeight=%d\n", __func__, err, imageWidth, imageHeight);
}
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
time_t PNGTest(char * file, int width, int height, bool reverse) {
struct timeval startTime, endTime;
gettimeofday(&startTime, NULL);
// open PNG file
FILE* fp = fopen(file, "rb");
if (fp == NULL) {
printf("File not found [%s]\n", file);
return 0;
}
lcdFillScreen(BLACK);
int _width = width;
if (width > 240) _width = 240;
int _height = height;
if (height > 320) _height = 320;
char buf[1024];
size_t remain = 0;
int len;
pngle_t *pngle = pngle_new(_width, _height);
pngle_set_init_callback(pngle, png_init);
pngle_set_draw_callback(pngle, png_draw);
pngle_set_done_callback(pngle, png_finish);
double display_gamma = 2.2;
pngle_set_display_gamma(pngle, display_gamma);
while (!feof(fp)) {
if (remain >= sizeof(buf)) {
printf("ERROR: Buffer exceeded\n");
fclose(fp);
return 0;
}
len = fread(buf + remain, 1, sizeof(buf) - remain, fp);
if (len <= 0) {
//printf("EOF\n");
break;
}
int fed = pngle_feed(pngle, buf, remain + len);
if (fed < 0) {
printf("ERROR: %s\n", pngle_error(pngle));
fclose(fp);
return 0;
}
remain = remain + len - fed;
if (remain > 0) memmove(buf, buf + fed, remain);
}
fclose(fp);
uint16_t pngWidth = width;
uint16_t offsetX = 0;
if (width > pngle->imageWidth) {
pngWidth = pngle->imageWidth;
offsetX = (width - pngle->imageWidth) / 2;
}
//printf("pngWidth=%d offsetX=%d\n", pngWidth, offsetX);
uint16_t pngHeight = height;
uint16_t offsetY = 0;
if (height > pngle->imageHeight) {
pngHeight = pngle->imageHeight;
offsetY = (height - pngle->imageHeight) / 2;
}
//printf("pngHeight=%d offsetY=%d\n", pngHeight, offsetY);
int ypos;
if (reverse) {
ypos = offsetY;
} else {
ypos = (height-1) - offsetY;
}
for(int y = 0; y < pngHeight; y++){
for(int x = 0;x < pngWidth; x++){
pixel_png pixel = pngle->pixels[y][x];
uint16_t color = rgb565(pixel.red, pixel.green, pixel.blue);
if (reverse) {
lcdDrawPixel(offsetX+pngWidth-x, ypos, color);
} else {
lcdDrawPixel(offsetX+x, ypos, color);
}
}
if (reverse) {
ypos++;
} else {
ypos--;
}
}
pngle_destroy(pngle, _width, _height);
gettimeofday(&endTime, NULL);
time_t diff = elapsedTime(startTime, endTime);
printf("%s elapsed time[ms]=%ld\n",__func__, diff);
return diff;
}
int main(int argc, char **argv)
{
int i;
int screenWidth = 0;
int screenHeight = 0;
int offsetx = 0;
int offsety = 0;
char dir[128];
char cpath[128];
if(_DEBUG_) printf("argv[0]=%s\n",argv[0]);
strcpy(dir, argv[0]);
for(i=strlen(dir);i>0;i--) {
if (dir[i-1] == '/') {
dir[i] = 0;
break;
} // end if
} // end for
if(_DEBUG_)printf("dir=%s\n",dir);
strcpy(cpath,dir);
strcat(cpath,"tft.conf");
if(_DEBUG_)printf("cpath=%s\n",cpath);
if (ReadTFTConfig(cpath, &screenWidth, &screenHeight, &offsetx, &offsety) == 0) {
printf("%s Not found\n",cpath);
return 0;
}
if(_DEBUG_)printf("ReadTFTConfig:screenWidth=%d height=%d\n",screenWidth, screenHeight);
printf("Your TFT resolution is %d x %d.\n",screenWidth, screenHeight);
printf("Your TFT offsetx is %d.\n",offsetx);
printf("Your TFT offsety is %d.\n",offsety);
// You can change font file
FontxFile fx32G[2];
FontxFile fx24G[2];
FontxFile fx16G[2];
Fontx_init(fx32G,"./fontx/ILGH32XB.FNT","./fontx/ILGZ32XB.FNT"); // 16x32Dot Gothic
Fontx_init(fx24G,"./fontx/ILGH24XB.FNT","./fontx/ILGZ24XB.FNT"); // 12x24Dot Gothic
Fontx_init(fx16G,"./fontx/ILGH16XB.FNT","./fontx/ILGZ16XB.FNT"); // 8x16Dot Gothic
FontxFile fx32M[2];
FontxFile fx24M[2];
FontxFile fx16M[2];
Fontx_init(fx32M,"./fontx/ILMH32XF.FNT","./fontx/ILMZ32XF.FNT"); // 16x32Dot Mincyo
Fontx_init(fx24M,"./fontx/ILMH24XF.FNT","./fontx/ILMZ24XF.FNT"); // 12x24Dot Mincyo
Fontx_init(fx16M,"./fontx/ILMH16XB.FNT","./fontx/ILMZ16XF.FNT"); // 8x16Dot Mincyo
lcdInit(screenWidth, screenHeight, offsetx, offsety);
lcdReset();
lcdSetup();
#if _TEST_
JPEGTest("./images/RaspberryPi_240x240.jpg", screenWidth, screenHeight, false);
WAIT;
JPEGTest("./images/RaspberryPi_240x240.jpg", screenWidth, screenHeight, true);
WAIT;
PNGTest("./images/Ubuntu_log.png", screenWidth, screenHeight, false);
WAIT;
PNGTest("./images/Ubuntu_log.png", screenWidth, screenHeight, true);
return 0;
#endif
ColorBarTest(screenWidth, screenHeight);
WAIT;
if (screenWidth >= 240) {
ArrowTest(fx24G, screenWidth, screenHeight);
} else {
ArrowTest(fx16G, screenWidth, screenHeight);
}
WAIT;
LineTest(screenWidth, screenHeight);
WAIT;
CircleTest(screenWidth, screenHeight);
WAIT;
RoundRectTest(screenWidth, screenHeight);
WAIT;
if (screenWidth >= 240) {
DirectionTest(fx24G, screenWidth, screenHeight);
} else {
DirectionTest(fx16G, screenWidth, screenHeight);
}
WAIT;
if (screenHeight >= 320) {
HorizontalTest(fx24G, screenWidth, screenHeight);
} else {
HorizontalTest(fx16G, screenWidth, screenHeight);
}
WAIT;
if (screenWidth >= 240) {
VerticalTest(fx24G, screenWidth, screenHeight);
} else {
VerticalTest(fx16G, screenWidth, screenHeight);
}
WAIT;
FillRectTest(screenWidth, screenHeight);
WAIT;
ColorTest(screenWidth, screenHeight);
WAIT;
JPEGTest("./images/RaspberryPi_240x240.jpg", screenWidth, screenHeight, false);
WAIT;
JPEGTest("./images/RaspberryPi_240x240.jpg", screenWidth, screenHeight, true);
WAIT;
PNGTest("./images/Ubuntu_log.png", screenWidth, screenHeight, false);
WAIT;
PNGTest("./images/Ubuntu_log.png", screenWidth, screenHeight, true);
WAIT;
// Multi Font Test
uint16_t color;
unsigned char utf8[64];;
uint16_t xpos = 0;
uint16_t ypos = screenHeight-16-1;
int margin = 10;
lcdFillScreen( BLACK);
color = WHITE;
lcdSetFontDirection(DIRECTION0);
int xd = 0;
int yd = 1;
if(screenWidth < screenHeight) {
lcdSetFontDirection(DIRECTION90);
xpos = screenWidth-16-1;
xd = 1;
yd = 0;
}
strncpy((char *)utf8, "16Dot Gothic Font", sizeof(utf8));
if(JAPANESE)strncpy((char *)utf8, "16ドットゴシック", sizeof(utf8));
lcdDrawUTF8String(fx16G, xpos, ypos, utf8, color);
xpos = xpos - (24 * xd) - (margin * xd);
ypos = ypos - (16 * yd) - (margin * yd);
strncpy((char *)utf8, "24Dot Gothic Font", sizeof(utf8));
if(JAPANESE)strncpy((char *)utf8, "24ドットゴシック", sizeof(utf8));
lcdDrawUTF8String(fx24G, xpos, ypos, utf8, color);
xpos = xpos - (32 * xd) - (margin * xd);
ypos = ypos - (24 * yd) - (margin * yd);
if (screenWidth >= 240) {
strncpy((char *)utf8, "32Dot Gothic Font", sizeof(utf8));
if(JAPANESE)strncpy((char *)utf8, "32ドットゴシック", sizeof(utf8));
lcdDrawUTF8String(fx32G, xpos, ypos, utf8, color);
xpos = xpos - (32 * xd) - (margin * xd);
ypos = ypos - (32 * yd) - (margin * yd);
}
//xpos = xpos - (10 * xd);
ypos = ypos - (10 * yd);
strncpy((char *)utf8, "16Dot Mincyo Font", sizeof(utf8));
if(JAPANESE)strncpy((char *)utf8, "16ドット明朝", sizeof(utf8));
lcdDrawUTF8String(fx16M, xpos, ypos, utf8, color);
xpos = xpos - (24 * xd) - (margin * xd);
ypos = ypos - (16 * yd) - (margin * yd);
strncpy((char *)utf8, "24Dot Mincyo Font", sizeof(utf8));
if(JAPANESE)strncpy((char *)utf8, "24ドット明朝", sizeof(utf8));
lcdDrawUTF8String(fx24M, xpos, ypos, utf8, color);
if (screenWidth >= 240) {
xpos = xpos - (32 * xd) - (margin * xd);
ypos = ypos - (24 * yd) - (margin * yd);
strncpy((char *)utf8, "32Dot Mincyo Font", sizeof(utf8));
if(JAPANESE)strncpy((char *)utf8, "32ドット明朝", sizeof(utf8));
lcdDrawUTF8String(fx32M, xpos, ypos, utf8, color);
}
lcdSetFontDirection(0);
WAIT;
//lcdDisplayOff();
return 0;
}