Skip to content

Commit 1ef4e3c

Browse files
committed
Add Adafruit TFT Experiment (rev A)
There will be a revision but get the basics in for now. This successfully displays on a TL040HDS20-B1502A screen with: ``` import board from framebufferio import FramebufferDisplay from dotclockframebuffer import DotClockFramebuffer from displayio import release_displays tft_pins = board.TFT tft_timings = { "frequency": 6_500_000, "width": 720, "height": 720, "hsync_pulse_width": 20, "hsync_front_porch": 40, "hsync_back_porch": 40, "vsync_pulse_width": 10, "vsync_front_porch": 40, "vsync_back_porch": 40, "hsync_idle_low": False, "vsync_idle_low": False, "de_idle_high": False, "pclk_active_high": False, "pclk_idle_high": False, } release_displays() fb = DotClockFramebuffer(**tft_pins, **tft_timings) disp = FramebufferDisplay(fb) ```
1 parent 7dbf9a9 commit 1ef4e3c

File tree

5 files changed

+215
-0
lines changed

5 files changed

+215
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
#include "shared-bindings/microcontroller/Pin.h"
30+
31+
void board_init(void) {
32+
}
33+
34+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
// Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "Adafruit-ESP32-S3-RGB-TFT-Experiment"
30+
#define MICROPY_HW_MCU_NAME "ESP32S3"
31+
32+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3)
33+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO6)
34+
35+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO7)
36+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO6)
37+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO16)
38+
39+
// UART pins attached to the USB-serial converter chip
40+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO43)
41+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO44)
42+
43+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO4)
44+
45+
#define DOUBLE_TAP_PIN (&pin_GPIO5)
46+
47+
// a 1024x768 16BPP framebuffer + some breathing room
48+
#define DEFAULT_RESERVED_PSRAM (1024 * 1024 * 2)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x8148
3+
USB_PRODUCT = "Adafruit-ESP32-S3-RGB-TFT-Experiment"
4+
USB_MANUFACTURER = "Adafruit"
5+
6+
IDF_TARGET = esp32s3
7+
8+
CIRCUITPY_ESP_FLASH_MODE = dio
9+
CIRCUITPY_ESP_FLASH_FREQ = 80m
10+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
11+
12+
CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#include "py/objtuple.h"
2+
#include "shared-bindings/board/__init__.h"
3+
4+
STATIC const mp_rom_obj_tuple_t tft_r_pins = {
5+
{&mp_type_tuple},
6+
5,
7+
{
8+
MP_ROM_PTR(&pin_GPIO13),
9+
MP_ROM_PTR(&pin_GPIO12),
10+
MP_ROM_PTR(&pin_GPIO11),
11+
MP_ROM_PTR(&pin_GPIO10),
12+
MP_ROM_PTR(&pin_GPIO46),
13+
}
14+
};
15+
16+
STATIC const mp_rom_obj_tuple_t tft_g_pins = {
17+
{&mp_type_tuple},
18+
6,
19+
{
20+
MP_ROM_PTR(&pin_GPIO5), // XXX fixed in rev b
21+
MP_ROM_PTR(&pin_GPIO45),
22+
MP_ROM_PTR(&pin_GPIO48),
23+
MP_ROM_PTR(&pin_GPIO47),
24+
MP_ROM_PTR(&pin_GPIO21),
25+
MP_ROM_PTR(&pin_GPIO14),
26+
}
27+
};
28+
29+
STATIC const mp_rom_obj_tuple_t tft_b_pins = {
30+
{&mp_type_tuple},
31+
5,
32+
{
33+
MP_ROM_PTR(&pin_GPIO5), // XXX fixed in rev b
34+
MP_ROM_PTR(&pin_GPIO5), // XXX fixed in rev b
35+
MP_ROM_PTR(&pin_GPIO40),
36+
MP_ROM_PTR(&pin_GPIO39),
37+
MP_ROM_PTR(&pin_GPIO38),
38+
}
39+
};
40+
41+
STATIC const mp_rom_map_elem_t tft_table[] = {
42+
{ MP_ROM_QSTR(MP_QSTR_de), MP_ROM_PTR(&pin_GPIO2) },
43+
{ MP_ROM_QSTR(MP_QSTR_vsync), MP_ROM_PTR(&pin_GPIO42) },
44+
{ MP_ROM_QSTR(MP_QSTR_hsync), MP_ROM_PTR(&pin_GPIO41) },
45+
{ MP_ROM_QSTR(MP_QSTR_dclk), MP_ROM_PTR(&pin_GPIO1) },
46+
{ MP_ROM_QSTR(MP_QSTR_red), MP_ROM_PTR(&tft_r_pins) },
47+
{ MP_ROM_QSTR(MP_QSTR_green), MP_ROM_PTR(&tft_g_pins) },
48+
{ MP_ROM_QSTR(MP_QSTR_blue), MP_ROM_PTR(&tft_b_pins) },
49+
};
50+
MP_DEFINE_CONST_DICT(tft_dict, tft_table);
51+
52+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
53+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
54+
55+
{ MP_ROM_QSTR(MP_QSTR_TFT), MP_ROM_PTR(&tft_dict) },
56+
57+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(MICROPY_HW_NEOPIXEL) },
58+
59+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
60+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
61+
62+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(DEFAULT_I2C_BUS_SDA) },
63+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(DEFAULT_I2C_BUS_SCL) },
64+
65+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(DEFAULT_SPI_BUS_MOSI) },
66+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(DEFAULT_SPI_BUS_MISO) },
67+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(DEFAULT_SPI_BUS_SCK) },
68+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO16) },
69+
70+
// boot mode button can be used in SW as well
71+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_UP), MP_ROM_PTR(&pin_GPIO0) },
72+
{ MP_ROM_QSTR(MP_QSTR_BUTTON_DOWN), MP_ROM_PTR(&pin_GPIO5) },
73+
74+
{ MP_ROM_QSTR(MP_QSTR_TP_IRQ), MP_ROM_PTR(&pin_GPIO9) },
75+
76+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
77+
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
78+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
79+
};
80+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
2+
#
3+
# SPI RAM config
4+
#
5+
# CONFIG_SPIRAM_MODE_QUAD is not set
6+
CONFIG_SPIRAM_MODE_OCT=y
7+
CONFIG_SPIRAM_TYPE_AUTO=y
8+
# end of SPI RAM config
9+
10+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
11+
#
12+
# PSRAM Clock and CS IO for ESP32S3
13+
#
14+
CONFIG_DEFAULT_PSRAM_CS_IO=26
15+
# end of PSRAM Clock and CS IO for ESP32S3
16+
17+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
18+
# CONFIG_SPIRAM_RODATA is not set
19+
CONFIG_SPIRAM_SPEED_80M=y
20+
# CONFIG_SPIRAM_SPEED_40M is not set
21+
CONFIG_SPIRAM=y
22+
CONFIG_SPIRAM_BOOT_INIT=y
23+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
24+
CONFIG_SPIRAM_USE_MEMMAP=y
25+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
26+
# CONFIG_SPIRAM_USE_MALLOC is not set
27+
CONFIG_SPIRAM_MEMTEST=y
28+
#
29+
# LWIP
30+
#
31+
CONFIG_LWIP_LOCAL_HOSTNAME="matouch-tft"
32+
# end of LWIP
33+
#
34+
# CONFIG_ESP_CONSOLE_NONE is not set
35+
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
36+
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
37+
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
38+
CONFIG_ESP_CONSOLE_UART_NUM=0
39+
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
40+
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
41+
CONFIG_ESP_CONSOLE_UART=y

0 commit comments

Comments
 (0)