@@ -463,19 +463,20 @@ ili9341_read_memory_continue(int len, uint16_t* out)
463
463
ili9341_read_memory_raw (0x3E , len , out );
464
464
}
465
465
466
+ #if !defined(ST7796S )
466
467
void
467
468
ili9341_drawchar_5x7 (uint8_t ch , int x , int y , uint16_t fg , uint16_t bg )
468
469
{
469
470
#if defined(ILI9488 )
470
471
ili9341_drawchar_size (ch , x , y , fg , bg , 1 );
471
472
#else
472
473
uint16_t * buf = spi_buffer ;
473
- uint8_t bits ;
474
+ uint16_t bits ;
474
475
int c , r ;
475
476
for (c = 0 ; c < 7 ; c ++ ) {
476
477
bits = x5x7_bits [(ch * 7 ) + c ];
477
478
for (r = 0 ; r < 5 ; r ++ ) {
478
- * buf ++ = (0x80 & bits ) ? fg : bg ;
479
+ * buf ++ = (0x8000 & bits ) ? fg : bg ;
479
480
bits <<= 1 ;
480
481
}
481
482
}
@@ -493,16 +494,25 @@ ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg)
493
494
}
494
495
}
495
496
497
+ void
498
+ ili9341_drawstring_5x7_inv (const char * str , int x , int y , uint16_t fg , uint16_t bg , bool invert )
499
+ {
500
+ if (invert )
501
+ ili9341_drawstring_5x7 (str , x , y , bg , fg );
502
+ else
503
+ ili9341_drawstring_5x7 (str , x , y , fg , bg );
504
+ }
505
+
496
506
void
497
507
ili9341_drawchar_size (uint8_t ch , int x , int y , uint16_t fg , uint16_t bg , uint8_t size )
498
508
{
499
509
uint16_t * buf = spi_buffer ;
500
- uint8_t bits ;
510
+ uint16_t bits ;
501
511
int c , r ;
502
512
for (c = 0 ; c < 7 * size ; c ++ ) {
503
513
bits = x5x7_bits [(ch * 7 ) + (c / size )];
504
514
for (r = 0 ; r < 5 * size ; r ++ ) {
505
- * buf ++ = (0x80 & bits ) ? fg : bg ;
515
+ * buf ++ = (0x8000 & bits ) ? fg : bg ;
506
516
if (r % size == (size - 1 )) {
507
517
bits <<= 1 ;
508
518
}
@@ -521,6 +531,73 @@ ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg,
521
531
}
522
532
}
523
533
534
+ #else
535
+ void
536
+ ili9341_drawchar_7x13 (uint8_t ch , int x , int y , uint16_t fg , uint16_t bg )
537
+ {
538
+ uint16_t * buf = spi_buffer ;
539
+ uint16_t bits ;
540
+ int c , r ;
541
+ for (c = 0 ; c < 13 ; c ++ ) {
542
+ bits = x7x13b_bits [(ch * 13 ) + c ];
543
+ for (r = 0 ; r < 7 ; r ++ ) {
544
+ * buf ++ = (0x8000 & bits ) ? fg : bg ;
545
+ bits <<= 1 ;
546
+ }
547
+ }
548
+ ili9341_bulk (x , y , 7 , 13 );
549
+ }
550
+
551
+ void
552
+ ili9341_drawstring_7x13 (const char * str , int x , int y , uint16_t fg , uint16_t bg )
553
+ {
554
+ while (* str ) {
555
+ ili9341_drawchar_7x13 (* str , x , y , fg , bg );
556
+ x += 7 ;
557
+ str ++ ;
558
+ }
559
+ }
560
+
561
+ void
562
+ ili9341_drawstring_7x13_inv (const char * str , int x , int y , uint16_t fg , uint16_t bg , bool invert )
563
+ {
564
+ if (invert )
565
+ ili9341_drawstring_7x13 (str , x , y , bg , fg );
566
+ else
567
+ ili9341_drawstring_7x13 (str , x , y , fg , bg );
568
+ }
569
+
570
+
571
+ void
572
+ ili9341_drawchar_size (uint8_t ch , int x , int y , uint16_t fg , uint16_t bg , uint8_t size )
573
+ {
574
+ uint16_t * buf = spi_buffer ;
575
+ uint16_t bits ;
576
+ int c , r ;
577
+ for (c = 0 ; c < 13 * size ; c ++ ) {
578
+ bits = x7x13b_bits [(ch * 13 ) + (c / size )];
579
+ for (r = 0 ; r < 7 * size ; r ++ ) {
580
+ * buf ++ = (0x8000 & bits ) ? fg : bg ;
581
+ if (r % size == (size - 1 )) {
582
+ bits <<= 1 ;
583
+ }
584
+ }
585
+ }
586
+ ili9341_bulk (x , y , 7 * size , 13 * size );
587
+ }
588
+
589
+ void
590
+ ili9341_drawstring_size (const char * str , int x , int y , uint16_t fg , uint16_t bg , uint8_t size )
591
+ {
592
+ while (* str ) {
593
+ ili9341_drawchar_size (* str , x , y , fg , bg , size );
594
+ x += 7 * size ;
595
+ str ++ ;
596
+ }
597
+ }
598
+ #endif
599
+
600
+
524
601
#define SWAP (x ,y ) do { int z=x; x = y; y = z; } while(0)
525
602
526
603
void
@@ -605,7 +682,7 @@ ili9341_test(int mode)
605
682
int i ;
606
683
uint16_t x0 , x1 , y0 , y1 ;
607
684
int c ;
608
- int r ;
685
+ // int r;
609
686
switch (mode ) {
610
687
default :
611
688
#if 1
@@ -647,14 +724,14 @@ ili9341_test(int mode)
647
724
ili9341_fill (0 , 0 , LCD_WIDTH , LCD_HEIGHT , 0 );
648
725
x0 = (uint16_t ) my_rand () % LCD_WIDTH ;
649
726
y0 = (uint16_t ) my_rand () % LCD_HEIGHT - 4 ;
650
- if ((x0 >=LCD_WIDTH ) || (y0 >=LCD_HEIGHT ) || ( x0 < 0 ) || ( y0 < 0 ) ) {
727
+ if ((x0 >=LCD_WIDTH ) || (y0 >=LCD_HEIGHT )) {
651
728
return ;
652
729
}
653
- r = (int ) my_rand () % 100 ;
730
+ // r = (int) my_rand() % 100;
654
731
for (i = 0 ; i < 100 ; i ++ ) {
655
732
x1 = (uint16_t ) my_rand () % LCD_WIDTH ;
656
733
y1 = (uint16_t ) my_rand () % LCD_HEIGHT - 4 ;
657
- if ((x1 >=LCD_WIDTH ) || (y1 >=LCD_HEIGHT ) || ( x1 < 0 ) || ( y1 < 0 ) ) {
734
+ if ((x1 >=LCD_WIDTH ) || (y1 >=LCD_HEIGHT )) {
658
735
return ;
659
736
}
660
737
//c = RGB565(255,255,255);
0 commit comments