generated from sukesh-ak/ESP32-LVGL8x-SDSPI
-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathconf_WT32SCO1.h
164 lines (126 loc) · 6.49 KB
/
conf_WT32SCO1.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
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
/*
MIT License
Copyright (c) 2022 Sukesh Ashok Kumar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
//#define LGFX_WT32_SC01 // Wireless Tag / Seeed WT32-SC01
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#define WT32_SC01
// #define SD_SUPPORTED // external SPI (SD or others)
#define SPI_HOST_ID SPI2_HOST
// Since SPI bus is shared, only CS PIN required
#define SD_CS GPIO_NUM_33
// Portrait
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
//#define SD_SUPPORTED
#define TFT_MOSI GPIO_NUM_13
#define TFT_MISO -1 // Set this PIN for using shared SPI option
#define TFT_SCLK GPIO_NUM_14
#define TFT_DC GPIO_NUM_21
#define TFT_CS GPIO_NUM_15
#define TFT_RST GPIO_NUM_22
#define TOUCH_INT GPIO_NUM_39
#define TOUCH_SDA GPIO_NUM_18
#define TOUCH_SCL GPIO_NUM_19
class LGFX : public lgfx::LGFX_Device
{
// provide an instance that matches the type of panel you want to connect to.
lgfx::Panel_ST7796 _panel_instance;
// provide an instance that matches the type of bus to which the panel is connected.
lgfx::Bus_SPI _bus_instance; // Instances of spi buses
//Prepare an instance that matches the type of touchscreen.
lgfx::Touch_FT5x06 _touch_instance;
lgfx::Light_PWM _light_instance;
public:
LGFX(void)
{
{
// set up bus control.
auto cfg = _bus_instance.config(); // gets the structure for bus settings.
// SPI bus settings
cfg.spi_host = SPI2_HOST; // Select SPI to use ESP32-S2,C3: SPI2_HOST or SPI3_HOST / ESP32: VSPI_HOST or HSPI_HOST
//* Due to the ESP-IDF upgrade, the description of VSPI_HOST , HSPI_HOST will be deprecated, so if you get an error, use SPI2_HOST , SPI3_HOST instead.
cfg.spi_mode = 0; // Set SPI communication mode (0-3)
cfg.freq_write = 80000000; // SPI clock on transmission (up to 80MHz, rounded to 80MHz divided by integer)
cfg.freq_read = 16000000; // SPI clock on reception
cfg.spi_3wire = true; // Set true when receiving on the MOSI pin
cfg.use_lock = true; // set true if transaction lock is used
// * With the ESP-IDF version upgrade, SPI_DMA_CH_AUTO (automatic setting) of DMA channels is recommended.
cfg.dma_channel = SPI_DMA_CH_AUTO; // Set DMA channel to be used (0=DMA not used / 1=1ch / 2=ch / SPI_DMA_CH_AUTO=Auto setting)
cfg.pin_sclk = TFT_SCLK; // Set SCLK pin number for SPI
cfg.pin_mosi = TFT_MOSI; // Set SPI MOSI pin number
// When using the SPI bus, which is common to the SD card, be sure to set MISO without omitting it.
cfg.pin_miso = TFT_MISO; // Set THE MSO pin number of spi (-1 = disable)
cfg.pin_dc = TFT_DC; // Set THE D/C pin number of SPI (-1 = disable)
_bus_instance.config(cfg); // reflects the setting value on the bus.
_panel_instance.setBus(&_bus_instance); // Set the bus to the panel.
}
{
// set the display panel control.
auto cfg = _panel_instance.config(); // gets the structure for display panel settings.
cfg.pin_cs = TFT_CS; // Pin number to which CS is connected (-1 = disable)
cfg.pin_rst = TFT_RST; // Pin number to which RST is connected (-1 = disable)
cfg.pin_busy = -1; // Pin number to which BUSY is connected (-1 = disable)
// the following setting values are set to a general initial value for each panel,
cfg.panel_width = TFT_WIDTH; // actual visible width
cfg.panel_height = TFT_HEIGHT; // actually visible height
cfg.offset_x = 0; // Panel X-direction offset amount
cfg.offset_y = 0; // Panel Y offset amount
cfg.offset_rotation = 0; // offset of rotational values from 0 to 7 (4 to 7 upside down)
cfg.dummy_read_pixel = 8; // number of bits in dummy leads before pixel read
cfg.dummy_read_bits = 1; // number of bits in dummy leads before reading non-pixel data
cfg.readable = false; // set to true if data can be read
cfg.invert = false; // set to true if the light and dark of the panel is reversed
cfg.rgb_order = false; // set to true if the red and blue of the panel are swapped
cfg.dlen_16bit = false; // Set to true for panels that transmit data lengths in 16-bit increments in 16-bit parallel or SPI
cfg.bus_shared = true; // Set to true when sharing the bus with sd card (bus control is performed with drawJpgFile, etc.)
// The following should only be set if the display is misalized by a driver with a variable number of pixels, such as st7735 or ILI9163.
// cfg.memory_width = 240; //Maximum width supported by driver ICs
// cfg.memory_height = 320; //Maximum height supported by driver ICs
_panel_instance.config(cfg);
}
{
auto cfg = _light_instance.config();
cfg.pin_bl = 23;//45;
cfg.invert = false;
cfg.freq = 44100;
cfg.pwm_channel = 7;
_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance);
}
{
auto cfg = _touch_instance.config();
cfg.x_min = 0;
cfg.x_max = 319;
cfg.y_min = 0;
cfg.y_max = 479;
cfg.pin_int = TOUCH_INT;
cfg.bus_shared = false;
cfg.offset_rotation = 0;
cfg.i2c_port = 1;//I2C_NUM_1;
cfg.i2c_addr = 0x38;
cfg.pin_sda = TOUCH_SDA;
cfg.pin_scl = TOUCH_SCL;
cfg.freq = 400000;
_touch_instance.config(cfg);
_panel_instance.setTouch(&_touch_instance);
}
setPanel(&_panel_instance); // Set the panel to be used.
}
};