Skip to content

Commit dffd734

Browse files
author
liduanjun
committed
feat: add board waveshare_esp32_s3_lcd_1_47
1 parent 5202246 commit dffd734

File tree

5 files changed

+231
-0
lines changed

5 files changed

+231
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2025 Benjamin Shockley
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 ST7789V3
19+
// Display Panel is LBS147TC-IF15
20+
// 172 X 320 Pixels RGB 18-bit
21+
22+
uint8_t display_init_sequence[] = {
23+
0x01, 0 | DELAY, 120,
24+
0x11, 0 | DELAY, 120,
25+
0x13, 0,
26+
0x36, 1, 0x00,
27+
0x3A, 1 | DELAY, 0x05, 10,
28+
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
29+
0xB7, 1, 0x35,
30+
0xBB, 1, 0x20,
31+
0xC0, 1, 0x2C,
32+
0xC2, 2, 0x01, 0xFF,
33+
0xC3, 1, 0x13,
34+
0xC4, 1, 0x20,
35+
0xC6, 1, 0x0F,
36+
0xD0, 2, 0xA4, 0xA1,
37+
0xE0, 14, 0xF0, 0x00, 0x04, 0x04, 0x04, 0x05, 0x29, 0x33, 0x3E, 0x38, 0x12, 0x12, 0x28, 0x30,
38+
0xE1, 14, 0xF0, 0x07, 0x0A, 0x0D, 0x0B, 0x07, 0x28, 0x33, 0x3E, 0x36, 0x14, 0x14, 0x29, 0x32,
39+
0x21, 0,
40+
0x29, 0 | DELAY, 255,
41+
};
42+
43+
static void display_init(void) {
44+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
45+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
46+
bus->base.type = &fourwire_fourwire_type;
47+
48+
common_hal_fourwire_fourwire_construct(
49+
bus,
50+
spi,
51+
&pin_GPIO41, // DC
52+
&pin_GPIO42, // CS
53+
&pin_GPIO39, // RST
54+
80000000, // baudrate
55+
0, // polarity
56+
0 // phase
57+
);
58+
59+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
60+
display->base.type = &busdisplay_busdisplay_type;
61+
62+
common_hal_busdisplay_busdisplay_construct(
63+
display,
64+
bus,
65+
172, // width (after rotation)
66+
320, // height (after rotation)
67+
34, // column start
68+
0, // row start
69+
0, // rotation
70+
16, // color depth
71+
false, // grayscale
72+
false, // pixels in a byte share a row. Only valid for depths < 8
73+
1, // bytes per cell. Only valid for depths < 8
74+
false, // reverse_pixels_in_byte. Only valid for depths < 8
75+
true, // reverse_pixels_in_word
76+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
77+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
78+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
79+
display_init_sequence,
80+
sizeof(display_init_sequence),
81+
&pin_GPIO48, // backlight pin
82+
NO_BRIGHTNESS_COMMAND,
83+
1.0f, // brightness
84+
false, // single_byte_bounds
85+
false, // data_as_commands
86+
true, // auto_refresh
87+
60, // native_frames_per_second
88+
true, // backlight_on_high
89+
false, // SH1107_addressing
90+
50000 // backlight pwm frequency
91+
);
92+
}
93+
94+
void board_init(void) {
95+
// Display
96+
display_init();
97+
}
98+
99+
// 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 Benjamin Shockley
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Micropython setup
10+
11+
#define MICROPY_HW_BOARD_NAME "Waveshare ESP32-S3 LCD 1.47"
12+
#define MICROPY_HW_MCU_NAME "ESP32S3"
13+
14+
#define DEFAULT_UART_BUS_RX (&pin_GPIO44)
15+
#define DEFAULT_UART_BUS_TX (&pin_GPIO43)
16+
17+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO17)
18+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO16)
19+
20+
#define CIRCUITPY_BOARD_SPI (2)
21+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO40, .mosi = &pin_GPIO45}, \
22+
{.clock = &pin_GPIO14, .mosi = &pin_GPIO15, .miso = &pin_GPIO16}}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
USB_VID = 0x303A
2+
USB_PID = 0x828B
3+
USB_PRODUCT = "ESP32-S3-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
15+
CIRCUITPY_BUILD_EXTENSIONS = bin,uf2
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
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(sd_spi, spi, 1)
11+
12+
static const mp_rom_map_elem_t board_module_globals_table[] = {
13+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
14+
15+
// Button
16+
{ MP_ROM_QSTR(MP_QSTR_BTN), MP_ROM_PTR(&pin_GPIO0) },
17+
{ MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) },
18+
19+
// RGB LED
20+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO38) },
21+
{ MP_ROM_QSTR(MP_QSTR_GP38), MP_ROM_PTR(&pin_GPIO38) },
22+
23+
// 7-12 LCD
24+
// LCD Backlight
25+
{ MP_ROM_QSTR(MP_QSTR_GP48), MP_ROM_PTR(&pin_GPIO48) },
26+
// LCD DC
27+
{ MP_ROM_QSTR(MP_QSTR_GP41), MP_ROM_PTR(&pin_GPIO41) },
28+
// LCD RST
29+
{ MP_ROM_QSTR(MP_QSTR_GP39), MP_ROM_PTR(&pin_GPIO39) },
30+
// LCD CS
31+
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_GPIO42) },
32+
{ MP_ROM_QSTR(MP_QSTR_GP42), MP_ROM_PTR(&pin_GPIO42) },
33+
// LCD MOSI
34+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO45) },
35+
{ MP_ROM_QSTR(MP_QSTR_GP45), MP_ROM_PTR(&pin_GPIO45) },
36+
// LCD SCK
37+
{ MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO40) },
38+
{ MP_ROM_QSTR(MP_QSTR_GP40), MP_ROM_PTR(&pin_GPIO40) },
39+
40+
// 14-21 SD
41+
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) },
42+
{ MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) },
43+
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) },
44+
{ MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) },
45+
{ MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) },
46+
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
47+
48+
// 43-44 UART
49+
{ MP_ROM_QSTR(MP_QSTR_GP43), MP_ROM_PTR(&pin_GPIO43) },
50+
{ MP_ROM_QSTR(MP_QSTR_GP44), MP_ROM_PTR(&pin_GPIO44) },
51+
52+
// UART
53+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
54+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
55+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
56+
57+
// I2C
58+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO17) },
59+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO16) },
60+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
61+
62+
// SD Card
63+
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO14) },
64+
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO15) },
65+
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO16) },
66+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO21) },
67+
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) },
68+
// Pin 38 is for the SDIO interface, and therefore not included in the SPI object
69+
70+
// LCD
71+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO45) },
72+
{ MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO40) },
73+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO42) },
74+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO39) },
75+
{ MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO48) },
76+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO41) },
77+
{ MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_spi_obj) },
78+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
79+
80+
};
81+
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy