forked from Bodmer/TFT_eSPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathST7789_Init.h
124 lines (100 loc) · 2.82 KB
/
ST7789_Init.h
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
// This is the command sequence that initialises the ST7789 driver
//
// This setup information uses simple 8 bit SPI writecommand() and writedata() functions
//
// See ST7735_Setup.h file for an alternative format
{
writecommand(ST7789_SLPOUT); // Sleep out
delay(120);
writecommand(ST7789_NORON); // Normal display mode on
//------------------------------display and color format setting--------------------------------//
writecommand(ST7789_MADCTL);
//writedata(0x00);
writedata(TFT_MAD_COLOR_ORDER);
// JLX240 display datasheet
writecommand(0xB6);
writedata(0x0A);
writedata(0x82);
writecommand(ST7789_COLMOD);
writedata(0x55);
delay(10);
//--------------------------------ST7789V Frame rate setting----------------------------------//
writecommand(ST7789_PORCTRL);
writedata(0x0c);
writedata(0x0c);
writedata(0x00);
writedata(0x33);
writedata(0x33);
writecommand(ST7789_GCTRL); // Voltages: VGH / VGL
writedata(0x35);
//---------------------------------ST7789V Power setting--------------------------------------//
writecommand(ST7789_VCOMS);
writedata(0x28); // JLX240 display datasheet
writecommand(ST7789_LCMCTRL);
writedata(0x0C);
writecommand(ST7789_VDVVRHEN);
writedata(0x01);
writedata(0xFF);
writecommand(ST7789_VRHS); // voltage VRHS
writedata(0x10);
writecommand(ST7789_VDVSET);
writedata(0x20);
writecommand(ST7789_FRCTR2);
writedata(0x0f);
writecommand(ST7789_PWCTRL1);
writedata(0xa4);
writedata(0xa1);
//--------------------------------ST7789V gamma setting---------------------------------------//
writecommand(ST7789_PVGAMCTRL);
writedata(0xd0);
writedata(0x00);
writedata(0x02);
writedata(0x07);
writedata(0x0a);
writedata(0x28);
writedata(0x32);
writedata(0x44);
writedata(0x42);
writedata(0x06);
writedata(0x0e);
writedata(0x12);
writedata(0x14);
writedata(0x17);
writecommand(ST7789_NVGAMCTRL);
writedata(0xd0);
writedata(0x00);
writedata(0x02);
writedata(0x07);
writedata(0x0a);
writedata(0x28);
writedata(0x31);
writedata(0x54);
writedata(0x47);
writedata(0x0e);
writedata(0x1c);
writedata(0x17);
writedata(0x1b);
writedata(0x1e);
writecommand(ST7789_INVON);
writecommand(ST7789_CASET); // Column address set
writedata(0x00);
writedata(0x00);
writedata(0x00);
writedata(0xE5); // 239
writecommand(ST7789_RASET); // Row address set
writedata(0x00);
writedata(0x00);
writedata(0x01);
writedata(0x3F); // 319
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
spi_end();
delay(120);
spi_begin();
writecommand(ST7789_DISPON); //Display on
delay(120);
#ifdef TFT_BL
// Turn on the back-light LED
digitalWrite(TFT_BL, HIGH);
pinMode(TFT_BL, OUTPUT);
#endif
}