Skip to content

Commit 9f2fed5

Browse files
authored
Merge pull request #10689 from natheihei/esp32s3_touch_lcd_147
board: add board waveshare_esp32_s3_touch_lcd_1_47
2 parents 6fe19f7 + b076e08 commit 9f2fed5

File tree

5 files changed

+253
-0
lines changed

5 files changed

+253
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 natheihei
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/microcontroller/Pin.h"
10+
#include "shared-bindings/busio/SPI.h"
11+
#include "shared-bindings/fourwire/FourWire.h"
12+
#include "shared-module/displayio/__init__.h"
13+
#include "shared-module/displayio/mipi_constants.h"
14+
#include "shared-bindings/board/__init__.h"
15+
16+
#define DELAY 0x80
17+
18+
// Driver is JD9853
19+
// 172 X 320 Pixels RGB 18-bit
20+
// Init sequence converted from Arduino example
21+
22+
uint8_t display_init_sequence[] = {
23+
// Command: 0x11 (SLPOUT: Sleep Out)
24+
// Description: Exits sleep mode. A 120ms delay is added for the power supply and clock circuits to stabilize.
25+
0x11, 0 | DELAY, 120,
26+
27+
0xDF, 2, 0x98, 0x53,
28+
0xB2, 1, 0x23,
29+
30+
0xB7, 4, 0x00, 0x47, 0x00, 0x6F,
31+
0xBB, 6, 0x1C, 0x1A, 0x55, 0x73, 0x63, 0xF0,
32+
0xC0, 2, 0x44, 0xA4,
33+
0xC1, 1, 0x16,
34+
0xC3, 8, 0x7D, 0x07, 0x14, 0x06, 0xCF, 0x71, 0x72, 0x77,
35+
0xC4, 12, 0x00, 0x00, 0xA0, 0x79, 0x0B, 0x0A, 0x16, 0x79, 0x0B, 0x0A, 0x16, 0x82,
36+
37+
0xC8, 32, 0x3F, 0x32, 0x29, 0x29, 0x27, 0x2B, 0x27, 0x28, 0x28, 0x26, 0x25, 0x17, 0x12, 0x0D, 0x04, 0x00,
38+
0x3F, 0x32, 0x29, 0x29, 0x27, 0x2B, 0x27, 0x28, 0x28, 0x26, 0x25, 0x17, 0x12, 0x0D, 0x04, 0x00,
39+
40+
0xD0, 5, 0x04, 0x06, 0x6B, 0x0F, 0x00,
41+
0xD7, 2, 0x00, 0x30,
42+
0xE6, 1, 0x14,
43+
0xDE, 1, 0x01,
44+
45+
0xB7, 5, 0x03, 0x13, 0xEF, 0x35, 0x35,
46+
0xC1, 3, 0x14, 0x15, 0xC0,
47+
0xC2, 2, 0x06, 0x3A,
48+
0xC4, 2, 0x72, 0x12,
49+
0xBE, 1, 0x00,
50+
0xDE, 1, 0x02,
51+
52+
0xE5, 3, 0x00, 0x02, 0x00,
53+
0xE5, 3, 0x01, 0x02, 0x00,
54+
55+
0xDE, 1, 0x00,
56+
57+
// Command: 0x35 (TEON: Tearing Effect Line ON)
58+
// Description: Turns on the Tearing Effect output signal.
59+
0x35, 1, 0x00,
60+
61+
// Command: 0x3A (COLMOD: Pixel Format Set)
62+
// Description: Sets the pixel format for the MCU interface.
63+
0x3A, 1, 0x05,
64+
65+
// Command: 0x2A (CASET: Column Address Set)
66+
// Description: Defines the accessible column range in frame memory.
67+
0x2A, 4, 0x00, 0x22, 0x00, 0xCD,
68+
69+
// Command: 0x2B (PASET: Page Address Set)
70+
// Description: Defines the accessible page (row) range.
71+
0x2B, 4, 0x00, 0x00, 0x01, 0x3F,
72+
73+
0xDE, 1, 0x02,
74+
0xE5, 3, 0x00, 0x02, 0x00,
75+
0xDE, 1, 0x00,
76+
77+
// Command: 0x36 (MADCTL: Memory Access Control)
78+
// Description: Sets the read/write scanning direction of the frame memory.
79+
0x36, 1, 0x00,
80+
81+
// Command: 0x21 (INVON: Display Inversion ON)
82+
// 0x21, 0 | DELAY, 10,
83+
84+
// Command: 0x29 (DISPON: Display ON)
85+
// Description: Turns the display on by enabling output from the frame memory.
86+
0x29, 0,
87+
};
88+
89+
static void display_init(void) {
90+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
91+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
92+
bus->base.type = &fourwire_fourwire_type;
93+
94+
common_hal_fourwire_fourwire_construct(
95+
bus,
96+
spi,
97+
&pin_GPIO45, // DC
98+
&pin_GPIO21, // CS
99+
&pin_GPIO40, // RST
100+
80000000, // baudrate
101+
0, // polarity
102+
0 // phase
103+
);
104+
105+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
106+
display->base.type = &busdisplay_busdisplay_type;
107+
108+
common_hal_busdisplay_busdisplay_construct(
109+
display,
110+
bus,
111+
172, // width (after rotation)
112+
320, // height (after rotation)
113+
34, // column start
114+
0, // row start
115+
0, // rotation
116+
16, // color depth
117+
false, // grayscale
118+
false, // pixels in a byte share a row. Only valid for depths < 8
119+
1, // bytes per cell. Only valid for depths < 8
120+
false, // reverse_pixels_in_byte. Only valid for depths < 8
121+
true, // reverse_pixels_in_word
122+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
123+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
124+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
125+
display_init_sequence,
126+
sizeof(display_init_sequence),
127+
&pin_GPIO46, // backlight pin
128+
NO_BRIGHTNESS_COMMAND,
129+
1.0f, // brightness
130+
false, // single_byte_bounds
131+
false, // data_as_commands
132+
true, // auto_refresh
133+
60, // native_frames_per_second
134+
true, // backlight_on_high
135+
false, // SH1107_addressing
136+
50000 // backlight pwm frequency
137+
);
138+
}
139+
140+
void board_init(void) {
141+
// Display
142+
display_init();
143+
}
144+
145+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 natheihei
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Micropython setup
10+
11+
#define MICROPY_HW_BOARD_NAME "Waveshare ESP32-S3 Touch LCD 1.47"
12+
#define MICROPY_HW_MCU_NAME "ESP32S3"
13+
14+
#define CIRCUITPY_BOARD_UART (1)
15+
#define CIRCUITPY_BOARD_UART_PIN {{.rx = &pin_GPIO44, .tx = &pin_GPIO43}}
16+
17+
#define CIRCUITPY_BOARD_I2C (1)
18+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO41, .sda = &pin_GPIO42}} /* for Touchscreen */
19+
20+
#define CIRCUITPY_BOARD_SPI (2)
21+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO38, .mosi = &pin_GPIO39}, /* for LCD display */ \
22+
{.clock = &pin_GPIO16, .mosi = &pin_GPIO15, .miso = &pin_GPIO17} /* for SD Card */}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
USB_VID = 0x303A
2+
USB_PID = 0x8325
3+
USB_PRODUCT = "ESP32-S3-Touch-LCD-1.47"
4+
USB_MANUFACTURER = "Waveshare Electronics"
5+
6+
IDF_TARGET = esp32s3
7+
8+
CIRCUITPY_ESP_FLASH_MODE = qio
9+
CIRCUITPY_ESP_FLASH_FREQ = 80m
10+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
11+
12+
CIRCUITPY_ESP_PSRAM_SIZE = 8MB
13+
CIRCUITPY_ESP_PSRAM_MODE = opi
14+
CIRCUITPY_ESP_PSRAM_FREQ = 80m
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 natheihei
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
#include "shared-module/displayio/__init__.h"
9+
10+
CIRCUITPY_BOARD_BUS_SINGLETON(touch_i2c, i2c, 0)
11+
CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1)
12+
13+
static const mp_rom_map_elem_t board_module_globals_table[] = {
14+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
15+
16+
// UART
17+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
18+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
19+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
20+
21+
// GPIO
22+
{ MP_ROM_QSTR(MP_QSTR_GPIO1), MP_ROM_PTR(&pin_GPIO1) },
23+
{ MP_ROM_QSTR(MP_QSTR_GPIO2), MP_ROM_PTR(&pin_GPIO2) },
24+
{ MP_ROM_QSTR(MP_QSTR_GPIO3), MP_ROM_PTR(&pin_GPIO3) },
25+
{ MP_ROM_QSTR(MP_QSTR_GPIO4), MP_ROM_PTR(&pin_GPIO4) },
26+
{ MP_ROM_QSTR(MP_QSTR_GPIO5), MP_ROM_PTR(&pin_GPIO5) },
27+
{ MP_ROM_QSTR(MP_QSTR_GPIO6), MP_ROM_PTR(&pin_GPIO6) },
28+
{ MP_ROM_QSTR(MP_QSTR_GPIO7), MP_ROM_PTR(&pin_GPIO7) },
29+
{ MP_ROM_QSTR(MP_QSTR_GPIO8), MP_ROM_PTR(&pin_GPIO8) },
30+
{ MP_ROM_QSTR(MP_QSTR_GPIO9), MP_ROM_PTR(&pin_GPIO9) },
31+
{ MP_ROM_QSTR(MP_QSTR_GPIO10), MP_ROM_PTR(&pin_GPIO10) },
32+
{ MP_ROM_QSTR(MP_QSTR_GPIO11), MP_ROM_PTR(&pin_GPIO11) },
33+
34+
// I2C (occupied by Touch I2C)
35+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO41) },
36+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO42) },
37+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
38+
39+
// SD Card
40+
{ MP_ROM_QSTR(MP_QSTR_SD_CMD), MP_ROM_PTR(&pin_GPIO15) },
41+
{ MP_ROM_QSTR(MP_QSTR_SD_CLK), MP_ROM_PTR(&pin_GPIO16) },
42+
{ MP_ROM_QSTR(MP_QSTR_SD_D0), MP_ROM_PTR(&pin_GPIO17) },
43+
{ MP_ROM_QSTR(MP_QSTR_SD_D1), MP_ROM_PTR(&pin_GPIO18) },
44+
{ MP_ROM_QSTR(MP_QSTR_SD_D2), MP_ROM_PTR(&pin_GPIO13) },
45+
{ MP_ROM_QSTR(MP_QSTR_SD_D3), MP_ROM_PTR(&pin_GPIO14) },
46+
// CLK, CMD, D0 is also included in the SPI object as its MISO pin, MOSI pin, and SCK pin respectively
47+
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) },
48+
49+
// AXS5106L Touch
50+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_I2C), MP_ROM_PTR(&board_touch_i2c_obj) },
51+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_RST), MP_ROM_PTR(&pin_GPIO47) },
52+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_IRQ), MP_ROM_PTR(&pin_GPIO48) },
53+
54+
// JD9853 LCD Display
55+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
56+
57+
};
58+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Espressif IoT Development Framework Configuration
3+
#
4+
#
5+
# Component config
6+
#
7+
#
8+
# LWIP
9+
#
10+
# end of LWIP
11+
12+
# end of Component config
13+
14+
# end of Espressif IoT Development Framework Configuration

0 commit comments

Comments
 (0)