Skip to content

Commit db39547

Browse files
lovyan03EeeeBin
authored andcommitted
Update to TFT_eSPI latest version 1.4.21 (2019/11/12) . (#192)
1 parent 70d0460 commit db39547

File tree

9 files changed

+233
-143
lines changed

9 files changed

+233
-143
lines changed

src/Fonts/Font16.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
// Font 2
22

3+
// Comment out for £ sign for character 24
4+
#define TFT_ESPI_FONT2_DOLLAR
5+
6+
// The grave ( ` ) diacritical mark will show as a degree ( ° ) symbol
7+
// Comment out next line to return character 0x60 to the grave accent:
8+
#define TFT_ESPI_GRAVE_IS_DEGREE
9+
310
#include <pgmspace.h>
411

512
// Width has been increased by 1 pixel so pixel lengths are calculated correctly
@@ -15,7 +22,11 @@ PROGMEM const unsigned char widtbl_f16[96] = // character width table
1522
8, 4, 8, 8, 7, 10, 8, 8, // char 72 - 79
1623
8, 8, 8, 8, 8, 8, 8, 10, // char 80 - 87
1724
8, 8, 8, 4, 7, 4, 7, 9, // char 88 - 95
18-
4, 7, 7, 7, 7, 7, 6, 7, // char 96 - 103
25+
#ifdef TFT_ESPI_GRAVE_IS_DEGREE
26+
5, 7, 7, 7, 7, 7, 6, 7, // char 96 - 103 0x60 is degree symbol
27+
#else
28+
4, 7, 7, 7, 7, 7, 6, 7, // char 96 - 103 0x60 is grave
29+
#endif
1930
7, 4, 5, 6, 4, 8, 7, 8, // char 104 - 111
2031
7, 8, 6, 6, 5, 7, 8, 8, // char 112 - 119
2132
6, 7, 7, 5, 3, 5, 8, 6 // char 120 - 127
@@ -49,8 +60,13 @@ PROGMEM const unsigned char chr_f16_23[16] = // 1 unsigned char per row
4960

5061
PROGMEM const unsigned char chr_f16_24[16] = // 1 unsigned char per row
5162
{
63+
#ifdef TFT_ESPI_FONT2_DOLLAR
64+
0x00, 0x00, 0x28, 0x38, 0x6C, 0xAA, 0xA8, 0x68, 0x3C, 0x2A, 0xAA, // row 1 - 11
65+
0x6C, 0x38, 0x28, 0x00, 0x00 // row 12 - 16
66+
#else // GBP sign
5267
0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x40, 0x70, 0x40, 0x70, 0x40, // row 1 - 11
5368
0x40, 0xFE, 0x00, 0x00, 0x00 // row 12 - 16
69+
#endif
5470
};
5571

5672
PROGMEM const unsigned char chr_f16_25[16] = // 1 unsigned char per row
@@ -407,8 +423,13 @@ PROGMEM const unsigned char chr_f16_5F[32] = // 1 unsigned chars per row
407423

408424
PROGMEM const unsigned char chr_f16_60[16] = // 1 unsigned char per row
409425
{
410-
0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, // row 1 - 11
426+
#ifdef TFT_ESPI_GRAVE_IS_DEGREE
427+
0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 Degree symbol
428+
0x00, 0x00, 0x00, 0x00, 0x00
429+
#else
430+
0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 Grave accent
411431
0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16
432+
#endif
412433
};
413434

414435
PROGMEM const unsigned char chr_f16_61[16] = // 1 unsigned char per row

src/Fonts/Font7srle.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
PROGMEM const unsigned char widtbl_f7s[96] = // character width table
1313
{
1414
12, 12, 12, 12, 12, 12, 12, 12, // char 32 - 39
15-
12, 12, 12, 12, 12, 17, 12, 12, // char 40 - 47
15+
12, 12, 12, 12, 12, 32, 12, 12, // char 40 - 47
1616
32, 32, 32, 32, 32, 32, 32, 32, // char 48 - 55
1717
32, 32, 12, 12, 12, 12, 12, 12, // char 56 - 63
1818
12, 12, 12, 12, 12, 12, 12, 12, // char 64 - 71
@@ -32,10 +32,12 @@ PROGMEM const unsigned char chr_f7s_20[] =
3232
0x7F, 0x7F, 0x7F, 0x7F, 0x3F
3333
};
3434

35+
// Make - sign look like a segment
3536
PROGMEM const unsigned char chr_f7s_2D[] =
3637
{
37-
0x7F, 0x7F, 0x45, 0x8A, 0x05, 0x8A, 0x05, 0x8A,
38-
0x05, 0x8A, 0x7F, 0x7F, 0x7F, 0x2B
38+
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x27, 0x8E, 0x0E,
39+
0x92, 0x0A, 0x96, 0x09, 0x94, 0x0C, 0x90, 0x7F,
40+
0x7F, 0x7F, 0x7F, 0x7F, 0x47
3941
};
4042

4143
PROGMEM const unsigned char chr_f7s_2E[] =

src/utility/ILI9341_Defines.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define TFT_WIDTH 240
44
#define TFT_HEIGHT 320
55

6+
67
// Color definitions for backwards compatibility with old sketches
78
// use colour definitions like TFT_BLACK to make sketches more portable
89
#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
@@ -70,6 +71,16 @@
7071
#define TFT_MAD_MH 0x04
7172
#define TFT_MAD_RGB 0x00
7273

74+
#ifdef TFT_RGB_ORDER
75+
#if (TFT_RGB_ORDER == 1)
76+
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
77+
#else
78+
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
79+
#endif
80+
#else
81+
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
82+
#endif
83+
7384
#define TFT_INVOFF 0x20
7485
#define TFT_INVON 0x21
7586

src/utility/ILI9341_Init.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@
4141
writedata(0x00);
4242
writedata(0x00);
4343

44-
writecommand(ILI9341_PWCTR1); // Power control
45-
writedata(0x23); // VRH[5:0]
44+
writecommand(ILI9341_PWCTR1); //Power control
45+
writedata(0x23); //VRH[5:0]
4646

47-
writecommand(ILI9341_PWCTR2); // Power control
48-
writedata(0x10); // SAP[2:0];BT[3:0]
47+
writecommand(ILI9341_PWCTR2); //Power control
48+
writedata(0x10); //SAP[2:0];BT[3:0]
4949

50-
writecommand(ILI9341_VMCTR1); // VCM control
50+
writecommand(ILI9341_VMCTR1); //VCM control
5151
writedata(0x3e);
5252
writedata(0x28);
5353

54-
writecommand(ILI9341_VMCTR2); // VCM control2
55-
writedata(0x86); // --
54+
writecommand(ILI9341_VMCTR2); //VCM control2
55+
writedata(0x86); //--
5656

5757
writecommand(ILI9341_MADCTL); // Memory Access Control
5858
#ifdef M5STACK
59-
writedata(0xA8); // Rotation 0 (portrait mode)
59+
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); // Rotation 0 (portrait mode)
6060
#else
61-
writedata(0x48); // Rotation 0 (portrait mode)
61+
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER); // Rotation 0 (portrait mode)
6262
#endif
6363

