forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add Waveshare ESP32S3 Touch LCD 2.8inch display board #10691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2_8/board.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "supervisor/board.h" | ||
| #include "mpconfigboard.h" | ||
| #include "shared-bindings/busio/SPI.h" | ||
| #include "shared-bindings/fourwire/FourWire.h" | ||
| #include "shared-bindings/microcontroller/Pin.h" | ||
| #include "shared-module/displayio/__init__.h" | ||
| #include "shared-module/displayio/mipi_constants.h" | ||
| #include "shared-bindings/board/__init__.h" | ||
|
|
||
| #define DELAY 0x80 | ||
|
|
||
| // display init sequence according to LilyGO example app | ||
| uint8_t display_init_sequence[] = { | ||
| 0x01, DELAY, 0x96, // _SWRESET and Delay 150ms | ||
| 0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms | ||
| 0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD and Delay 10ms | ||
| 0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms | ||
| 0x13, DELAY, 0x0A, // _NORON and Delay 10ms | ||
| 0x36, 0x01, 0x60, // _MADCTL | ||
| 0x29, DELAY, 0xFF, // _DISPON and Delay 500ms | ||
| }; | ||
|
|
||
| void board_init(void) { | ||
| busio_spi_obj_t *spi = common_hal_board_create_spi(0); | ||
| fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; | ||
| bus->base.type = &fourwire_fourwire_type; | ||
|
|
||
| common_hal_fourwire_fourwire_construct( | ||
| bus, | ||
| spi, | ||
| &pin_GPIO41, // DC | ||
| &pin_GPIO42, // CS | ||
| &pin_GPIO39, // RST | ||
| 40000000, // baudrate | ||
| 0, // polarity | ||
| 0 // phase | ||
| ); | ||
| busdisplay_busdisplay_obj_t *display = &allocate_display()->display; | ||
| display->base.type = &busdisplay_busdisplay_type; | ||
|
|
||
| common_hal_busdisplay_busdisplay_construct( | ||
| display, | ||
| bus, | ||
| 320, // width (after rotation) | ||
| 240, // height (after rotation) | ||
| 0, // column start | ||
| 0, // row start | ||
| 0, // rotation | ||
| 16, // color depth | ||
| false, // grayscale | ||
| false, // pixels in a byte share a row. Only valid for depths < 8 | ||
| 1, // bytes per cell. Only valid for depths < 8 | ||
| false, // reverse_pixels_in_byte. Only valid for depths < 8 | ||
| true, // reverse_pixels_in_word | ||
| MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command | ||
| MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command | ||
| MIPI_COMMAND_WRITE_MEMORY_START, // write memory command | ||
| display_init_sequence, | ||
| sizeof(display_init_sequence), | ||
| &pin_GPIO5, // backlight pin | ||
| NO_BRIGHTNESS_COMMAND, | ||
| 1.0f, // brightness | ||
| false, // single_byte_bounds | ||
| false, // data_as_commands | ||
| true, // auto_refresh | ||
| 60, // native_frames_per_second | ||
| true, // backlight_on_high | ||
| false, // SH1107_addressing | ||
| 50000 // backlight pwm frequency | ||
| ); | ||
| } |
19 changes: 19 additions & 0 deletions
19
ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2_8/mpconfigboard.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025 Neradoc | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #pragma once | ||
|
|
||
| #define MICROPY_HW_BOARD_NAME "Waveshare ESP32-S3 Touch LCD 2.8" | ||
| #define MICROPY_HW_MCU_NAME "ESP32S3" | ||
|
|
||
| #define CIRCUITPY_BOARD_I2C (1) | ||
| #define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO3, .sda = &pin_GPIO1}} | ||
|
|
||
| #define CIRCUITPY_BOARD_SPI (1) | ||
| #define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO40, .mosi = &pin_GPIO45, .miso = &pin_GPIO46}} | ||
|
|
||
| #define DEFAULT_UART_BUS_RX (&pin_GPIO44) | ||
| #define DEFAULT_UART_BUS_TX (&pin_GPIO43) |
14 changes: 14 additions & 0 deletions
14
ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2_8/mpconfigboard.mk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| USB_VID = 0x303A | ||
| USB_PID = 0x825F | ||
| USB_MANUFACTURER = "Waveshare Electronics" | ||
| USB_PRODUCT = "ESP32-S3 Touch LCD 2.8" | ||
|
|
||
| IDF_TARGET = esp32s3 | ||
|
|
||
| CIRCUITPY_ESP_FLASH_MODE = qio | ||
| CIRCUITPY_ESP_FLASH_FREQ = 80m | ||
| CIRCUITPY_ESP_FLASH_SIZE = 16MB | ||
|
|
||
| CIRCUITPY_ESP_PSRAM_SIZE = 8MB | ||
| CIRCUITPY_ESP_PSRAM_MODE = opi | ||
| CIRCUITPY_ESP_PSRAM_FREQ = 80m |
109 changes: 109 additions & 0 deletions
109
ports/espressif/boards/waveshare_esp32_s3_touch_lcd_2_8/pins.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // This file is part of the CircuitPython project: https://circuitpython.org | ||
| // | ||
| // SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "shared-bindings/board/__init__.h" | ||
| #include "shared-module/displayio/__init__.h" | ||
|
|
||
| static const mp_rom_map_elem_t board_module_globals_table[] = { | ||
| CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS | ||
|
|
||
| // LCD (SPI0) | ||
| { MP_ROM_QSTR(MP_QSTR_LCD_SCK), MP_ROM_PTR(&pin_GPIO40) }, | ||
| { MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO45) }, | ||
| { MP_ROM_QSTR(MP_QSTR_LCD_MISO), MP_ROM_PTR(&pin_GPIO46) }, | ||
| { MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO42) }, | ||
| { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO41) }, | ||
| { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO39) }, | ||
| { MP_ROM_QSTR(MP_QSTR_LCD_BL), MP_ROM_PTR(&pin_GPIO5) }, // PWM-capable | ||
|
|
||
| // microSD (SPI1) | ||
| { MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO14) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO17) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO16) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO21) }, | ||
|
|
||
| // Touch panel (I2C0) | ||
| { MP_ROM_QSTR(MP_QSTR_TP_SCL), MP_ROM_PTR(&pin_GPIO3) }, | ||
| { MP_ROM_QSTR(MP_QSTR_TP_SDA), MP_ROM_PTR(&pin_GPIO1) }, | ||
| { MP_ROM_QSTR(MP_QSTR_TP_RST), MP_ROM_PTR(&pin_GPIO2) }, | ||
| { MP_ROM_QSTR(MP_QSTR_TP_INT), MP_ROM_PTR(&pin_GPIO4) }, | ||
|
|
||
| // IMU (I2C1) | ||
| { MP_ROM_QSTR(MP_QSTR_IMU_SCL), MP_ROM_PTR(&pin_GPIO10) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IMU_SDA), MP_ROM_PTR(&pin_GPIO11) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IMU_INT2), MP_ROM_PTR(&pin_GPIO12) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IMU_INT1), MP_ROM_PTR(&pin_GPIO13) }, | ||
|
|
||
| // I2S Audio | ||
| { MP_ROM_QSTR(MP_QSTR_I2S_BCK), MP_ROM_PTR(&pin_GPIO48) }, | ||
| { MP_ROM_QSTR(MP_QSTR_I2S_DIN), MP_ROM_PTR(&pin_GPIO47) }, | ||
| { MP_ROM_QSTR(MP_QSTR_I2S_LRCK), MP_ROM_PTR(&pin_GPIO38) }, | ||
|
|
||
| // Battery management | ||
| { MP_ROM_QSTR(MP_QSTR_BAT_CONTROL), MP_ROM_PTR(&pin_GPIO7) }, // control pin | ||
| { MP_ROM_QSTR(MP_QSTR_BAT_PWR), MP_ROM_PTR(&pin_GPIO6) }, // Board name | ||
| { MP_ROM_QSTR(MP_QSTR_KEY_BAT), MP_ROM_PTR(&pin_GPIO6) }, // Schematics name | ||
| { MP_ROM_QSTR(MP_QSTR_BAT_ADC), MP_ROM_PTR(&pin_GPIO8) }, // VBAT sense (ADC) | ||
|
|
||
| // UART header | ||
| { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, // User accessible | ||
| { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, // User accessible | ||
|
|
||
| // I2C header | ||
| { MP_ROM_QSTR(MP_QSTR_I2C_SCL), MP_ROM_PTR(&pin_GPIO10) }, | ||
| { MP_ROM_QSTR(MP_QSTR_I2C_SDA), MP_ROM_PTR(&pin_GPIO11) }, | ||
|
|
||
| // Boot/User button | ||
| { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }, | ||
| { MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_GPIO0) }, // Optional Alias | ||
|
|
||
| // Primary bus pins | ||
| { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO40) }, // Primary SPI (LCD) | ||
| { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO45) }, | ||
| { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO46) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, // Primary I2C (TP) | ||
| { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO1) }, | ||
|
|
||
| // Objects | ||
| { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, | ||
|
|
||
| // Fallback mapping for all GPIO pins | ||
| { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, // User accessible | ||
| { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, // User accessible | ||
| { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, // User accessible | ||
| { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, // User accessible | ||
| { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, // User accessible | ||
| { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, // User accessible | ||
| { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, | ||
| { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, | ||
| }; | ||
| MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); | ||
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.