Repository navigation
Expand file tree
/
Copy pathBoard.hpp
More file actions
63 lines (61 loc) · 1.79 KB
/
Copy pathBoard.hpp
File metadata and controls
63 lines (61 loc) · 1.79 KB
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
#pragma once
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
// ST7796 SPI reference wiring. Adapt these pins for your board. SPI2 is
// required by the S3 queued scanout; the bus must be dedicated to the LCD.
namespace Board {
#if CONFIG_IDF_TARGET_ESP32S3
constexpr int clock = 46, mosi = 3, dc = 8, cs = 17, reset = 18, backlight = 9;
constexpr int spiMode = 1;
#elif CONFIG_IDF_TARGET_ESP32P4
constexpr int clock = 20, mosi = 5, dc = 23, cs = 7, reset = 8, backlight = 21;
constexpr int spiMode = 0;
#else
#error "Select esp32s3 or esp32p4"
#endif
}
class LGFX : public lgfx::LGFX_Device {
lgfx::Panel_ST7796 panel;
lgfx::Light_PWM light;
lgfx::Bus_SPI bus;
public:
LGFX() {
auto b = bus.config();
b.spi_host = SPI2_HOST;
b.spi_mode = Board::spiMode;
b.freq_write = 80000000;
b.freq_read = 16000000;
b.spi_3wire = false;
b.use_lock = true;
b.dma_channel = SPI_DMA_CH_AUTO;
b.pin_sclk = Board::clock;
b.pin_mosi = Board::mosi;
b.pin_miso = -1;
b.pin_dc = Board::dc;
bus.config(b);
panel.setBus(&bus);
auto p = panel.config();
p.pin_cs = Board::cs;
p.pin_rst = Board::reset;
p.pin_busy = -1;
p.panel_width = 320;
p.panel_height = 480;
p.offset_x = p.offset_y = p.offset_rotation = 0;
p.dummy_read_pixel = 8;
p.dummy_read_bits = 1;
p.readable = false;
p.invert = true;
p.rgb_order = false;
p.dlen_16bit = false;
p.bus_shared = false;
panel.config(p);
auto l = light.config();
l.pin_bl = Board::backlight;
l.invert = false;
l.freq = 44100;
l.pwm_channel = 7;
light.config(l);
panel.setLight(&light);
setPanel(&panel);
}
};