6464
writecommand(ILI9341_PIXFMT);
@@ -76,10 +76,10 @@
7676
writecommand(0xF2); // 3Gamma Function Disable
7777
writedata(0x00);
7878

79-
writecommand(ILI9341_GAMMASET); // Gamma curve selected
79+
writecommand(ILI9341_GAMMASET); //Gamma curve selected
8080
writedata(0x01);
8181

82-
writecommand(ILI9341_GMCTRP1); // Set Gamma
82+
writecommand(ILI9341_GMCTRP1); //Set Gamma
8383
writedata(0x0F);
8484
writedata(0x31);
8585
writedata(0x2B);
@@ -96,7 +96,7 @@
9696
writedata(0x09);
9797
writedata(0x00);
9898

99-
writecommand(ILI9341_GMCTRN1); // Set Gamma
99+
writecommand(ILI9341_GMCTRN1); //Set Gamma
100100
writedata(0x00);
101101
writedata(0x0E);
102102
writedata(0x14);
@@ -113,11 +113,12 @@
113113
writedata(0x36);
114114
writedata(0x0F);
115115

116-
writecommand(ILI9341_SLPOUT); // Exit Sleep
116+
writecommand(ILI9341_SLPOUT); //Exit Sleep
117117

118118
spi_end();
119119
delay(120);
120120
spi_begin();
121121

122-
writecommand(ILI9341_DISPON); // Display on
123-
}
122+
writecommand(ILI9341_DISPON); //Display on
123+
124+
}

src/utility/ILI9341_Rotation.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,73 +7,73 @@
77
switch (rotation) {
88
case 0:
99
#ifdef M5STACK
10-
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
10+
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
1111
#else
12-
writedata(TFT_MAD_MX | TFT_MAD_BGR);
12+
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
1313
#endif
1414
_width = _init_width;
1515
_height = _init_height;
1616
break;
1717
case 1:
1818
#ifdef M5STACK
19-
writedata(TFT_MAD_BGR);
19+
writedata(TFT_MAD_COLOR_ORDER);
2020
#else
21-
writedata(TFT_MAD_MV | TFT_MAD_BGR);
21+
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
2222
#endif
2323
_width = _init_height;
2424
_height = _init_width;
2525
break;
2626
case 2:
2727
#ifdef M5STACK
28-
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
28+
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
2929
#else
30-
writedata(TFT_MAD_MY | TFT_MAD_BGR);
30+
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
3131
#endif
3232
_width = _init_width;
3333
_height = _init_height;
3434
break;
3535
case 3:
3636
#ifdef M5STACK
37-
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
37+
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
3838
#else
39-
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
39+
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
4040
#endif
4141
_width = _init_height;
4242
_height = _init_width;
4343
break;
4444
// These next rotations are for bottom up BMP drawing
4545
case 4:
4646
#ifdef M5STACK
47-
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
47+
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
4848
#else
49-
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
49+
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
5050
#endif
5151
_width = _init_width;
5252
_height = _init_height;
5353
break;
5454
case 5:
5555
#ifdef M5STACK
56-
writedata(TFT_MAD_MY | TFT_MAD_BGR);
56+
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
5757
#else
58-
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
58+
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
5959
#endif
6060
_width = _init_height;
6161
_height = _init_width;
6262
break;
6363
case 6:
6464
#ifdef M5STACK
65-
writedata(TFT_MAD_MV | TFT_MAD_BGR);
65+
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
6666
#else
67-
writedata(TFT_MAD_BGR);
67+
writedata(TFT_MAD_COLOR_ORDER);
6868
#endif
6969
_width = _init_width;
7070
_height = _init_height;
7171
break;
7272
case 7:
7373
#ifdef M5STACK
74-
writedata(TFT_MAD_MX | TFT_MAD_BGR);
74+
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
7575
#else
76-
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
76+
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
7777
#endif
7878
_width = _init_height;
7979
_height = _init_width;

0 commit comments

Comments
 (0)