Merge pull request #8351 from jepler/dotclockframebuffer
Dotclockframebuffer
This commit is contained in:
commit
0928a95bb2
|
@ -1228,6 +1228,7 @@ msgid "Invalid %q"
|
|||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/microcontroller/Pin.c
|
||||
#: ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c
|
||||
#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
msgid "Invalid %q pin"
|
||||
|
@ -1382,6 +1383,10 @@ msgstr ""
|
|||
msgid "Must be a %q subclass."
|
||||
msgstr ""
|
||||
|
||||
#: ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c
|
||||
msgid "Must provide 5/6/5 RGB pins"
|
||||
msgstr ""
|
||||
|
||||
#: ports/mimxrt10xx/common-hal/busio/SPI.c shared-bindings/busio/SPI.c
|
||||
msgid "Must provide MISO or MOSI pin"
|
||||
msgstr ""
|
||||
|
|
11
main.c
11
main.c
|
@ -1042,6 +1042,10 @@ int __attribute__((used)) main(void) {
|
|||
set_safe_mode(SAFE_MODE_NO_CIRCUITPY);
|
||||
}
|
||||
|
||||
// We maybe can't initialize the heap until here, because on espressif port we need to be able to check for reserved psram in settings.toml
|
||||
// (but it's OK if this is a no-op due to the heap being initialized in port_init())
|
||||
set_safe_mode(port_heap_init(get_safe_mode()));
|
||||
|
||||
#if CIRCUITPY_ALARM
|
||||
// Record which alarm woke us up, if any.
|
||||
// common_hal_alarm_record_wake_alarm() should return a static, non-heap object
|
||||
|
@ -1171,6 +1175,13 @@ void gc_collect(void) {
|
|||
MP_WEAK void port_gc_collect() {
|
||||
}
|
||||
|
||||
// A port may initialize the heap in port_init but if it cannot (for instance
|
||||
// in espressif it must be done after CIRCUITPY is mounted) then it must provde
|
||||
// an implementation of this function.
|
||||
MP_WEAK safe_mode_t port_heap_init(safe_mode_t safe_mode_in) {
|
||||
return safe_mode_in;
|
||||
}
|
||||
|
||||
void NORETURN nlr_jump_fail(void *val) {
|
||||
reset_into_safe_mode(SAFE_MODE_NLR_JUMP_FAIL);
|
||||
while (true) {
|
||||
|
|
|
@ -6,14 +6,9 @@ set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf)
|
|||
|
||||
# The component list here determines what options we get in menuconfig and what the ninja file
|
||||
# can build.
|
||||
set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls mdns esp_event esp_adc_cal esp_netif esp_wifi lwip ulp wpa_supplicant freertos bt usb)
|
||||
set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls mdns esp_event esp_adc_cal esp_netif esp_wifi lwip ulp wpa_supplicant freertos bt usb esp32-camera esp_lcd)
|
||||
|
||||
if("${CIRCUITPY_ESPCAMERA}")
|
||||
message("Including esp32-camera")
|
||||
set(EXTRA_COMPONENT_DIRS "esp32-camera")
|
||||
list(APPEND COMPONENTS "esp32-camera")
|
||||
message("COMPONENTS = ${COMPONENTS}")
|
||||
endif()
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "esp32-camera")
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(circuitpython)
|
||||
|
|
|
@ -257,6 +257,11 @@ ifneq ($(CIRCUITPY_BLEIO),0)
|
|||
SRC_C += common-hal/_bleio/ble_events.c
|
||||
endif
|
||||
|
||||
ifneq ($(CIRCUITPY_DOTCLOCKFRAMEBUFFER),0)
|
||||
CFLAGS += -isystem esp-idf/components/esp_lcd/include
|
||||
CFLAGS += -isystem esp-idf/components/esp_lcd/interface
|
||||
endif
|
||||
|
||||
ifneq ($(CIRCUITPY_ESPCAMERA),0)
|
||||
SRC_CAMERA := \
|
||||
$(wildcard common-hal/espcamera/*.c) \
|
||||
|
@ -355,7 +360,7 @@ endif
|
|||
do-sdkconfig: $(BUILD)/esp-idf/config/sdkconfig.h
|
||||
QSTR_GLOBAL_REQUIREMENTS += $(BUILD)/esp-idf/config/sdkconfig.h
|
||||
$(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig CMakeLists.txt | $(BUILD)/esp-idf
|
||||
IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja -DCIRCUITPY_ESPCAMERA=$(CIRCUITPY_ESPCAMERA)
|
||||
IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja
|
||||
|
||||
# build a lib
|
||||
# Adding -d explain -j 1 -v to the ninja line will output debug info
|
||||
|
@ -393,6 +398,9 @@ endif
|
|||
ifneq ($(CIRCUITPY_ESPULP),0)
|
||||
ESP_IDF_COMPONENTS_LINK += ulp
|
||||
endif
|
||||
ifneq ($(CIRCUITPY_DOTCLOCKFRAMEBUFFER),0)
|
||||
ESP_IDF_COMPONENTS_LINK += esp_lcd
|
||||
endif
|
||||
|
||||
ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "Adafruit-ESP32-S3-RGB-TFT-Experiment"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S3"
|
||||
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8)
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO18)
|
||||
|
||||
// UART pins attached to the USB-serial converter chip
|
||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO43)
|
||||
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO44)
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO4) // also DBLTAP
|
||||
|
||||
#define DOUBLE_TAP_PIN (&pin_GPIO4) // also NEOPIXEL
|
||||
|
||||
// a 1024x768 16BPP framebuffer + some breathing room
|
||||
#define DEFAULT_RESERVED_PSRAM (1024 * 1024 * 2)
|
|
@ -0,0 +1,12 @@
|
|||
USB_VID = 0x239A
|
||||
USB_PID = 0x8148
|
||||
USB_PRODUCT = "Adafruit-ESP32-S3-RGB-TFT-Experiment"
|
||||
USB_MANUFACTURER = "Adafruit"
|
||||
|
||||
IDF_TARGET = esp32s3
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE = dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ = 80m
|
||||
CIRCUITPY_ESP_FLASH_SIZE = 16MB
|
||||
|
||||
CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
|
|
@ -0,0 +1,78 @@
|
|||
#include "py/objtuple.h"
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_r_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO11),
|
||||
MP_ROM_PTR(&pin_GPIO10),
|
||||
MP_ROM_PTR(&pin_GPIO9),
|
||||
MP_ROM_PTR(&pin_GPIO46),
|
||||
MP_ROM_PTR(&pin_GPIO3),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_g_pins = {
|
||||
{&mp_type_tuple},
|
||||
6,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO48),
|
||||
MP_ROM_PTR(&pin_GPIO47),
|
||||
MP_ROM_PTR(&pin_GPIO21),
|
||||
MP_ROM_PTR(&pin_GPIO14),
|
||||
MP_ROM_PTR(&pin_GPIO13),
|
||||
MP_ROM_PTR(&pin_GPIO12),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_b_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO40),
|
||||
MP_ROM_PTR(&pin_GPIO39),
|
||||
MP_ROM_PTR(&pin_GPIO38),
|
||||
MP_ROM_PTR(&pin_GPIO0),
|
||||
MP_ROM_PTR(&pin_GPIO45),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t tft_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_de), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync), MP_ROM_PTR(&pin_GPIO42) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync), MP_ROM_PTR(&pin_GPIO41) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_dclk), MP_ROM_PTR(&pin_GPIO1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_red), MP_ROM_PTR(&tft_r_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_green), MP_ROM_PTR(&tft_g_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_blue), MP_ROM_PTR(&tft_b_pins) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(tft_dict, tft_table);
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT), MP_ROM_PTR(&tft_dict) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(MICROPY_HW_NEOPIXEL) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(DEFAULT_I2C_BUS_SDA) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(DEFAULT_I2C_BUS_SCL) },
|
||||
|
||||
// I/O expander pin numbers
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_INT(0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_INT(1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_INT(2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TP_IRQ), MP_ROM_INT(3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BACKLIGHT), MP_ROM_INT(4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BTN_UP), MP_ROM_INT(5) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BTN_DN), MP_ROM_INT(6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_INT(7) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
|
@ -0,0 +1,41 @@
|
|||
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
|
||||
#
|
||||
# SPI RAM config
|
||||
#
|
||||
# CONFIG_SPIRAM_MODE_QUAD is not set
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_TYPE_AUTO=y
|
||||
# end of SPI RAM config
|
||||
|
||||
CONFIG_DEFAULT_PSRAM_CLK_IO=30
|
||||
#
|
||||
# PSRAM Clock and CS IO for ESP32S3
|
||||
#
|
||||
CONFIG_DEFAULT_PSRAM_CS_IO=26
|
||||
# end of PSRAM Clock and CS IO for ESP32S3
|
||||
|
||||
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
|
||||
# CONFIG_SPIRAM_RODATA is not set
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
# CONFIG_SPIRAM_SPEED_40M is not set
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
CONFIG_SPIRAM_USE_MEMMAP=y
|
||||
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
|
||||
# CONFIG_SPIRAM_USE_MALLOC is not set
|
||||
CONFIG_SPIRAM_MEMTEST=y
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="matouch-tft"
|
||||
# end of LWIP
|
||||
#
|
||||
# CONFIG_ESP_CONSOLE_NONE is not set
|
||||
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
|
||||
CONFIG_ESP_CONSOLE_UART_NUM=0
|
||||
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
|
||||
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
|
||||
CONFIG_ESP_CONSOLE_UART=y
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void board_init(void) {
|
||||
// Debug UART
|
||||
#ifdef DEBUG
|
||||
common_hal_never_reset_pin(&pin_GPIO43);
|
||||
common_hal_never_reset_pin(&pin_GPIO44);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitC-1-N8R8-with-HACKTABLET"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S3"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO48)
|
||||
|
||||
#define DEFAULT_UART_BUS_RX (&pin_GPIO44)
|
||||
#define DEFAULT_UART_BUS_TX (&pin_GPIO43)
|
||||
|
||||
// UART pins attached to the USB-serial converter chip
|
||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO43)
|
||||
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO44)
|
||||
|
||||
// a 800x480 16BPP framebuffer + some breathing room
|
||||
#define DEFAULT_RESERVED_PSRAM (800 * 800 * 2)
|
|
@ -0,0 +1,12 @@
|
|||
USB_VID = 0x303A
|
||||
USB_PID = 0x7003
|
||||
USB_PRODUCT = "ESP32-S3-DevKitC-1-N8R8"
|
||||
USB_MANUFACTURER = "Espressif"
|
||||
|
||||
IDF_TARGET = esp32s3
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE = dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ = 80m
|
||||
CIRCUITPY_ESP_FLASH_SIZE = 8MB
|
||||
|
||||
CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
|
|
@ -0,0 +1,122 @@
|
|||
#include "py/objtuple.h"
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_r_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO14),
|
||||
MP_ROM_PTR(&pin_GPIO15),
|
||||
MP_ROM_PTR(&pin_GPIO16),
|
||||
MP_ROM_PTR(&pin_GPIO17),
|
||||
MP_ROM_PTR(&pin_GPIO18),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_g_pins = {
|
||||
{&mp_type_tuple},
|
||||
6,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO8),
|
||||
MP_ROM_PTR(&pin_GPIO9),
|
||||
MP_ROM_PTR(&pin_GPIO10),
|
||||
MP_ROM_PTR(&pin_GPIO11),
|
||||
MP_ROM_PTR(&pin_GPIO12),
|
||||
MP_ROM_PTR(&pin_GPIO13),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_b_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO3),
|
||||
MP_ROM_PTR(&pin_GPIO4),
|
||||
MP_ROM_PTR(&pin_GPIO5),
|
||||
MP_ROM_PTR(&pin_GPIO6),
|
||||
MP_ROM_PTR(&pin_GPIO7),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t tft_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_de), MP_ROM_PTR(&pin_GPIO45) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync), MP_ROM_PTR(&pin_GPIO48) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync), MP_ROM_PTR(&pin_GPIO47) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_dclk), MP_ROM_PTR(&pin_GPIO21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_red), MP_ROM_PTR(&tft_r_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_green), MP_ROM_PTR(&tft_g_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_blue), MP_ROM_PTR(&tft_b_pins) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(tft_dict, tft_table);
|
||||
|
||||
STATIC const mp_rom_map_elem_t timings800_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_INT(6500000) }, // nominal 16MHz, but display is unstable/tears at that frequency
|
||||
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_INT(800) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_INT(480) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_pulse_width), MP_ROM_INT(30) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_front_porch), MP_ROM_INT(210) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_back_porch), MP_ROM_INT(16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_idle_low), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_pulse_width), MP_ROM_INT(13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_front_porch), MP_ROM_INT(22) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_back_porch), MP_ROM_INT(10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_idle_low), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_de_idle_high), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_pclk_active_high), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_pclk_idle_high), MP_ROM_FALSE },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(timings800_dict, timings800_table);
|
||||
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT), MP_ROM_PTR(&tft_dict) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TIMINGS800), MP_ROM_PTR(&timings800_dict) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BACKLIGHT), MP_ROM_PTR(&pin_GPIO39) },
|
||||
|
||||
{ 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_TFTB1), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTB2), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTB3), MP_ROM_PTR(&pin_GPIO5) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTB4), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTB5), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTG1), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTG2), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTG3), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTG4), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTG5), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTG6), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTR1), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTR2), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTR3), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTR4), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFTR5), MP_ROM_PTR(&pin_GPIO18) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_dclk), MP_ROM_PTR(&pin_GPIO21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
|
||||
{ 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) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_de), MP_ROM_PTR(&pin_GPIO45) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync), MP_ROM_PTR(&pin_GPIO47) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync), MP_ROM_PTR(&pin_GPIO48) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
|
@ -0,0 +1,62 @@
|
|||
#
|
||||
# Component config
|
||||
#
|
||||
#
|
||||
# ESP32S3-Specific
|
||||
#
|
||||
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
|
||||
#
|
||||
# SPI RAM config
|
||||
#
|
||||
#CONFIG_SPIRAM_MODE_QUAD=y
|
||||
### NEW ###
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_TYPE_AUTO=y
|
||||
#######
|
||||
# CONFIG_SPIRAM_MODE_OCT is not set
|
||||
# CONFIG_SPIRAM_TYPE_AUTO is not set
|
||||
#CONFIG_SPIRAM_TYPE_ESPPSRAM16=y
|
||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
|
||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
|
||||
#CONFIG_SPIRAM_SIZE=2097152
|
||||
CONFIG_SPIRAM_TYPE_ESPPSRAM64=y
|
||||
CONFIG_SPIRAM_SIZE=8388608
|
||||
#
|
||||
# PSRAM Clock and CS IO for ESP32S3
|
||||
#
|
||||
CONFIG_DEFAULT_PSRAM_CLK_IO=30
|
||||
CONFIG_DEFAULT_PSRAM_CS_IO=26
|
||||
# end of PSRAM Clock and CS IO for ESP32S3
|
||||
|
||||
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
|
||||
# CONFIG_SPIRAM_RODATA is not set
|
||||
# CONFIG_SPIRAM_SPEED_120M is not set
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
# CONFIG_SPIRAM_SPEED_40M is not set
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
CONFIG_SPIRAM_USE_MEMMAP=y
|
||||
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
|
||||
# CONFIG_SPIRAM_USE_MALLOC is not set
|
||||
CONFIG_SPIRAM_MEMTEST=y
|
||||
# end of SPI RAM config
|
||||
|
||||
# end of ESP32S3-Specific
|
||||
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3-hacktablet"
|
||||
# end of LWIP
|
||||
|
||||
# CONFIG_ESP_CONSOLE_NONE is not set
|
||||
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
|
||||
CONFIG_ESP_CONSOLE_UART_NUM=0
|
||||
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
|
||||
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
|
||||
CONFIG_ESP_CONSOLE_UART=y
|
||||
|
||||
# end of Component config
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "Espressif-ESP32-S3-LCD-EV-Board"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S3"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO4)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8)
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO18)
|
||||
|
||||
// UART pins attached to the USB-serial converter chip
|
||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO43)
|
||||
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO44)
|
||||
|
||||
// a 1024x768 16BPP framebuffer + some breathing room
|
||||
#define DEFAULT_RESERVED_PSRAM (1024 * 1024 * 2)
|
|
@ -0,0 +1,13 @@
|
|||
USB_VID = 0x239A
|
||||
USB_PID = 0x814C
|
||||
USB_PRODUCT = "ESP32-S3-EV-LCD-Board"
|
||||
USB_MANUFACTURER = "Espressif"
|
||||
|
||||
IDF_TARGET = esp32s3
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE = dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ = 80m
|
||||
CIRCUITPY_ESP_FLASH_SIZE = 16MB
|
||||
|
||||
CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
|
||||
UF2_BOOTLOADER = 0
|
|
@ -0,0 +1,79 @@
|
|||
#include "py/objtuple.h"
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_r_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO10),
|
||||
MP_ROM_PTR(&pin_GPIO11),
|
||||
MP_ROM_PTR(&pin_GPIO12),
|
||||
MP_ROM_PTR(&pin_GPIO13),
|
||||
MP_ROM_PTR(&pin_GPIO14),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_g_pins = {
|
||||
{&mp_type_tuple},
|
||||
6,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO21),
|
||||
MP_ROM_PTR(&pin_GPIO47),
|
||||
MP_ROM_PTR(&pin_GPIO48),
|
||||
MP_ROM_PTR(&pin_GPIO45),
|
||||
MP_ROM_PTR(&pin_GPIO38),
|
||||
MP_ROM_PTR(&pin_GPIO39),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_b_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO40),
|
||||
MP_ROM_PTR(&pin_GPIO41),
|
||||
MP_ROM_PTR(&pin_GPIO42),
|
||||
MP_ROM_PTR(&pin_GPIO2),
|
||||
MP_ROM_PTR(&pin_GPIO1),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t tft_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_de), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync), MP_ROM_PTR(&pin_GPIO46) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_dclk), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_red), MP_ROM_PTR(&tft_r_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_green), MP_ROM_PTR(&tft_g_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_blue), MP_ROM_PTR(&tft_b_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_INT(9000000) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(tft_dict, tft_table);
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT), MP_ROM_PTR(&tft_dict) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BACKLIGHT), MP_ROM_PTR(&pin_GPIO10) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_SCK), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_SDO), MP_ROM_PTR(&pin_GPIO15) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(DEFAULT_I2C_BUS_SCL) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(DEFAULT_I2C_BUS_SDA) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO12) },
|
||||
|
||||
// boot mode button can be used in SW as well
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
|
||||
|
||||
{ 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_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
|
@ -0,0 +1,41 @@
|
|||
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
|
||||
#
|
||||
# SPI RAM config
|
||||
#
|
||||
# CONFIG_SPIRAM_MODE_QUAD is not set
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_TYPE_AUTO=y
|
||||
# end of SPI RAM config
|
||||
|
||||
CONFIG_DEFAULT_PSRAM_CLK_IO=30
|
||||
#
|
||||
# PSRAM Clock and CS IO for ESP32S3
|
||||
#
|
||||
CONFIG_DEFAULT_PSRAM_CS_IO=26
|
||||
# end of PSRAM Clock and CS IO for ESP32S3
|
||||
|
||||
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
|
||||
# CONFIG_SPIRAM_RODATA is not set
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
# CONFIG_SPIRAM_SPEED_40M is not set
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
CONFIG_SPIRAM_USE_MEMMAP=y
|
||||
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
|
||||
# CONFIG_SPIRAM_USE_MALLOC is not set
|
||||
CONFIG_SPIRAM_MEMTEST=y
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="circuitpy"
|
||||
# end of LWIP
|
||||
#
|
||||
# CONFIG_ESP_CONSOLE_NONE is not set
|
||||
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
|
||||
CONFIG_ESP_CONSOLE_UART_NUM=0
|
||||
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
|
||||
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
|
||||
CONFIG_ESP_CONSOLE_UART=y
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "MakerFabs-ESP32-S3-Parallel-TFT-With-Touch-7inch"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S3"
|
||||
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO17)
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO18)
|
||||
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO11)
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO12)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO13)
|
||||
|
||||
// UART pins attached to the USB-serial converter chip
|
||||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO43)
|
||||
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO44)
|
||||
|
||||
// a 1024x768 16BPP framebuffer + some breathing room
|
||||
#define DEFAULT_RESERVED_PSRAM (1024 * 1024 * 2)
|
|
@ -0,0 +1,12 @@
|
|||
USB_VID = 0x239A
|
||||
USB_PID = 0x814A
|
||||
USB_PRODUCT = "MakerFabs-ESP32-S3-Parallel-TFT-With-Touch-7inch"
|
||||
USB_MANUFACTURER = "MakerFabs"
|
||||
|
||||
IDF_TARGET = esp32s3
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE = dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ = 80m
|
||||
CIRCUITPY_ESP_FLASH_SIZE = 16MB
|
||||
|
||||
CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
|
|
@ -0,0 +1,100 @@
|
|||
#include "py/objtuple.h"
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_r_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO14),
|
||||
MP_ROM_PTR(&pin_GPIO21),
|
||||
MP_ROM_PTR(&pin_GPIO47),
|
||||
MP_ROM_PTR(&pin_GPIO48),
|
||||
MP_ROM_PTR(&pin_GPIO45),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_g_pins = {
|
||||
{&mp_type_tuple},
|
||||
6,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO4),
|
||||
MP_ROM_PTR(&pin_GPIO16),
|
||||
MP_ROM_PTR(&pin_GPIO15),
|
||||
MP_ROM_PTR(&pin_GPIO7),
|
||||
MP_ROM_PTR(&pin_GPIO6),
|
||||
MP_ROM_PTR(&pin_GPIO5),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_obj_tuple_t tft_b_pins = {
|
||||
{&mp_type_tuple},
|
||||
5,
|
||||
{
|
||||
MP_ROM_PTR(&pin_GPIO1),
|
||||
MP_ROM_PTR(&pin_GPIO9),
|
||||
MP_ROM_PTR(&pin_GPIO46),
|
||||
MP_ROM_PTR(&pin_GPIO3),
|
||||
MP_ROM_PTR(&pin_GPIO8),
|
||||
}
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t tft_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_de), MP_ROM_PTR(&pin_GPIO40) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync), MP_ROM_PTR(&pin_GPIO41) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync), MP_ROM_PTR(&pin_GPIO39) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_dclk), MP_ROM_PTR(&pin_GPIO42) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_red), MP_ROM_PTR(&tft_r_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_green), MP_ROM_PTR(&tft_g_pins) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_blue), MP_ROM_PTR(&tft_b_pins) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(tft_dict, tft_table);
|
||||
|
||||
STATIC const mp_rom_map_elem_t timings800_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_INT(6500000) }, // nominal 16MHz, but display is unstable/tears at that frequency
|
||||
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_INT(800) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_INT(480) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_pulse_width), MP_ROM_INT(30) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_front_porch), MP_ROM_INT(210) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_back_porch), MP_ROM_INT(16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_hsync_idle_low), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_pulse_width), MP_ROM_INT(13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_front_porch), MP_ROM_INT(22) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_back_porch), MP_ROM_INT(10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_vsync_idle_low), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_de_idle_high), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_pclk_active_high), MP_ROM_FALSE },
|
||||
{ MP_ROM_QSTR(MP_QSTR_pclk_idle_high), MP_ROM_FALSE },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(timings800_dict, timings800_table);
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TFT), MP_ROM_PTR(&tft_dict) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TIMINGS800), MP_ROM_PTR(&timings800_dict) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BACKLIGHT), MP_ROM_PTR(&pin_GPIO10) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_SCK), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_SDO), MP_ROM_PTR(&pin_GPIO19) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO18) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO17) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO12) },
|
||||
|
||||
// boot mode button can be used in SW as well
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO1) },
|
||||
|
||||
// IO10 <> SD_CS is cut at factory (non-placed resistor position R34) and pulled up.
|
||||
// Permanent SDIO 1-bit mode?
|
||||
|
||||
{ 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_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
|
@ -0,0 +1,41 @@
|
|||
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
|
||||
#
|
||||
# SPI RAM config
|
||||
#
|
||||
# CONFIG_SPIRAM_MODE_QUAD is not set
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_TYPE_AUTO=y
|
||||
# end of SPI RAM config
|
||||
|
||||
CONFIG_DEFAULT_PSRAM_CLK_IO=30
|
||||
#
|
||||
# PSRAM Clock and CS IO for ESP32S3
|
||||
#
|
||||
CONFIG_DEFAULT_PSRAM_CS_IO=26
|
||||
# end of PSRAM Clock and CS IO for ESP32S3
|
||||
|
||||
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
|
||||
# CONFIG_SPIRAM_RODATA is not set
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
# CONFIG_SPIRAM_SPEED_40M is not set
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
#CONFIG_SPIRAM_USE_MEMMAP=y
|
||||
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
|
||||
# CONFIG_SPIRAM_USE_MALLOC is not set
|
||||
CONFIG_SPIRAM_MEMTEST=y
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="matouch-tft"
|
||||
# end of LWIP
|
||||
#
|
||||
# CONFIG_ESP_CONSOLE_NONE is not set
|
||||
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
|
||||
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
|
||||
CONFIG_ESP_CONSOLE_UART_NUM=0
|
||||
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
|
||||
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
|
||||
CONFIG_ESP_CONSOLE_UART=y
|
|
@ -175,7 +175,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||
xTaskCreatePinnedToCore(
|
||||
uart_event_task,
|
||||
"uart_event_task",
|
||||
configMINIMAL_STACK_SIZE,
|
||||
configMINIMAL_STACK_SIZE + 512,
|
||||
self,
|
||||
CONFIG_PTHREAD_TASK_PRIO_DEFAULT,
|
||||
&self->event_task,
|
||||
|
|
|
@ -0,0 +1,258 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2023 Jeff Epler for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_lcd_panel_interface.h"
|
||||
#include "esp_lcd_panel_rgb.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_private/gdma.h"
|
||||
#include "hal/dma_types.h"
|
||||
#include "hal/lcd_hal.h"
|
||||
#include "hal/lcd_ll.h"
|
||||
#include "soc/lcd_periph.h"
|
||||
|
||||
// extract from esp-idf esp_lcd_rgb_panel.c
|
||||
typedef struct
|
||||
{
|
||||
esp_lcd_panel_t base; // Base class of generic lcd panel
|
||||
int panel_id; // LCD panel ID
|
||||
lcd_hal_context_t hal; // Hal layer object
|
||||
size_t data_width; // Number of data lines (e.g. for RGB565, the data width is 16)
|
||||
size_t sram_trans_align; // Alignment for framebuffer that allocated in SRAM
|
||||
size_t psram_trans_align; // Alignment for framebuffer that allocated in PSRAM
|
||||
int disp_gpio_num; // Display control GPIO, which is used to perform action like "disp_off"
|
||||
intr_handle_t intr; // LCD peripheral interrupt handle
|
||||
esp_pm_lock_handle_t pm_lock; // Power management lock
|
||||
size_t num_dma_nodes; // Number of DMA descriptors that used to carry the frame buffer
|
||||
uint8_t *fb; // Frame buffer
|
||||
size_t fb_size; // Size of frame buffer
|
||||
int data_gpio_nums[SOC_LCD_RGB_DATA_WIDTH]; // GPIOs used for data lines, we keep these GPIOs for action like "invert_color"
|
||||
size_t resolution_hz; // Peripheral clock resolution
|
||||
esp_lcd_rgb_timing_t timings; // RGB timing parameters (e.g. pclk, sync pulse, porch width)
|
||||
gdma_channel_handle_t dma_chan; // DMA channel handle
|
||||
esp_lcd_rgb_panel_frame_trans_done_cb_t on_frame_trans_done; // Callback, invoked after frame trans done
|
||||
void *user_ctx; // Reserved user's data of callback functions
|
||||
int x_gap; // Extra gap in x coordinate, it's used when calculate the flush window
|
||||
int y_gap; // Extra gap in y coordinate, it's used when calculate the flush window
|
||||
struct
|
||||
{
|
||||
unsigned int disp_en_level : 1; // The level which can turn on the screen by `disp_gpio_num`
|
||||
unsigned int stream_mode : 1; // If set, the LCD transfers data continuously, otherwise, it stops refreshing the LCD when transaction done
|
||||
unsigned int fb_in_psram : 1; // Whether the frame buffer is in PSRAM
|
||||
} flags;
|
||||
dma_descriptor_t dma_nodes[]; // DMA descriptor pool of size `num_dma_nodes`
|
||||
} esp_rgb_panel_t;
|
||||
|
||||
|
||||
#include "esp_log.h"
|
||||
#define TAG "LCD"
|
||||
|
||||
#include "components/esp_rom/include/esp_rom_sys.h"
|
||||
|
||||
|
||||
#include "py/objarray.h"
|
||||
#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h"
|
||||
#include "common-hal/dotclockframebuffer/DotClockFramebuffer.h"
|
||||
#include "bindings/espidf/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "py/runtime.h"
|
||||
#include "components/driver/include/driver/gpio.h"
|
||||
#include "components/driver/include/driver/periph_ctrl.h"
|
||||
#include "components/driver/include/esp_private/gdma.h"
|
||||
#include "components/esp_rom/include/esp_rom_gpio.h"
|
||||
#include "components/hal/esp32s3/include/hal/lcd_ll.h"
|
||||
#include "components/hal/include/hal/gpio_hal.h"
|
||||
#include "components/soc/esp32s3/include/soc/lcd_cam_struct.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
// should be from rom/cache.h but it wasn't working
|
||||
int Cache_WriteBack_Addr(uint32_t addr, uint32_t size);
|
||||
|
||||
#define LCD_RGB_ISR_IRAM_SAFE (1)
|
||||
#define LCD_RGB_INTR_ALLOC_FLAGS (ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_INTRDISABLED)
|
||||
|
||||
#define common_hal_mcu_pin_number_maybe(x) ((x) ? common_hal_mcu_pin_number((x)) : -1)
|
||||
|
||||
static void claim_and_record(const mcu_pin_obj_t *pin, uint64_t *used_pins_mask) {
|
||||
if (pin) {
|
||||
int number = common_hal_mcu_pin_number(pin);
|
||||
*used_pins_mask |= (UINT64_C(1) << number);
|
||||
claim_pin_number(number);
|
||||
never_reset_pin_number(number);
|
||||
}
|
||||
}
|
||||
|
||||
static int valid_pin(const mcu_pin_obj_t *pin, qstr name) {
|
||||
int result = common_hal_mcu_pin_number(pin);
|
||||
if (result == NO_PIN) {
|
||||
mp_raise_ValueError_varg(translate("Invalid %q pin"), name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void common_hal_dotclockframebuffer_framebuffer_construct(dotclockframebuffer_framebuffer_obj_t *self,
|
||||
const mcu_pin_obj_t *de,
|
||||
const mcu_pin_obj_t *vsync,
|
||||
const mcu_pin_obj_t *hsync,
|
||||
const mcu_pin_obj_t *dclk,
|
||||
const mcu_pin_obj_t **red, uint8_t num_red,
|
||||
const mcu_pin_obj_t **green, uint8_t num_green,
|
||||
const mcu_pin_obj_t **blue, uint8_t num_blue,
|
||||
int frequency, int width, int height,
|
||||
int hsync_pulse_width, int hsync_back_porch, int hsync_front_porch, bool hsync_idle_low,
|
||||
int vsync_pulse_width, int vsync_back_porch, int vsync_front_porch, bool vsync_idle_low,
|
||||
bool de_idle_high, bool pclk_active_high, bool pclk_idle_high, int overscan_left) {
|
||||
|
||||
if (num_red != 5 || num_green != 6 || num_blue != 5) {
|
||||
mp_raise_ValueError(translate("Must provide 5/6/5 RGB pins"));
|
||||
}
|
||||
|
||||
claim_and_record(de, &self->used_pins_mask);
|
||||
claim_and_record(vsync, &self->used_pins_mask);
|
||||
claim_and_record(hsync, &self->used_pins_mask);
|
||||
claim_and_record(dclk, &self->used_pins_mask);
|
||||
|
||||
for (size_t i = 0; i < num_red; i++) {
|
||||
claim_and_record(red[i], &self->used_pins_mask);
|
||||
}
|
||||
for (size_t i = 0; i < num_green; i++) {
|
||||
claim_and_record(green[i], &self->used_pins_mask);
|
||||
}
|
||||
for (size_t i = 0; i < num_blue; i++) {
|
||||
claim_and_record(blue[i], &self->used_pins_mask);
|
||||
}
|
||||
|
||||
esp_lcd_rgb_panel_config_t *cfg = &self->panel_config;
|
||||
cfg->timings.pclk_hz = frequency;
|
||||
cfg->timings.h_res = width + overscan_left;
|
||||
cfg->timings.v_res = height;
|
||||
cfg->timings.hsync_pulse_width = hsync_pulse_width;
|
||||
cfg->timings.hsync_back_porch = hsync_back_porch;
|
||||
cfg->timings.hsync_front_porch = hsync_front_porch;
|
||||
cfg->timings.vsync_pulse_width = vsync_pulse_width;
|
||||
cfg->timings.vsync_back_porch = vsync_back_porch;
|
||||
cfg->timings.vsync_front_porch = vsync_front_porch;
|
||||
cfg->timings.flags.hsync_idle_low = hsync_idle_low;
|
||||
cfg->timings.flags.vsync_idle_low = hsync_idle_low;
|
||||
cfg->timings.flags.de_idle_high = de_idle_high;
|
||||
cfg->timings.flags.pclk_active_neg = !pclk_active_high;
|
||||
cfg->timings.flags.pclk_idle_high = pclk_idle_high;
|
||||
|
||||
cfg->data_width = 16;
|
||||
cfg->sram_trans_align = 8;
|
||||
cfg->psram_trans_align = 64;
|
||||
cfg->hsync_gpio_num = valid_pin(hsync, MP_QSTR_hsync);
|
||||
cfg->vsync_gpio_num = valid_pin(vsync, MP_QSTR_vsync);
|
||||
cfg->de_gpio_num = valid_pin(de, MP_QSTR_de);
|
||||
cfg->pclk_gpio_num = valid_pin(dclk, MP_QSTR_dclk);
|
||||
|
||||
cfg->data_gpio_nums[0] = valid_pin(blue[0], MP_QSTR_blue);
|
||||
cfg->data_gpio_nums[1] = valid_pin(blue[1], MP_QSTR_blue);
|
||||
cfg->data_gpio_nums[2] = valid_pin(blue[2], MP_QSTR_blue);
|
||||
cfg->data_gpio_nums[3] = valid_pin(blue[3], MP_QSTR_blue);
|
||||
cfg->data_gpio_nums[4] = valid_pin(blue[4], MP_QSTR_blue);
|
||||
|
||||
cfg->data_gpio_nums[5] = valid_pin(green[0], MP_QSTR_green);
|
||||
cfg->data_gpio_nums[6] = valid_pin(green[1], MP_QSTR_green);
|
||||
cfg->data_gpio_nums[7] = valid_pin(green[2], MP_QSTR_green);
|
||||
cfg->data_gpio_nums[8] = valid_pin(green[3], MP_QSTR_green);
|
||||
cfg->data_gpio_nums[9] = valid_pin(green[4], MP_QSTR_green);
|
||||
cfg->data_gpio_nums[10] = valid_pin(green[5], MP_QSTR_green);
|
||||
|
||||
cfg->data_gpio_nums[11] = valid_pin(red[0], MP_QSTR_red);
|
||||
cfg->data_gpio_nums[12] = valid_pin(red[1], MP_QSTR_red);
|
||||
cfg->data_gpio_nums[13] = valid_pin(red[2], MP_QSTR_red);
|
||||
cfg->data_gpio_nums[14] = valid_pin(red[3], MP_QSTR_red);
|
||||
cfg->data_gpio_nums[15] = valid_pin(red[4], MP_QSTR_red);
|
||||
|
||||
cfg->disp_gpio_num = GPIO_NUM_NC;
|
||||
|
||||
cfg->flags.disp_active_low = 0;
|
||||
cfg->flags.relax_on_idle = 0;
|
||||
cfg->flags.fb_in_psram = 1; // allocate frame buffer in PSRAM
|
||||
|
||||
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&self->panel_config, &self->panel_handle));
|
||||
ESP_ERROR_CHECK(esp_lcd_panel_reset(self->panel_handle));
|
||||
ESP_ERROR_CHECK(esp_lcd_panel_init(self->panel_handle));
|
||||
|
||||
uint16_t color = 0;
|
||||
ESP_ERROR_CHECK(self->panel_handle->draw_bitmap(self->panel_handle, 0, 0, 1, 1, &color));
|
||||
|
||||
esp_rgb_panel_t *_rgb_panel = __containerof(self->panel_handle, esp_rgb_panel_t, base);
|
||||
|
||||
self->frequency = frequency;
|
||||
self->row_stride = 2 * (width + overscan_left);
|
||||
self->refresh_rate = frequency / (width + hsync_front_porch + hsync_back_porch) / (height + vsync_front_porch + vsync_back_porch);
|
||||
self->bufinfo.buf = (uint8_t *)_rgb_panel->fb + 2 * overscan_left; // first line starts ater overscan_left pixels
|
||||
self->bufinfo.len = 2 * (cfg->timings.h_res * cfg->timings.v_res - overscan_left); // no overscan after last line
|
||||
self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW;
|
||||
|
||||
// LCD_CAM.lcd_ctrl2.lcd_vsync_idle_pol = _vsync_polarity;
|
||||
// LCD_CAM.lcd_ctrl2.lcd_hsync_idle_pol = _hsync_polarity;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void common_hal_dotclockframebuffer_framebuffer_deinit(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
if (common_hal_dotclockframebuffer_framebuffer_deinitialized(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
reset_pin_mask(self->used_pins_mask);
|
||||
self->used_pins_mask = 0;
|
||||
esp_lcd_panel_del(self->panel_handle);
|
||||
}
|
||||
|
||||
bool common_hal_dotclockframebuffer_framebuffer_deinitialized(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
return self->used_pins_mask == 0;
|
||||
}
|
||||
|
||||
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_width(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
return self->panel_config.timings.h_res;
|
||||
}
|
||||
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_height(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
return self->panel_config.timings.v_res;
|
||||
}
|
||||
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_frequency(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
return self->frequency;
|
||||
}
|
||||
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_row_stride(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
return self->row_stride;
|
||||
}
|
||||
|
||||
void common_hal_dotclockframebuffer_framebuffer_refresh(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
Cache_WriteBack_Addr((uint32_t)(self->bufinfo.buf), self->bufinfo.len);
|
||||
}
|
||||
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_refresh_rate(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
return self->refresh_rate;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2023 Jeff Epler for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_rgb.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_lcd_panel_interface.h"
|
||||
|
||||
typedef struct dotclockframebuffer_framebuffer_obj {
|
||||
mp_obj_base_t base;
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_int_t row_stride;
|
||||
uint32_t frequency, refresh_rate;
|
||||
uint64_t used_pins_mask;
|
||||
volatile int32_t frame_count;
|
||||
esp_lcd_rgb_panel_config_t panel_config;
|
||||
esp_lcd_panel_handle_t panel_handle;
|
||||
} dotclockframebuffer_framebuffer_obj_t;
|
|
@ -79,7 +79,7 @@ bool common_hal_espidf_set_reserved_psram(size_t amount) {
|
|||
supervisor_allocation *psram_for_idf;
|
||||
|
||||
void common_hal_espidf_reserve_psram(void) {
|
||||
#ifdef CONFIG_SPIRAM
|
||||
#ifdef CONFIG_SPIRAM_USE_MEMMAP
|
||||
if (!psram_for_idf) {
|
||||
ESP_LOGI(TAG, "Reserving %d bytes of psram", reserved_psram);
|
||||
if (reserved_psram == 0) {
|
||||
|
|
|
@ -218,6 +218,14 @@ void reset_pin_number(gpio_num_t pin_number) {
|
|||
_reset_pin(pin_number);
|
||||
}
|
||||
|
||||
void reset_pin_mask(uint64_t mask) {
|
||||
for (int i = 0; i < 64; i++, mask >>= 1) {
|
||||
if (mask & 1) {
|
||||
reset_pin_number(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_mcu_pin_reset_number(uint8_t i) {
|
||||
reset_pin_number((gpio_num_t)i);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ extern void reset_all_pins(void);
|
|||
// reset_pin_number takes the pin number instead of the pointer so that objects don't
|
||||
// need to store a full pointer.
|
||||
extern void reset_pin_number(gpio_num_t pin_number);
|
||||
// reset all pins in `bitmask`
|
||||
extern void reset_pin_mask(uint64_t bitmask);
|
||||
extern void skip_reset_once_pin_number(gpio_num_t pin_number);
|
||||
extern void claim_pin(const mcu_pin_obj_t *pin);
|
||||
extern void claim_pin_number(gpio_num_t pin_number);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 630c2724fc8c69eeaaa1bb025de52b99c5cb11aa
|
||||
Subproject commit 69f9a4f566d49afe97fd8b47444bd394af005e23
|
|
@ -21,6 +21,7 @@ CIRCUITPY_BLEIO ?= 1
|
|||
CIRCUITPY_BLEIO_HCI = 0
|
||||
CIRCUITPY_CANIO ?= 1
|
||||
CIRCUITPY_COUNTIO ?= 1
|
||||
CIRCUITPY_DOTCLOCKFRAMEBUFFER_USES_SUPERVISOR_ALLOCATION = 0
|
||||
CIRCUITPY_DUALBANK ?= 1
|
||||
CIRCUITPY_ESPCAMERA ?= 1
|
||||
CIRCUITPY_ESPIDF ?= 1
|
||||
|
|
|
@ -25,12 +25,15 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include "supervisor/board.h"
|
||||
#include "supervisor/port.h"
|
||||
#include "supervisor/filesystem.h"
|
||||
#include "supervisor/shared/reload.h"
|
||||
#include "supervisor/serial.h"
|
||||
#include "py/mpprint.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
@ -243,16 +246,17 @@ safe_mode_t port_init(void) {
|
|||
|
||||
circuitpython_task = xTaskGetCurrentTaskHandle();
|
||||
|
||||
#if !defined(DEBUG)
|
||||
#define DEBUG (0)
|
||||
#endif
|
||||
|
||||
// Send the ROM output out of the UART. This includes early logs.
|
||||
#ifdef DEBUG
|
||||
#if DEBUG
|
||||
ets_install_uart_printf();
|
||||
#endif
|
||||
|
||||
heap = NULL;
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG (0)
|
||||
#endif
|
||||
heap_size = 0;
|
||||
|
||||
#define pin_GPIOn(n) pin_GPIO##n
|
||||
#define pin_GPIOn_EXPAND(x) pin_GPIOn(x)
|
||||
|
@ -295,33 +299,8 @@ safe_mode_t port_init(void) {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SPIRAM
|
||||
{
|
||||
intptr_t heap_start = common_hal_espidf_get_psram_start();
|
||||
intptr_t heap_end = common_hal_espidf_get_psram_end();
|
||||
size_t spiram_size = heap_end - heap_start;
|
||||
if (spiram_size > 0) {
|
||||
heap = (uint32_t *)heap_start;
|
||||
heap_size = (heap_end - heap_start) / sizeof(uint32_t);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "CONFIG_SPIRAM enabled but no spiram heap available");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_never_reset_spi_ram_flash();
|
||||
|
||||
if (heap == NULL) {
|
||||
size_t heap_total = heap_caps_get_total_size(MALLOC_CAP_8BIT);
|
||||
heap_size = MIN(heap_caps_get_largest_free_block(MALLOC_CAP_8BIT), heap_total / 2);
|
||||
heap = malloc(heap_size);
|
||||
heap_size = heap_size / sizeof(uint32_t);
|
||||
}
|
||||
if (heap == NULL) {
|
||||
heap_size = 0;
|
||||
return SAFE_MODE_NO_HEAP;
|
||||
}
|
||||
|
||||
esp_reset_reason_t reason = esp_reset_reason();
|
||||
switch (reason) {
|
||||
case ESP_RST_BROWNOUT:
|
||||
|
@ -340,6 +319,57 @@ safe_mode_t port_init(void) {
|
|||
return SAFE_MODE_NONE;
|
||||
}
|
||||
|
||||
safe_mode_t port_heap_init(safe_mode_t sm) {
|
||||
mp_int_t reserved = 0;
|
||||
if (filesystem_present() && common_hal_os_getenv_int("CIRCUITPY_RESERVED_PSRAM", &reserved) == GETENV_OK) {
|
||||
common_hal_espidf_set_reserved_psram(reserved);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SPIRAM_USE_MEMMAP)
|
||||
{
|
||||
intptr_t heap_start = common_hal_espidf_get_psram_start();
|
||||
intptr_t heap_end = common_hal_espidf_get_psram_end();
|
||||
size_t spiram_size = heap_end - heap_start;
|
||||
if (spiram_size > 0) {
|
||||
heap = (uint32_t *)heap_start;
|
||||
heap_size = (heap_end - heap_start) / sizeof(uint32_t);
|
||||
common_hal_espidf_reserve_psram();
|
||||
} else {
|
||||
ESP_LOGE(TAG, "CONFIG_SPIRAM_USE_MMAP enabled but no spiram heap available");
|
||||
}
|
||||
}
|
||||
#elif defined(CONFIG_SPIRAM_USE_CAPS_ALLOC)
|
||||
{
|
||||
intptr_t psram_start = common_hal_espidf_get_psram_start();
|
||||
intptr_t psram_end = common_hal_espidf_get_psram_end();
|
||||
size_t psram_amount = psram_end - psram_start;
|
||||
size_t biggest_block = heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM);
|
||||
size_t try_alloc = MIN(biggest_block, psram_amount - common_hal_espidf_get_reserved_psram());
|
||||
heap = heap_caps_malloc(try_alloc, MALLOC_CAP_SPIRAM);
|
||||
|
||||
if (heap) {
|
||||
heap_size = try_alloc;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "CONFIG_SPIRAM_USE_CAPS_ALLOC but no spiram heap available");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (heap == NULL) {
|
||||
size_t heap_total = heap_caps_get_total_size(MALLOC_CAP_8BIT);
|
||||
heap_size = MIN(heap_caps_get_largest_free_block(MALLOC_CAP_8BIT), heap_total / 2);
|
||||
heap = malloc(heap_size);
|
||||
heap_size = heap_size / sizeof(uint32_t);
|
||||
}
|
||||
if (heap == NULL) {
|
||||
heap_size = 0;
|
||||
return SAFE_MODE_NO_HEAP;
|
||||
}
|
||||
|
||||
return sm;
|
||||
|
||||
}
|
||||
|
||||
void reset_port(void) {
|
||||
// TODO deinit for esp32-camera
|
||||
#if CIRCUITPY_ESPCAMERA
|
||||
|
@ -529,14 +559,20 @@ void port_idle_until_interrupt(void) {
|
|||
|
||||
void port_post_boot_py(bool heap_valid) {
|
||||
if (!heap_valid && filesystem_present()) {
|
||||
mp_int_t reserved;
|
||||
if (common_hal_os_getenv_int("CIRCUITPY_RESERVED_PSRAM", &reserved) == GETENV_OK) {
|
||||
common_hal_espidf_set_reserved_psram(reserved);
|
||||
}
|
||||
common_hal_espidf_reserve_psram();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if CIRCUITPY_CONSOLE_UART
|
||||
static int vprintf_adapter(const char *fmt, va_list ap) {
|
||||
return mp_vprintf(&mp_plat_print, fmt, ap);
|
||||
}
|
||||
|
||||
void port_serial_early_init(void) {
|
||||
esp_log_set_vprintf(vprintf_adapter);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Wrap main in app_main that the IDF expects.
|
||||
extern void main(void);
|
||||
extern void app_main(void);
|
||||
|
|
|
@ -296,6 +296,9 @@ endif
|
|||
ifeq ($(CIRCUITPY_RGBMATRIX),1)
|
||||
SRC_PATTERNS += rgbmatrix/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_DOTCLOCKFRAMEBUFFER),1)
|
||||
SRC_PATTERNS += dotclockframebuffer/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_RP2PIO),1)
|
||||
SRC_PATTERNS += rp2pio/%
|
||||
endif
|
||||
|
@ -435,6 +438,8 @@ SRC_COMMON_HAL_ALL = \
|
|||
countio/__init__.c \
|
||||
digitalio/DigitalInOut.c \
|
||||
digitalio/__init__.c \
|
||||
dotclockframebuffer/DotClockFramebuffer.c \
|
||||
dotclockframebuffer/__init__.c \
|
||||
dualbank/__init__.c \
|
||||
frequencyio/FrequencyIn.c \
|
||||
frequencyio/__init__.c \
|
||||
|
|
|
@ -206,6 +206,11 @@ CIRCUITPY_PARALLELDISPLAY = 0
|
|||
endif
|
||||
CFLAGS += -DCIRCUITPY_PARALLELDISPLAY=$(CIRCUITPY_PARALLELDISPLAY)
|
||||
|
||||
CIRCUITPY_DOTCLOCKFRAMEBUFFER ?= 0
|
||||
CFLAGS += -DCIRCUITPY_DOTCLOCKFRAMEBUFFER=$(CIRCUITPY_DOTCLOCKFRAMEBUFFER)
|
||||
CIRCUITPY_DOTCLOCKFRAMEBUFFER_USES_SUPERVISOR_ALLOCATION ?= 1
|
||||
CFLAGS += -DCIRCUITPY_DOTCLOCKFRAMEBUFFER_USES_SUPERVISOR_ALLOCATION=$(CIRCUITPY_DOTCLOCKFRAMEBUFFER_USES_SUPERVISOR_ALLOCATION)
|
||||
|
||||
# bitmaptools and framebufferio rely on displayio
|
||||
CIRCUITPY_BITMAPTOOLS ?= $(call enable-if-all,$(CIRCUITPY_FULL_BUILD) $(CIRCUITPY_DISPLAYIO))
|
||||
CIRCUITPY_FRAMEBUFFERIO ?= $(call enable-if-all,$(CIRCUITPY_FULL_BUILD) $(CIRCUITPY_DISPLAYIO))
|
||||
|
|
|
@ -0,0 +1,372 @@
|
|||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2023 Jeff Epler for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h"
|
||||
|
||||
#include "py/binary.h"
|
||||
#include "py/objarray.h"
|
||||
#include "py/objproperty.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/util.h"
|
||||
#include "shared-module/displayio/__init__.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
||||
//| class DotClockFramebuffer:
|
||||
//| """Manage updating a 'dot-clock' framebuffer in the background while Python code runs.
|
||||
//| It doesn't handle display initialization."""
|
||||
//|
|
||||
//| def __init__(
|
||||
//| self,
|
||||
//| *,
|
||||
//| de: microcontroller.Pin,
|
||||
//| vsync: microcontroller.Pin,
|
||||
//| hsync: microcontroller.Pin,
|
||||
//| dclk: microcontroller.Pin,
|
||||
//| red: Tuple[microcontroller.Pin],
|
||||
//| green: Tuple[microcontroller.Pin],
|
||||
//| blue: Tuple[microcontroller.Pin],
|
||||
//| frequency: int,
|
||||
//| width: int,
|
||||
//| height: int,
|
||||
//| hsync_pulse_width: int,
|
||||
//| hsync_back_porch: int,
|
||||
//| hsync_front_porch: int,
|
||||
//| hsync_idle_low: bool,
|
||||
//| vsync_back_porch: int,
|
||||
//| vsync_front_porch: int,
|
||||
//| vsync_idle_low: bool,
|
||||
//| de_idle_high: bool,
|
||||
//| pclk_active_high: bool,
|
||||
//| pclk_idle_high: bool,
|
||||
//| overscan_left: int = 0,
|
||||
//| ) -> None:
|
||||
//| """Create a DotClockFramebuffer object associated with the given pins.
|
||||
//|
|
||||
//| The pins are then in use by the display until `displayio.release_displays()`
|
||||
//| is called even after a reload. (It does this so CircuitPython can use the display after your
|
||||
//| code is done.) So, the first time you initialize a display bus in code.py you should call
|
||||
//| :py:func:`displayio.release_displays` first, otherwise it will error after the first code.py run.
|
||||
//|
|
||||
//| When a board has dedicated dot clock framebuffer pins and/or timings, they are intended to be used in the constructor with ``**`` dictionary unpacking like so:
|
||||
//| ``DotClockFramebuffer(**board.TFT_PINS, **board.TFT_TIMINGS)``
|
||||
//|
|
||||
//| On Espressif-family microcontrollers, this driver requires that the
|
||||
//| ``CIRCUITPY_RESERVED_PSRAM`` in ``settings.toml`` be large enough to hold the
|
||||
//| framebuffer. Generally, boards with built-in displays or display connectors
|
||||
//| will have a default setting that is large enough for typical use. If the
|
||||
//| constructor raises a MemoryError or an IDFError, this probably indicates the
|
||||
//| setting is too small and should be increased.
|
||||
//|
|
||||
//| TFT connection parameters:
|
||||
//|
|
||||
//| :param microcontroller.Pin de: The "data enable" input to the display
|
||||
//| :param microcontroller.Pin vsync: The "vertical sync" input to the display
|
||||
//| :param microcontroller.Pin hsync: The "horizontal sync" input to the display
|
||||
//| :param microcontroller.Pin dclk: The "data clock" input to the display
|
||||
//| :param ~tuple red: The red data pins, most significant pin first.
|
||||
//| :param ~tuple green: The green data pins, most significant pin first.
|
||||
//| :param ~tuple blue: The blue data pins, most significant pin first.
|
||||
//|
|
||||
//| TFT timing parameters:
|
||||
//|
|
||||
//| :param int frequency: The requested data clock frequency in Hz.
|
||||
//| :param int width: The visible width of the display, in pixels
|
||||
//| :param int height: The visible height of the display, in pixels
|
||||
//| :param int hsync_pulse_width: Horizontal sync width in pixels
|
||||
//| :param int hsync_back_porch: Horizontal back porch, number of pixels between hsync and start of line active data
|
||||
//| :param int hsync_front_porch: Horizontal front porch, number of pixels between the end of active data and the next hsync
|
||||
//| :param int vsync_back_porch: Vertical back porch, number of lines between vsync and start of frame
|
||||
//| :param int vsync_front_porch: Vertical front porch, number of lines between the end of frame and the next vsync
|
||||
//| :param bool hsync_idle_low: True if the hsync signal is low in IDLE state
|
||||
//| :param bool vsync_idle_low: True if the vsync signal is low in IDLE state
|
||||
//| :param bool de_idle_high: True if the de signal is high in IDLE state
|
||||
//| :param bool pclk_active_high: True if the display data is clocked out at the rising edge of dclk
|
||||
//| :param bool pclk_idle_high: True if the dclk stays at high level in IDLE phase
|
||||
//|
|
||||
//| :param int overscan_left: Allocate additional non-visible columns left of the first display column
|
||||
//| """
|
||||
//| #:param int overscan_top: Allocate additional non-visible rows above the first display row
|
||||
//| #:param int overscan_right: Allocate additional non-visible columns right of the last display column
|
||||
//| #:param int overscan_bottom: Allocate additional non-visible rows below the last display row
|
||||
//| ...
|
||||
STATIC mp_obj_t dotclockframebuffer_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
enum { ARG_de, ARG_vsync, ARG_hsync, ARG_dclk, ARG_red, ARG_green, ARG_blue,
|
||||
ARG_frequency, ARG_width, ARG_height,
|
||||
ARG_hsync_pulse_width, ARG_hsync_back_porch, ARG_hsync_front_porch, ARG_hsync_idle_low,
|
||||
ARG_vsync_pulse_width, ARG_vsync_back_porch, ARG_vsync_front_porch, ARG_vsync_idle_low,
|
||||
ARG_de_idle_high, ARG_pclk_active_high, ARG_pclk_idle_high,
|
||||
ARG_overscan_left};
|
||||
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_de, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_obj = mp_const_none } },
|
||||
{ MP_QSTR_vsync, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_obj = mp_const_none } },
|
||||
{ MP_QSTR_hsync, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_obj = mp_const_none } },
|
||||
{ MP_QSTR_dclk, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_obj = mp_const_none } },
|
||||
{ MP_QSTR_red, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_obj = mp_const_none } },
|
||||
{ MP_QSTR_green, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_obj = mp_const_none } },
|
||||
{ MP_QSTR_blue, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_obj = mp_const_none } },
|
||||
|
||||
{ MP_QSTR_frequency, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_width, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
|
||||
{ MP_QSTR_hsync_pulse_width, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_hsync_back_porch, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_hsync_front_porch, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_hsync_idle_low, MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_bool = false } },
|
||||
|
||||
{ MP_QSTR_vsync_pulse_width, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_vsync_back_porch, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_vsync_front_porch, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_int = 0 } },
|
||||
{ MP_QSTR_vsync_idle_low, MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_bool = false } },
|
||||
|
||||
{ MP_QSTR_de_idle_high, MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_bool = false } },
|
||||
{ MP_QSTR_pclk_active_high, MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_bool = false } },
|
||||
{ MP_QSTR_pclk_idle_high, MP_ARG_BOOL | MP_ARG_KW_ONLY | MP_ARG_REQUIRED, {.u_bool = false } },
|
||||
|
||||
{ MP_QSTR_overscan_left, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mcu_pin_obj_t *de = validate_obj_is_free_pin(args[ARG_de].u_obj, MP_QSTR_de);
|
||||
const mcu_pin_obj_t *vsync = validate_obj_is_free_pin(args[ARG_vsync].u_obj, MP_QSTR_vsync);
|
||||
const mcu_pin_obj_t *hsync = validate_obj_is_free_pin(args[ARG_hsync].u_obj, MP_QSTR_hsync);
|
||||
const mcu_pin_obj_t *dclk = validate_obj_is_free_pin(args[ARG_dclk].u_obj, MP_QSTR_dclk);
|
||||
|
||||
uint8_t num_red, num_green, num_blue;
|
||||
const mcu_pin_obj_t *red_pins[8], *green_pins[8], *blue_pins[8];
|
||||
|
||||
validate_list_is_free_pins(MP_QSTR_red, red_pins, (mp_int_t)MP_ARRAY_SIZE(red_pins), args[ARG_red].u_obj, &num_red);
|
||||
validate_list_is_free_pins(MP_QSTR_green, green_pins, (mp_int_t)MP_ARRAY_SIZE(green_pins), args[ARG_green].u_obj, &num_green);
|
||||
validate_list_is_free_pins(MP_QSTR_blue, blue_pins, (mp_int_t)MP_ARRAY_SIZE(blue_pins), args[ARG_blue].u_obj, &num_blue);
|
||||
|
||||
mp_printf(&mp_plat_print, "#red=%d #green=%d #blue=%d\n", num_red, num_green, num_blue);
|
||||
|
||||
dotclockframebuffer_framebuffer_obj_t *self = &allocate_display_bus_or_raise()->dotclock;
|
||||
self->base.type = &dotclockframebuffer_framebuffer_type;
|
||||
|
||||
common_hal_dotclockframebuffer_framebuffer_construct(
|
||||
self, de, vsync, hsync, dclk, red_pins, num_red, green_pins, num_green, blue_pins, num_blue,
|
||||
args[ARG_frequency].u_int, args[ARG_width].u_int, args[ARG_height].u_int,
|
||||
args[ARG_hsync_pulse_width].u_int, args[ARG_hsync_back_porch].u_int, args[ARG_hsync_front_porch].u_int, args[ARG_hsync_idle_low].u_bool,
|
||||
args[ARG_vsync_pulse_width].u_int, args[ARG_vsync_back_porch].u_int, args[ARG_vsync_front_porch].u_int, args[ARG_vsync_idle_low].u_bool,
|
||||
args[ARG_de_idle_high].u_bool,
|
||||
args[ARG_pclk_active_high].u_bool,
|
||||
args[ARG_pclk_idle_high].u_bool,
|
||||
args[ARG_overscan_left].u_int
|
||||
);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void check_for_deinit(dotclockframebuffer_framebuffer_obj_t *self) {
|
||||
if (common_hal_dotclockframebuffer_framebuffer_deinitialized(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| def refresh(self) -> None:
|
||||
//| """Transmits the color data in the buffer to the pixels so that
|
||||
//| they are shown.
|
||||
//|
|
||||
//| If this function is not called, the results are unpredictable; updates may be partially shown.
|
||||
//| """
|
||||
//| ...
|
||||
STATIC mp_obj_t dotclockframebuffer_framebuffer_refresh(mp_obj_t self_in) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
check_for_deinit(self);
|
||||
common_hal_dotclockframebuffer_framebuffer_refresh(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_refresh_obj, dotclockframebuffer_framebuffer_refresh);
|
||||
|
||||
|
||||
//| refresh_rate: float
|
||||
//| """The pixel refresh rate of the display, in Hz"""
|
||||
STATIC mp_obj_t dotclockframebuffer_framebuffer_get_refresh_rate(mp_obj_t self_in) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_dotclockframebuffer_framebuffer_get_refresh_rate(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_get_refresh_rate_obj, dotclockframebuffer_framebuffer_get_refresh_rate);
|
||||
MP_PROPERTY_GETTER(dotclockframebuffer_framebuffer_refresh_rate_obj,
|
||||
(mp_obj_t)&dotclockframebuffer_framebuffer_get_refresh_rate_obj);
|
||||
|
||||
//| frequency: int
|
||||
//| """The pixel frequency of the display, in Hz"""
|
||||
STATIC mp_obj_t dotclockframebuffer_framebuffer_get_frequency(mp_obj_t self_in) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_dotclockframebuffer_framebuffer_get_frequency(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_get_frequency_obj, dotclockframebuffer_framebuffer_get_frequency);
|
||||
MP_PROPERTY_GETTER(dotclockframebuffer_framebuffer_frequency_obj,
|
||||
(mp_obj_t)&dotclockframebuffer_framebuffer_get_frequency_obj);
|
||||
|
||||
//| width: int
|
||||
//| """The width of the display, in pixels"""
|
||||
STATIC mp_obj_t dotclockframebuffer_framebuffer_get_width(mp_obj_t self_in) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_dotclockframebuffer_framebuffer_get_width(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_get_width_obj, dotclockframebuffer_framebuffer_get_width);
|
||||
MP_PROPERTY_GETTER(dotclockframebuffer_framebuffer_width_obj,
|
||||
(mp_obj_t)&dotclockframebuffer_framebuffer_get_width_obj);
|
||||
|
||||
//| height: int
|
||||
//| """The height of the display, in pixels"""
|
||||
//|
|
||||
STATIC mp_obj_t dotclockframebuffer_framebuffer_get_height(mp_obj_t self_in) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_dotclockframebuffer_framebuffer_get_height(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_get_height_obj, dotclockframebuffer_framebuffer_get_height);
|
||||
|
||||
MP_PROPERTY_GETTER(dotclockframebuffer_framebuffer_height_obj,
|
||||
(mp_obj_t)&dotclockframebuffer_framebuffer_get_height_obj);
|
||||
|
||||
//| row_stride: int
|
||||
//| """The row_stride of the display, in bytes
|
||||
//|
|
||||
//| Due to overscan or alignment requirements, the memory address for row N+1 may not be exactly ``2*width`` bytes after the memory address for row N.
|
||||
//| This property gives the stride in **bytes**.
|
||||
//|
|
||||
//| On Espressif this value is **guaranteed** to be a multiple of the 2 (i.e., it is a whole number of pixels)"""
|
||||
//|
|
||||
STATIC mp_obj_t dotclockframebuffer_framebuffer_get_row_stride(mp_obj_t self_in) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_dotclockframebuffer_framebuffer_get_row_stride(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(dotclockframebuffer_framebuffer_get_row_stride_obj, dotclockframebuffer_framebuffer_get_row_stride);
|
||||
|
||||
MP_PROPERTY_GETTER(dotclockframebuffer_framebuffer_row_stride_obj,
|
||||
(mp_obj_t)&dotclockframebuffer_framebuffer_get_row_stride_obj);
|
||||
|
||||
STATIC mp_int_t dotclockframebuffer_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
// a readonly framebuffer would be unusual but not impossible
|
||||
if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) {
|
||||
return 1;
|
||||
}
|
||||
*bufinfo = self->bufinfo;
|
||||
bufinfo->typecode = 'H';
|
||||
return 0;
|
||||
}
|
||||
|
||||
// These version exists so that the prototype matches the protocol,
|
||||
// avoiding a type cast that can hide errors
|
||||
STATIC void dotclockframebuffer_framebuffer_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) {
|
||||
(void)dirty_row_bitmap;
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
common_hal_dotclockframebuffer_framebuffer_refresh(self);
|
||||
}
|
||||
|
||||
STATIC void dotclockframebuffer_framebuffer_deinit_proto(mp_obj_t self_in) {
|
||||
common_hal_dotclockframebuffer_framebuffer_deinit(self_in);
|
||||
}
|
||||
|
||||
STATIC float dotclockframebuffer_framebuffer_get_brightness_proto(mp_obj_t self_in) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
STATIC bool dotclockframebuffer_framebuffer_set_brightness_proto(mp_obj_t self_in, mp_float_t value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
STATIC int dotclockframebuffer_framebuffer_get_width_proto(mp_obj_t self_in) {
|
||||
return common_hal_dotclockframebuffer_framebuffer_get_width(self_in);
|
||||
}
|
||||
|
||||
STATIC int dotclockframebuffer_framebuffer_get_height_proto(mp_obj_t self_in) {
|
||||
return common_hal_dotclockframebuffer_framebuffer_get_height(self_in);
|
||||
}
|
||||
|
||||
STATIC int dotclockframebuffer_framebuffer_get_color_depth_proto(mp_obj_t self_in) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
STATIC int dotclockframebuffer_framebuffer_get_bytes_per_cell_proto(mp_obj_t self_in) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
STATIC int dotclockframebuffer_framebuffer_get_native_frames_per_second_proto(mp_obj_t self_in) {
|
||||
return common_hal_dotclockframebuffer_framebuffer_get_refresh_rate(self_in);
|
||||
}
|
||||
|
||||
STATIC void dotclockframebuffer_framebuffer_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
|
||||
*bufinfo = self->bufinfo;
|
||||
}
|
||||
|
||||
STATIC int dotclockframebuffer_framebuffer_get_row_stride_proto(mp_obj_t self_in) {
|
||||
dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in;
|
||||
return common_hal_dotclockframebuffer_framebuffer_get_row_stride(self);
|
||||
}
|
||||
|
||||
STATIC const framebuffer_p_t dotclockframebuffer_framebuffer_proto = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer)
|
||||
.get_bufinfo = dotclockframebuffer_framebuffer_get_bufinfo,
|
||||
.set_brightness = dotclockframebuffer_framebuffer_set_brightness_proto,
|
||||
.get_brightness = dotclockframebuffer_framebuffer_get_brightness_proto,
|
||||
.get_width = dotclockframebuffer_framebuffer_get_width_proto,
|
||||
.get_height = dotclockframebuffer_framebuffer_get_height_proto,
|
||||
.get_color_depth = dotclockframebuffer_framebuffer_get_color_depth_proto,
|
||||
.get_row_stride = dotclockframebuffer_framebuffer_get_row_stride_proto,
|
||||
.get_bytes_per_cell = dotclockframebuffer_framebuffer_get_bytes_per_cell_proto,
|
||||
.get_native_frames_per_second = dotclockframebuffer_framebuffer_get_native_frames_per_second_proto,
|
||||
.swapbuffers = dotclockframebuffer_framebuffer_swapbuffers,
|
||||
.deinit = dotclockframebuffer_framebuffer_deinit_proto,
|
||||
};
|
||||
|
||||
|
||||
STATIC const mp_rom_map_elem_t dotclockframebuffer_framebuffer_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&dotclockframebuffer_framebuffer_width_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&dotclockframebuffer_framebuffer_height_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_row_stride), MP_ROM_PTR(&dotclockframebuffer_framebuffer_row_stride_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&dotclockframebuffer_framebuffer_frequency_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_refresh_rate), MP_ROM_PTR(&dotclockframebuffer_framebuffer_refresh_rate_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&dotclockframebuffer_framebuffer_refresh_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(dotclockframebuffer_framebuffer_locals_dict, dotclockframebuffer_framebuffer_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t dotclockframebuffer_framebuffer_type = {
|
||||
{ &mp_type_type },
|
||||
.flags = MP_TYPE_FLAG_EXTENDED,
|
||||
.name = MP_QSTR_DotClockFramebuffer,
|
||||
.make_new = dotclockframebuffer_framebuffer_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&dotclockframebuffer_framebuffer_locals_dict,
|
||||
MP_TYPE_EXTENDED_FIELDS(
|
||||
.buffer_p = { .get_buffer = dotclockframebuffer_framebuffer_get_buffer, },
|
||||
.protocol = &dotclockframebuffer_framebuffer_proto,
|
||||
),
|
||||
};
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-bindings/displayio/__init__.h"
|
||||
#include "shared-module/displayio/Group.h"
|
||||
|
||||
typedef struct dotclockframebuffer_framebuffer_obj dotclockframebuffer_framebuffer_obj_t;
|
||||
|
||||
extern const mp_obj_type_t dotclockframebuffer_framebuffer_type;
|
||||
|
||||
void common_hal_dotclockframebuffer_framebuffer_construct(dotclockframebuffer_framebuffer_obj_t *self,
|
||||
const mcu_pin_obj_t *de,
|
||||
const mcu_pin_obj_t *vsync,
|
||||
const mcu_pin_obj_t *hsync,
|
||||
const mcu_pin_obj_t *dclk,
|
||||
const mcu_pin_obj_t **red, uint8_t num_red,
|
||||
const mcu_pin_obj_t **green, uint8_t num_green,
|
||||
const mcu_pin_obj_t **blue, uint8_t num_blue,
|
||||
int frequency, int width, int height,
|
||||
int hsync_pulse_width, int hsync_back_porch, int hsync_front_porch, bool hsync_idle_low,
|
||||
int vsync_pulse_width, int vsync_back_porch, int vsync_front_porch, bool vsync_idle_low,
|
||||
bool de_idle_high, bool pclk_active_high, bool pclk_idle_high,
|
||||
int overscan_left);
|
||||
|
||||
void common_hal_dotclockframebuffer_framebuffer_deinit(dotclockframebuffer_framebuffer_obj_t *self);
|
||||
bool common_hal_dotclockframebuffer_framebuffer_deinitialized(dotclockframebuffer_framebuffer_obj_t *self);
|
||||
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_width(dotclockframebuffer_framebuffer_obj_t *self);
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_height(dotclockframebuffer_framebuffer_obj_t *self);
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_frequency(dotclockframebuffer_framebuffer_obj_t *self);
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_refresh_rate(dotclockframebuffer_framebuffer_obj_t *self);
|
||||
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_row_stride(dotclockframebuffer_framebuffer_obj_t *self);
|
||||
void common_hal_dotclockframebuffer_framebuffer_refresh(dotclockframebuffer_framebuffer_obj_t *self);
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/enum.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/dotclockframebuffer/__init__.h"
|
||||
#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h"
|
||||
|
||||
//| """Native helpers for driving parallel displays"""
|
||||
|
||||
|
||||
STATIC const mp_rom_map_elem_t dotclockframebuffer_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_dotclockframebuffer) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DotClockFramebuffer), MP_ROM_PTR(&dotclockframebuffer_framebuffer_type) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(dotclockframebuffer_module_globals, dotclockframebuffer_module_globals_table);
|
||||
|
||||
const mp_obj_module_t dotclockframebuffer_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t *)&dotclockframebuffer_module_globals,
|
||||
};
|
||||
|
||||
MP_REGISTER_MODULE(MP_QSTR_dotclockframebuffer, dotclockframebuffer_module);
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
|
@ -47,6 +47,9 @@
|
|||
#if CIRCUITPY_SHARPDISPLAY
|
||||
#include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h"
|
||||
#endif
|
||||
#if CIRCUITPY_DOTCLOCKFRAMEBUFFER
|
||||
#include "common-hal/dotclockframebuffer/DotClockFramebuffer.h"
|
||||
#endif
|
||||
// Port unique frame buffers.
|
||||
#if CIRCUITPY_VIDEOCORE
|
||||
#include "bindings/videocore/Framebuffer.h"
|
||||
|
@ -78,6 +81,9 @@ typedef struct {
|
|||
#if CIRCUITPY_PICODVI
|
||||
picodvi_framebuffer_obj_t picodvi;
|
||||
#endif
|
||||
#if CIRCUITPY_DOTCLOCKFRAMEBUFFER
|
||||
dotclockframebuffer_framebuffer_obj_t dotclock;
|
||||
#endif
|
||||
};
|
||||
} primary_display_bus_t;
|
||||
|
||||
|
|
|
@ -43,6 +43,11 @@ extern uint32_t _ebss;
|
|||
|
||||
safe_mode_t port_init(void);
|
||||
|
||||
// If the port does not initialize the heap during port_init(), it must provide
|
||||
// this function which is called after CIRCUITPY is mounted.
|
||||
// If not required, a default (weak) implementation that does nothing is used.
|
||||
safe_mode_t port_heap_init(safe_mode_t);
|
||||
|
||||
// Reset the microcontroller completely.
|
||||
void reset_cpu(void) NORETURN;
|
||||
|
||||
|
|
|
@ -38,12 +38,18 @@
|
|||
// 9 in some translations sometime in the future. This length excludes
|
||||
// the trailing NUL, though notably decompress_length includes it.
|
||||
//
|
||||
// - followed by the huffman encoding of the individual UTF-16 code
|
||||
// - followed by the huffman encoding of the individual code
|
||||
// points that make up the string. The trailing "\0" is not
|
||||
// represented by a huffman code, but is implied by the length.
|
||||
// (building the huffman encoding on UTF-16 code points gave better
|
||||
// compression than building it on UTF-8 bytes)
|
||||
//
|
||||
// - If possible, the code points are represented as uint8_t values, with
|
||||
// 0..127 representing themselves and 160..255 representing another range
|
||||
// of Unicode, controlled by translation_offset and translation_offstart.
|
||||
// If this is not possible, uint16_t values are used. At present, no translation
|
||||
// requires code points not in the BMP, so this is adequate.
|
||||
//
|
||||
// - code points starting at 128 (word_start) and potentially extending
|
||||
// to 255 (word_end) (but never interfering with the target
|
||||
// language's used code points) stand for dictionary entries in a
|
||||
|
|
|
@ -55,6 +55,7 @@ DEFAULT_CLUSTERLIST = {
|
|||
"espressif_esp32s3_devkitc_1_n8r2",
|
||||
"espressif_esp32s3_devkitc_1_n8r8",
|
||||
"espressif_esp32s3_devkitc_1_n32r8",
|
||||
"espressif_esp32s3_devkitc_1_n8r8_hacktablet",
|
||||
],
|
||||
"0x303A:0x7009": [
|
||||
"espressif_esp32s2_devkitc_1_n4",
|
||||
|
@ -138,7 +139,8 @@ def check_vid_pid(files, clusterlist):
|
|||
f"Duplicate VID/PID usage found!\n{duplicates}\n"
|
||||
f"If you are open source maker, then you can request a PID from http://pid.codes\n"
|
||||
f"For boards without native USB, you can request a Creator ID from https://github.com/creationid/creators/\n"
|
||||
f"Otherwise, companies should pay the USB-IF for a vendor ID: https://www.usb.org/getting-vendor-id"
|
||||
f"Otherwise, companies should pay the USB-IF for a vendor ID: https://www.usb.org/getting-vendor-id\n"
|
||||
f"FAQ: Why does CircuitPython require a unique VID:PID for every board definition? https://learn.adafruit.com/how-to-add-a-new-board-to-circuitpython/frequently-asked-questions#faq-3130480"
|
||||
)
|
||||
sys.exit(duplicate_message)
|
||||
|
||||
|
|
Loading…
Reference in New Issue