TinyGPU
Loading...
Searching...
No Matches
LCDBoardsESP32.h
Go to the documentation of this file.
1#pragma once
2/**
3 * @file LCDBoardsESP32.h
4 * @brief One-call setup for ESP32(-S3) boards from the arduino-audio-tools
5 * "Audio Boards" wiki that combine an LCD/TFT display with a touch
6 * controller (and, on the same board, an I2S audio codec/amp):
7 * https://github.com/pschatzmann/arduino-audio-tools/wiki/Audio-Boards
8 *
9 * Bringing one of these boards up normally means hand-wiring the SPI/QSPI
10 * bus, the backlight pin, the display controller's init sequence, the
11 * touch controller's I2C bus, and separately tracking the board's I2S
12 * pins for the audio side - each board class here does the display/touch
13 * part in a single begin() call and exposes the I2S pin assignment so it
14 * can be handed to e.g. audio_tools::I2SConfig (TinyGPU itself has no
15 * audio-tools dependency, so I2SPins is a plain pin struct, not a
16 * driver).
17 *
18 * Only boards that actually have an LCD are covered - audio-only boards
19 * on that wiki page are out of scope for this graphics library. See
20 * LCDBoards.h for the platform-independent LCDBoard interface these
21 * classes implement.
22 */
23#include "TinyGPU/Emulation.h"
24
25#if defined(ESP32)
26
27#include <SD_MMC.h>
28
29#include "TinyGPU/Drivers/DisplayDriverDSI.h"
30#include "TinyGPU/Drivers/DisplayDriverQSPI.h"
31#include "TinyGPU/Drivers/DisplayDriverSPI.h"
32#include "TinyGPU/Input/TouchDriverArduino.h"
33#include "TinyGPU/Boards/LCDBoardsCommon.h"
34#include "esp_adc/adc_cali.h"
35#include "esp_adc/adc_cali_scheme.h"
36#include "esp_adc/adc_oneshot.h"
37#include "esp_check.h"
38#include "esp_log.h"
39
40namespace tinygpu {
41
42/**
43 * @brief "2.8" ESP32-S3 Display" - ILI9341 SPI TFT + FT6336G capacitive
44 * touch (I2C, shares its bus with the board's ES8311 audio codec).
45 * (FBBA0125-002) - also named ESP32-S3 Hosyond Display
46 *
47 * Display: ILI9341, 240x320, SPI - CS=10 DC=46 SCK=12 MOSI=11 MISO=13
48 * BL=45; RST is tied to the board's EN line (no dedicated reset
49 * pin). Needs inversion on (set in begin()) or colors render
50 * wrong on real hardware; byte order stays at the driver
51 * default. ILI9341Driver::setInvertColor() re-applies the last
52 * value at the end of every begin(), so it survives a later,
53 * redundant begin() (e.g. from DeviceOutput::begin()) even
54 * though each begin() resets the panel's inversion register via
55 * SWRESET.
56 * Touch: FT6336G (register-compatible with TouchDriverFT6236), I2C -
57 * SDA=16 SCL=15 RST=18, physical IRQ=17. IRQ is left unwired
58 * (-1, forcing register polling) since its idle polarity was
59 * never confirmed on real hardware.
60 * I2S (ES8311 codec): MCLK=4 BCK=5 WS=7 DOUT=8 DIN=6. Speaker amp
61 * (FM8002E) enable: IO1, active low.
62 * LED: single WS2812-compatible RGB LED on IO42.
63 *
64 * @note Audio setup: the ES8311 codec needs its own I2C init (volume, mic
65 * gain, ...), so plain I2SStream leaves it unconfigured. Prefer
66 * arduino-audio-driver's ready-made board definition, which owns codec
67 * init and I2S pins together:
68 *
69 * #include "AudioTools.h"
70 * #include "AudioTools/AudioLibs/AudioBoardStream.h"
71 * #include "AudioBoards/ESP32S3HosyondDisplay.h" // arduino-audio-driver
72 *
73 * audio_tools::AudioBoardStream out(audio_driver::ESP32S3HosyondDisplay);
74 * auto cfg = out.defaultConfig(TX_MODE);
75 * out.begin(cfg);
76 * out.setVolume(0.5f);
77 *
78 * Without arduino-audio-driver, i2s()/setI2SPins() give the raw
79 * MCLK/BCK/WS/DOUT/DIN pins for a plain I2SStream, but the caller must
80 * then handle the ES8311's I2C init and drive the PA-enable pin
81 * (i2s().paEnable, active low per paEnableActiveLow) itself.
82 */
83class LCDBoardESP32S3_2_8Display : public LCDBoard {
84 public:
85 /// Sets up the backlight, SPI bus, display controller (incl. inversion
86 /// and byte order - see the class doc comment), and touch controller.
87 /// Returns false if the display or touch begin() fails.
88 bool begin() override {
89 pinMode(kPinBacklight, OUTPUT);
90 digitalWrite(kPinBacklight, HIGH);
91
92 SPI.begin(kPinSck, kPinMiso, kPinMosi, kPinCs);
93 if (!display_.begin()) return false;
94 display_.setInvertColor(true);
95 display_.setSwapOutputBytes(false);
96
97 Wire.begin(kPinTouchSda, kPinTouchScl);
98 return touch_.begin();
99 }
100
101 /// Panel width in pixels.
102 size_t width() const override { return 240; }
103 /// Panel height in pixels.
104 size_t height() const override { return 320; }
105
106 /// The board's display driver.
107 ILI9341Driver<RGB565>& display() override { return display_; }
108 /// The board's touch controller.
109 TouchDriver* touch() override { return &touch_; }
110 /// The board's I2S/PA pin assignment.
111 const I2SPins& i2s() const override { return i2s_; }
112 /// The board's LED pin assignment.
113 const LEDPins& led() const override { return led_; }
114 /// The board's backlight GPIO pin.
115 int8_t backlightPin() const override { return kPinBacklight; }
116
117 private:
118 static constexpr int8_t kPinCs = 10;
119 static constexpr int8_t kPinDc = 46;
120 static constexpr int8_t kPinSck = 12;
121 static constexpr int8_t kPinMosi = 11;
122 static constexpr int8_t kPinMiso = 13;
123 static constexpr int8_t kPinBacklight = 45;
124 static constexpr int8_t kPinTouchSda = 16;
125 static constexpr int8_t kPinTouchScl = 15;
126 static constexpr int8_t kPinTouchRst = 18;
127
128 // 80MHz (this panel's SPI clock ceiling on this board's wiring, verified
129 // on real hardware) instead of the constructor's 40MHz default - halves
130 // per-frame SPI transfer time versus leaving it at the default. Rotation
131 // stays kNone here since callers set it explicitly (e.g. via
132 // OutputTinyGPU::setRotation()) after begin().
133 ILI9341Driver<RGB565> display_{SPI,
134 kPinCs,
135 kPinDc,
136 /*rst=*/-1,
137 ILI9341Driver<RGB565>::Rotation::kNone,
138 /*frequencyHz=*/80000000};
139 TouchDriverFT6236 touch_{Wire, kPinTouchRst, /*irq=*/-1};
140 I2SPins i2s_{/*mclk=*/4, /*bck=*/5,
141 /*ws=*/7,
142 /*dataOut=*/8, /*dataIn=*/6,
143 /*paEnable=*/1, /*paEnableActiveLow=*/true};
144 LEDPins led_{/*single=*/42};
145};
146
147using FBBA0125_002 = LCDBoardESP32S3_2_8Display;
148using ESP32S3HosyondLCD = LCDBoardESP32S3_2_8Display;
149
150/**
151 * @brief "Guition ESP32-S3 4.3" 480x272 Capacitive Touch Display"
152 * (JC4827W543C_I): it has a NV3041A QSPI display, GT911 capacitive touch
153 * NV3041A QSPI TFT + GT911 capacitive touch (I2C) + NS4168 speaker amp
154 * (speaker output only - no codec/mic on this board).
155 *
156 *
157 * Display: NV3041A, 480x272, QSPI - CS=45 SCLK=47 D0=21 D1=48 D2=40 D3=39
158 * BL=1, 32MHz.
159 * Touch: GT911, I2C - SDA=8 SCL=4 INT=3 RST=38, address 0x5D.
160 * I2S (NS4168 amp): BCK=42 WS=2 DATA=41.
161 * LED: none on this board.
162 *
163 * @note Audio setup: no codec on this board - the NS4168 is a plain I2S power
164 * amp, so audio_tools::I2SStream (TX only; there's no mic/data_in) is
165 * enough:
166 *
167 * #include "AudioTools.h"
168 *
169 * I2SStream out;
170 * auto cfg = out.defaultConfig(TX_MODE);
171 * cfg.sample_rate = 44100; cfg.channels = 2; cfg.bits_per_sample = 16;
172 * board.setI2SPins<I2SConfig>(cfg);
173 * out.begin(cfg);
174 */
175class LCDBoardGuitionESP32S3_4_3Display : public LCDBoard {
176 public:
177 /// Sets up the backlight, QSPI display controller, and touch controller.
178 /// Returns false if the display or touch begin() fails.
179 bool begin() override {
180 pinMode(kPinBacklight, OUTPUT);
181 digitalWrite(kPinBacklight, HIGH);
182
183 if (!display_.begin()) return false;
184
185 Wire.begin(kPinTouchSda, kPinTouchScl);
186 return touch_.begin();
187 }
188
189 /// Panel width in pixels.
190 size_t width() const override { return 480; }
191 /// Panel height in pixels.
192 size_t height() const override { return 272; }
193
194 /// The board's display driver.
195 NV3041ADriver<RGB565>& display() override { return display_; }
196 /// The board's touch controller.
197 TouchDriver* touch() override { return &touch_; }
198 /// The board's I2S pin assignment.
199 const I2SPins& i2s() const override { return i2s_; }
200 /// This board has no RGB LED - every LEDPins field is -1.
201 const LEDPins& led() const override { return led_; }
202 /// The board's backlight GPIO pin.
203 int8_t backlightPin() const override { return kPinBacklight; }
204
205 private:
206 static constexpr int8_t kPinCs = 45;
207 static constexpr int8_t kPinSclk = 47;
208 static constexpr int8_t kPinD0 = 21;
209 static constexpr int8_t kPinD1 = 48;
210 static constexpr int8_t kPinD2 = 40;
211 static constexpr int8_t kPinD3 = 39;
212 static constexpr int8_t kPinBacklight = 1;
213 static constexpr int8_t kPinTouchSda = 8;
214 static constexpr int8_t kPinTouchScl = 4;
215 static constexpr int8_t kPinTouchIrq = 3;
216 static constexpr int8_t kPinTouchRst = 38;
217
218 NV3041ADriver<RGB565> display_{kPinCs, kPinSclk, kPinD0,
219 kPinD1, kPinD2, kPinD3};
220 TouchDriverGT911 touch_{Wire, kPinTouchRst, kPinTouchIrq};
221 I2SPins i2s_{/*mclk=*/-1, /*bck=*/42, /*ws=*/2, /*dataOut=*/41,
222 /*dataIn=*/-1};
223 LEDPins led_{};
224};
225
226using JC4827W543C_I = LCDBoardGuitionESP32S3_4_3Display;
227
228/**
229 * @brief "ESP32 Arduino LVGL WiFi&Bluetooth Development Board, 2.4" LCD
230 * TFT Module" - ILI9341 SPI TFT + CST816S capacitive touch, no PSRAM.
231 * (ESP32-2432S028R) - also named ESP32 Cheap Yellow Diplay
232 *
233 *
234 * This is the same board pinout TinyGPU's own examples (e.g.
235 * examples/color-test) are tested against.
236 *
237 * Display: ILI9341, 240x320, SPI - CS=15 DC=2 SCK=14 MOSI=13 MISO=12
238 * RST=-1 BL=27.
239 * Touch: CST816S, I2C - SDA=33 SCL=32 IRQ=36 (no RST pin wired).
240 * Audio: built-in mono amplifier driven from the ESP32's internal DAC
241 * (analog output, not I2S) - i2s() is all -1 on this board.
242 * LED: discrete RGB LED (3 separate GPIOs, active low) - R=4 G=16 B=17.
243 *
244 * @note Audio setup: this board has no I2S bus at all (i2s().isValid() is
245 * false) - use audio_tools::AnalogAudioStream instead of I2SStream. It
246 * drives the ESP32's built-in DAC pins (GPIO25/26) directly, so there
247 * are no board pins to pass in:
248 *
249 * #include "AudioTools.h"
250 *
251 * AnalogAudioStream out;
252 * auto cfg = out.defaultConfig(TX_MODE);
253 * cfg.sample_rate = 44100; cfg.channels = 1; cfg.bits_per_sample = 16;
254 * out.begin(cfg);
255 */
256class LCDBoardGuitionESP32_LVGL_2_4Display : public LCDBoard {
257 public:
258 /// Sets up the backlight, SPI bus, display controller, and touch
259 /// controller. Returns false if the display or touch begin() fails.
260 bool begin() override {
261 pinMode(kPinBacklight, OUTPUT);
262 digitalWrite(kPinBacklight, HIGH);
263
264 SPI.begin(kPinSck, kPinMiso, kPinMosi, kPinCs);
265 if (!display_.begin()) return false;
266
267 Wire.begin(kPinTouchSda, kPinTouchScl);
268 return touch_.begin();
269 }
270
271 /// Panel width in pixels.
272 size_t width() const override { return 240; }
273 /// Panel height in pixels.
274 size_t height() const override { return 320; }
275
276 /// The board's display driver.
277 ILI9341Driver<RGB565>& display() override { return display_; }
278 /// The board's touch controller.
279 TouchDriver* touch() override { return &touch_; }
280 /// Analog-DAC audio on this board - every I2SPins field is -1.
281 const I2SPins& i2s() const override { return i2s_; }
282 /// The board's LED pin assignment.
283 const LEDPins& led() const override { return led_; }
284 /// The board's backlight GPIO pin.
285 int8_t backlightPin() const override { return kPinBacklight; }
286
287 private:
288 static constexpr int8_t kPinCs = 15;
289 static constexpr int8_t kPinDc = 2;
290 static constexpr int8_t kPinSck = 14;
291 static constexpr int8_t kPinMosi = 13;
292 static constexpr int8_t kPinMiso = 12;
293 static constexpr int8_t kPinBacklight = 27;
294 static constexpr int8_t kPinTouchSda = 33;
295 static constexpr int8_t kPinTouchScl = 32;
296 static constexpr int8_t kPinTouchIrq = 36;
297
298 ILI9341Driver<RGB565> display_{SPI, kPinCs, kPinDc, /*rst=*/-1};
299 TouchDriverCST816S touch_{Wire, /*rst=*/-1, kPinTouchIrq};
300 I2SPins i2s_{};
301 LEDPins led_{/*single=*/-1, /*r=*/4, /*g=*/16, /*b=*/17,
302 /*activeLow=*/true};
303};
304
305using ESP32_2432S028R = LCDBoardGuitionESP32_LVGL_2_4Display;
306using ESP32CheapYellowDisplay = LCDBoardGuitionESP32_LVGL_2_4Display;
307
308// The rest of this file is ESP32-P4-only: ST7701Driver (DisplayDriverDSI.h)
309// only exists when TINYGPU_HAS_ESP_LCD_DSI is defined (i.e. esp_lcd_mipi_dsi.h
310// is available, which the Arduino-ESP32 core only ships for the P4), and
311// hostedSetPins() below is likewise a P4-only ESP-Hosted-Wi-Fi API. Without
312// this guard, merely #including this file for any other chip (classic
313// ESP32, S3, ...) fails to compile even if the sketch never touches this
314// board class.
315#ifdef TINYGPU_HAS_ESP_LCD_DSI
316
317/**
318 * @brief "Guition ESP32-P4 4.3" 480x800 Capacitive Touch Display"
319 * (JC4880P443C_I_W): it has an ST7701 MIPI-DSI display, GT911 capacitive
320 * touch (I2C), and an ES8311 audio codec with NS4150 speaker amp (speaker
321 * output only - this board has no mic). The board also has a WiFi SDIO
322 * interface and an SD_MMC interface, both of which need their own pin setup.
323 *
324 * Note: despite the class name (kept for historical/API-compatibility
325 * reasons), the chip on this board is an ESP32-P4, not an ESP32-H4 - see
326 * ST7701Driver's docs in DisplayDriverDSI.h and the guition-jc4880p4-bsp
327 * source this driver was transcribed from.
328 *
329 * @note SD card power: kSdLdoChannel (TF_VCC) is recorded from the BSP
330 * source but not currently driven by begin() - unlike kDsiPhyLdoChan, which
331 * IS wired into ST7701Driver. If the TF socket needs that LDO switched on to
332 * work, SD_MMC.begin() may fail until this is enabled explicitly.
333 *
334 * @note Audio setup: this board's ES8311 codec needs its own I2C init
335 * (volume, mic gain, ...), not just I2S pins, so plain I2SStream
336 * leaves the codec unconfigured. If the sketch also depends on
337 * arduino-audio-driver, use its ready-made board definition instead,
338 * which owns the codec init and I2S pins together:
339 *
340 * #include "AudioTools.h"
341 * #include "AudioTools/AudioLibs/AudioBoardStream.h"
342 *
343 * AudioBoardStream i2s(GenericES8311);
344 * auto config = i2s.defaultConfig(TX_MODE);
345 * board.setI2SPins<I2SConfig>(config);
346 * i2s.begin(config);
347 * i2s.setVolume(0.5f);
348 * board.setAmplifierActive(true);
349 *
350 * Without arduino-audio-driver, i2s()/setI2SPins() still give the raw
351 * MCLK/BCK/WS/DOUT/DIN pins for a plain I2SStream, but the caller is then
352 * responsible for the ES8311's I2C init and driving the PA-enable pin
353 * (i2s().paEnable, active low per paEnableActiveLow) itself.
354 */
355
356class LCDBoardGuitionESP32H4_4_3Display : public LCDBoard {
357 public:
358 LCDBoardGuitionESP32H4_4_3Display() = default;
359
360 ~LCDBoardGuitionESP32H4_4_3Display() {
361 if (cali_handle_) {
362#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
363 adc_cali_delete_scheme_curve_fitting(cali_handle_);
364#elif ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED
365 adc_cali_delete_scheme_line_fitting(cali_handle_);
366#endif
367 }
368 if (adc_handle_) {
369 adc_oneshot_del_unit(adc_handle_);
370 }
371 }
372
373 /// Sets up the backlight, QSPI display controller, touch controller,
374 /// WiFi SDIO pins, and SD_MMC pins. Returns false if the display or touch
375 /// begin() fails. The speaker amp is not activated - call
376 /// setAmplifierActive(true) explicitly.
377 bool begin() override {
378 pinMode(kPinLcdBacklight, OUTPUT);
379 digitalWrite(kPinLcdBacklight, HIGH);
380
381 if (!display_.begin()) return false;
382
383 // setup wire for I2S codec and touch controller (GT911)
384 Wire.begin(kPinSda, kPinScl);
385
386 if (!touch_.begin()) return false;
387
388 // set wifi pins
389 if (!setupWifi()) return false;
390
391 // set SD_MMC pins
392 if (!SD_MMC.setPins(kPinSdClk, kPinSdCmd, kPinSdD0, kPinSdD1, kPinSdD2,
393 kPinSdD3)) {
394 return false;
395 }
396
397 return true;
398 }
399
400 /// Activates or deactivates the NS4150 speaker amp. The amp is active when
401 /// the pin is driven low, so this function inverts the active state to
402 /// make it more intuitive to the caller.
403 void setAmplifierActive(bool active) {
404 pinMode(kPinAmpEnable, OUTPUT);
405 digitalWrite(kPinAmpEnable, active ? HIGH : LOW);
406 }
407
408 /// Panel width in pixels.
409 size_t width() const override { return kDisplayWidth; }
410 /// Panel height in pixels.
411 size_t height() const override { return kDisplayHeight; }
412
413 /// The board's display driver.
414 ST7701Driver<RGB565>& display() override { return display_; }
415 /// The board's touch controller.
416 TouchDriver* touch() override { return &touch_; }
417 /// The board's I2S pin assignment.
418 const I2SPins& i2s() const override { return i2s_; }
419 /// This board has no RGB LED - every LEDPins field is -1.
420 const LEDPins& led() const override { return led_; }
421 /// The board's backlight GPIO pin.
422 int8_t backlightPin() const override { return kPinLcdBacklight; }
423
424 /// Reads and returns the battery charge percentage (0 - 100).
425 int battery(int battery_readings_ = 100) {
426 if (!adc_initialized_) {
427 initAdc();
428 }
429 if (!adc_handle_) return 0;
430
431 long raw_sum = 0;
432 int raw_val = 0;
433 for (int i = 0; i < battery_readings_; ++i) {
434 if (adc_oneshot_read(adc_handle_, kAdcChannel, &raw_val) == ESP_OK) {
435 raw_sum += raw_val;
436 }
437 }
438
439 int avg_raw = raw_sum / battery_readings_;
440 int mv = 0;
441 if (cali_handle_) {
442 adc_cali_raw_to_voltage(cali_handle_, avg_raw, &mv);
443 }
444
445 int clamped_mv = constrain(mv, kVcMinMv, kVcMaxMv);
446 return (clamped_mv - kVcMinMv) * 100 / (kVcMaxMv - kVcMinMv);
447 }
448
449 private:
450 static constexpr int kPinI2sMclk = 13;
451 static constexpr int kPinI2sBck = 12;
452 static constexpr int kPinI2sWs = 10;
453 static constexpr int kPinI2sDout = 9; // P4 -> codec
454 static constexpr int kPinI2sDin = 48;
455 static constexpr int kPinScl = 8; // shared with GT911 touch bus
456 static constexpr int kPinSda = 7;
457 static constexpr int kPinAmpEnable = 11; // NS4150 PA_EN
458
459 // sdcard pins (SDMMC1, 4-bit mode) -
460 static constexpr int kPinSdClk = 43;
461 static constexpr int kPinSdCmd = 44;
462 static constexpr int kPinSdD0 = 39;
463 static constexpr int kPinSdD1 = 40;
464 static constexpr int kPinSdD2 = 41;
465 static constexpr int kPinSdD3 = 42;
466 // TF_VCC LDO channel, from guition-jc4880p4-bsp; not currently driven by
467 // begin() - see class doc note on SD card power.
468 static constexpr int kSdLdoChannel = 4;
469
470 // --- display geometry (native portrait) --------------------------------
471 static constexpr int kDisplayWidth = 480;
472 static constexpr int kDisplayHeight = 800;
473
474 // --- Display pins/config (ST7701S MIPI-DSI), from
475 // guition-jc4880p4-bsp's board_p4_pins.h/board_p4.c ---------------------
476 static constexpr int8_t kPinLcdRst = 5;
477 static constexpr int8_t kPinLcdBacklight = 23;
478 static constexpr int8_t kDsiPhyLdoChan = 3;
479 static constexpr uint16_t kDsiPhyLdoMv = 2500;
480
481 // --- Touch I2C pins (GT911), same source ---------------------------------
482 static constexpr int8_t kPinTouchRst = 3;
483 static constexpr int8_t kPinTouchInt = -1; // unused/polled on this board
484
485 // --- WiFi SDIO pins (SDIO1), same source ---------------------------------
486 static constexpr int kPinWifiSdioClk = 18;
487 static constexpr int kPinWifiSdioCmd = 19;
488 static constexpr int kPinWifiSdioD0 = 14;
489 static constexpr int kPinWifiSdioD1 = 15;
490 static constexpr int kPinWifiSdioD2 = 16;
491 static constexpr int kPinWifiSdioD3 = 17;
492 static constexpr int kPinWifiC6Reset = 54;
493
494 // --- Battery ADC Config --------------------------------------------------
495 static constexpr adc_channel_t kAdcChannel = ADC_CHANNEL_4;
496 static constexpr adc_atten_t kAdcAtten = ADC_ATTEN_DB_12;
497 static constexpr int kVcMaxMv = 2450;
498 static constexpr int kVcMinMv = 2250;
499
500 ST7701Driver<RGB565> display_{kPinLcdRst, kPinLcdBacklight, kDisplayWidth,
501 kDisplayHeight, kDsiPhyLdoChan, kDsiPhyLdoMv};
502 TouchDriverGT911 touch_{Wire, kPinTouchRst, kPinTouchInt};
503
504 I2SPins i2s_{kPinI2sMclk, kPinI2sBck, kPinI2sWs, kPinI2sDout, kPinI2sDin};
505 LEDPins led_{};
506
507 adc_oneshot_unit_handle_t adc_handle_ = nullptr;
508 adc_cali_handle_t cali_handle_ = nullptr;
509 bool adc_initialized_ = false;
510
511 bool setupWifi() {
512 return hostedSetPins(kPinWifiSdioClk, kPinWifiSdioCmd, kPinWifiSdioD0,
513 kPinWifiSdioD1, kPinWifiSdioD2, kPinWifiSdioD3,
514 kPinWifiC6Reset);
515 }
516
517 void initAdc() {
518 adc_initialized_ = true;
519
520 adc_oneshot_unit_init_cfg_t init_config = {
521 .unit_id = ADC_UNIT_2,
522 .ulp_mode = ADC_ULP_MODE_DISABLE,
523 };
524 if (adc_oneshot_new_unit(&init_config, &adc_handle_) != ESP_OK) return;
525
526 adc_oneshot_chan_cfg_t config = {
527 .atten = kAdcAtten,
528 .bitwidth = ADC_BITWIDTH_DEFAULT,
529 };
530 adc_oneshot_config_channel(adc_handle_, kAdcChannel, &config);
531
532#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
533 adc_cali_curve_fitting_config_t cali_config = {
534 .unit_id = ADC_UNIT_2,
535 .chan = kAdcChannel,
536 .atten = kAdcAtten,
537 .bitwidth = ADC_BITWIDTH_DEFAULT,
538 };
539 if (adc_cali_create_scheme_curve_fitting(&cali_config, &cali_handle_) ==
540 ESP_OK) {
541 return;
542 }
543#endif
544
545#if ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED
546 adc_cali_line_fitting_config_t cali_config = {
547 .unit_id = ADC_UNIT_2,
548 .atten = kAdcAtten,
549 .bitwidth = ADC_BITWIDTH_DEFAULT,
550 };
551 adc_cali_create_scheme_line_fitting(&cali_config, &cali_handle_);
552#endif
553 }
554};
555
556using JC4880P443C_I_W = LCDBoardGuitionESP32H4_4_3Display;
557
558#endif // TINYGPU_HAS_ESP_LCD_DSI
559
560} // namespace tinygpu
561
562#endif // ESP32