Merge remote-tracking branch 'origin/main' into synthio-lfo-dag

This commit is contained in:
Jeff Epler 2023-05-19 11:56:13 -05:00
commit 4da32a7b86
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
22 changed files with 557 additions and 40 deletions

View File

@ -207,11 +207,11 @@ msgstr ""
#: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c
#: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c
#: shared-module/synthio/LFO.c shared-module/synthio/Synthesizer.c
#: shared-module/synthio/Synthesizer.c
msgid "%q must be of type %q or %q, not %q"
msgstr ""
#: py/argcheck.c py/obj.c py/objstrunicode.c
#: py/argcheck.c py/obj.c py/objstrunicode.c shared-module/synthio/__init__.c
msgid "%q must be of type %q, not %q"
msgstr ""
@ -1430,6 +1430,10 @@ msgstr ""
msgid "Nimble out of memory"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
msgid "No %q pin"
msgstr ""
#: ports/espressif/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
@ -1478,14 +1482,12 @@ msgstr ""
msgid "No MOSI pin"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/espressif/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "No RX pin"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/espressif/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
@ -2112,8 +2114,8 @@ msgstr ""
msgid "UART de-init"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
#: ports/espressif/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
#: ports/cxd56/common-hal/busio/UART.c ports/espressif/common-hal/busio/UART.c
#: ports/stm/common-hal/busio/UART.c
msgid "UART init"
msgstr ""

View File

@ -8,8 +8,8 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
"PO-Revision-Date: 2023-04-22 15:51+0000\n"
"Last-Translator: Jose David M <jquintana202020@gmail.com>\n"
"PO-Revision-Date: 2023-05-16 19:50+0000\n"
"Last-Translator: Luis Ruiz San Segundo <luisan00@hotmail.com>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
@ -206,7 +206,7 @@ msgstr "%q debe ser un bytearray o array de tipo 'H' o 'B'"
#: shared-bindings/audiocore/RawSample.c
msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'"
msgstr "%q debe ser un byte-matriz o matriz de tipo 'h', 'H', 'b', o 'B'"
msgstr "%q debe ser un bytearray o array de tipo 'h', 'H', 'b', o 'B'"
#: ports/espressif/common-hal/analogbufio/BufferedIn.c
msgid "%q must be array of type 'H'"
@ -601,8 +601,7 @@ msgstr "Por debajo de la tasa mínima de refrescamiento"
#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
msgid "Bit clock and word select must be sequential pins"
msgstr ""
"Los pines de reloj de bit y de selector de palabra deben ser secuenciales"
msgstr "Los pines \"clock\" y \"word-select\" deben ser consecutivos"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Bit clock and word select must share a clock unit"

View File

@ -241,7 +241,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
}
if (usart_async_init(usart_desc_p, sercom, self->buffer, self->buffer_length, NULL) != ERR_NONE) {
mp_raise_RuntimeError(translate("UART init"));
mp_raise_RuntimeError(NULL);
}
// usart_async_init() sets a number of defaults based on a prototypical SERCOM
@ -396,7 +396,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
// Read characters.
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
if (self->rx_pin == NO_PIN) {
mp_raise_ValueError(translate("No RX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx);
}
// This assignment is only here because the usart_async routines take a *const argument.
@ -453,7 +453,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
if (self->tx_pin == NO_PIN) {
mp_raise_ValueError(translate("No TX pin"));
mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx);
}
// This assignment is only here because the usart_async routines take a *const argument.

View File

@ -120,19 +120,25 @@ CFLAGS += -DSTACK_CANARY_VALUE=0xa5a5a5a5
#Debugging/Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -DDEBUG -ggdb
OPTIMIZATION_FLAGS ?= -Og
# You may want to enable these flags to make setting breakpoints easier.
# CFLAGS += -fno-inline -fno-ipa-sra
CFLAGS += -ggdb
ifeq ($(IDF_TARGET_ARCH),riscv)
OPTIMIZATION_FLAGS ?= -Os
CFLAGS += -DNDEBUG
else
OPTIMIZATION_FLAGS ?= -Og
CFLAGS += -DDEBUG
endif
# You may want to enable these flags to make setting breakpoints easier.
# CFLAGS += -fno-inline -fno-ipa-sra
else
CFLAGS += -DNDEBUG -ggdb3
# RISC-V is larger than xtensa
# Use -Os for RISC-V when it overflows
ifeq ($(IDF_TARGET_ARCH),riscv)
OPTIMIZATION_FLAGS ?= -Os
else
OPTIMIZATION_FLAGS ?= -O2
endif
CFLAGS += -DNDEBUG -ggdb3
# RISC-V is larger than xtensa
# Use -Os for RISC-V when it overflows
ifeq ($(IDF_TARGET_ARCH),riscv)
OPTIMIZATION_FLAGS ?= -Os
else
OPTIMIZATION_FLAGS ?= -O2
endif
endif
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk

View File

@ -0,0 +1,49 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2023 Bill Sideris, independently providing these changes.
*
* 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"
#include "components/driver/include/driver/gpio.h"
#include "components/hal/include/hal/gpio_hal.h"
#include "common-hal/microcontroller/Pin.h"
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 33) {
/*
* Turn on BAT_HOLD by default,
* so that the board does not power off
* when usb is disconnected or
* the power button is released.
*/
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
return true;
}
return false;
}
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -0,0 +1,48 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2023 Bill Sideris, independently providing these changes.
*
* 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.
*/
#define MICROPY_HW_BOARD_NAME "M5Stack Timer Camera X"
#define MICROPY_HW_MCU_NAME "ESP32"
#define MICROPY_HW_LED_STATUS (&pin_GPIO2)
#define CIRCUITPY_BOARD_I2C (3)
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO13, .sda = &pin_GPIO4}, \
{.scl = &pin_GPIO14, .sda = &pin_GPIO12}, \
{.scl = &pin_GPIO23, .sda = &pin_GPIO25}}
// Ext. Port
// BM8563
// Camera sensor
// UART pins attached to the USB-serial converter chip
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (1)
// espcamera.FrameSize.QXGA, half a megabyte result image.jpeg
#define DEFAULT_RESERVED_PSRAM (1572864)

View File

@ -0,0 +1,8 @@
CIRCUITPY_CREATOR_ID = 0x10151015
CIRCUITPY_CREATION_ID = 0x00320009
IDF_TARGET = esp32
CIRCUITPY_ESP_FLASH_MODE = qio
CIRCUITPY_ESP_FLASH_FREQ = 80m
CIRCUITPY_ESP_FLASH_SIZE = 4MB

View File

@ -0,0 +1,87 @@
#include "py/objtuple.h"
#include "shared-bindings/board/__init__.h"
#include "shared-module/displayio/__init__.h"
CIRCUITPY_BOARD_BUS_SINGLETON(bm8563_i2c, i2c, 1) // RTC
CIRCUITPY_BOARD_BUS_SINGLETON(sscb_i2c, i2c, 2) // Camera sensor
STATIC const mp_rom_obj_tuple_t camera_data_tuple = {
// The order matters.
// They must be ordered from low to high (Y2, Y3 .. Y9).
// Do not include any of the control pins in here.
{&mp_type_tuple},
8,
{
MP_ROM_PTR(&pin_GPIO32), // Y2
MP_ROM_PTR(&pin_GPIO35), // Y3
MP_ROM_PTR(&pin_GPIO34), // Y4
MP_ROM_PTR(&pin_GPIO5), // Y5
MP_ROM_PTR(&pin_GPIO39), // Y6
MP_ROM_PTR(&pin_GPIO18), // Y7
MP_ROM_PTR(&pin_GPIO36), // Y8
MP_ROM_PTR(&pin_GPIO19) // Y9
}
};
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) },
// "Ext. Port", the label says [G, V, SDA/G4, SCL/G13]
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_G13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
/* Battery
*
* No alternative names as they are not broken out
* and cannot be used for anything else.
*/
{ MP_ROM_QSTR(MP_QSTR_BAT_HOLD), MP_ROM_PTR(&pin_GPIO33) },
{ MP_ROM_QSTR(MP_QSTR_BAT_ADC), MP_ROM_PTR(&pin_GPIO38) },
/* BM8563 I2C bus
*
* No alternative names as they are not broken out
* and cannot be used for anything else.
*/
{ MP_ROM_QSTR(MP_QSTR_BM8563_SCL), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_BM8563_SDA), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_BM8563_I2C), MP_ROM_PTR(&board_bm8563_i2c_obj) },
// Camera control
{ MP_ROM_QSTR(MP_QSTR_VSYNC), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_HREF), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_PCLK), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_XCLK), MP_ROM_PTR(&pin_GPIO27) }, // xclk_freq_hz = 20000000
{ MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR(&pin_GPIO15) },
// Camera sensor I2C bus
{ MP_ROM_QSTR(MP_QSTR_SSCB_SDA), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_SSCB_SCL), MP_ROM_PTR(&pin_GPIO23) },
{ MP_ROM_QSTR(MP_QSTR_SSCB_I2C), MP_ROM_PTR(&board_sscb_i2c_obj) },
/*
* Camera data
*
* We don't really need to individually name each one,
* but they look cool in the tuple listing if we do.
*
* These are also not broken out.
*/
{ MP_ROM_QSTR(MP_QSTR_D), MP_ROM_PTR(&camera_data_tuple) },
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO36) },
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO39) },
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO34) },
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO35) },
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO32) }
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

View File

@ -0,0 +1,27 @@
# ESP32-D0WDQ6-V3 (revision 3)
CONFIG_ESP32_SPIRAM_SUPPORT=y
CONFIG_ESP32_ECO3_CACHE_LOCK_FIX=y
CONFIG_ESP32_REV_MIN_3=y
# PSRAM
CONFIG_D0WD_PSRAM_CLK_IO=17
CONFIG_D0WD_PSRAM_CS_IO=16
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_TYPE_ESPPSRAM64=y
CONFIG_SPIRAM_SIZE=8388608
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_USE_MEMMAP=y
CONFIG_SPIRAM_MEMTEST=y
# Hostname
CONFIG_LWIP_LOCAL_HOSTNAME="M5StackTimerX"
# Camera
CONFIG_OV3660_SUPPORT=y
CONFIG_GC_SENSOR_SUBSAMPLE_MODE=y
CONFIG_CAMERA_CORE0=y
CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX=32768

View File

@ -62,6 +62,11 @@ static const uint64_t pin_mask_reset_forbidden =
GPIO_SEL_18 | // USB D-
GPIO_SEL_19 | // USB D+
#endif
#if defined(CONFIG_ESP_CONSOLE_UART_DEFAULT) && CONFIG_ESP_CONSOLE_UART_DEFAULT && CONFIG_ESP_CONSOLE_UART_NUM == 0
// Never reset debug UART/console pins.
GPIO_SEL_20 |
GPIO_SEL_21 |
#endif
#endif // ESP32C3
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)

View File

@ -101,21 +101,28 @@ bool usb_serial_jtag_connected(void) {
}
char usb_serial_jtag_read_char(void) {
if (ringbuf_num_filled(&ringbuf) == 0) {
if (ringbuf_num_filled(&ringbuf) == 0 && !usb_serial_jtag_ll_rxfifo_data_available()) {
return -1;
}
char c = ringbuf_get(&ringbuf);
char c = -1;
if (ringbuf_num_filled(&ringbuf) > 0) {
c = ringbuf_get(&ringbuf);
}
// Maybe re-enable the recv interrupt if we've emptied the ringbuf.
if (ringbuf_num_filled(&ringbuf) == 0) {
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT);
_copy_out_of_fifo();
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT);
// May have only been ctrl-c.
if (c == -1 && ringbuf_num_filled(&ringbuf) > 0) {
c = ringbuf_get(&ringbuf);
}
}
return c;
}
bool usb_serial_jtag_bytes_available(void) {
return ringbuf_num_filled(&ringbuf) > 0;
return ringbuf_num_filled(&ringbuf) > 0 || usb_serial_jtag_ll_rxfifo_data_available();
}
void usb_serial_jtag_write(const char *text, uint32_t length) {

View File

@ -26,8 +26,11 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) },

View File

@ -0,0 +1,151 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 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"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#define DELAY 0x80
#define LCD_POWER 22
// display init sequence according to LilyGO example app
uint8_t display_init_sequence[] = {
// sw reset
0x01, 0 | DELAY, 150,
// sleep out
0x11, 0 | DELAY, 255,
// normal display mode on
0x13, 0,
// display and color format settings
0x36, 1, 0x08,
0xB6, 2, 0x0A, 0x82,
0x3A, 1 | DELAY, 0x55, 10,
// ST7789V frame rate setting
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
// voltages: VGH / VGL
0xB7, 1, 0x35,
// ST7789V power setting
0xBB, 1, 0x28,
0xC0, 1, 0x0C,
0xC2, 2, 0x01, 0xFF,
0xC3, 1, 0x10,
0xC4, 1, 0x20,
0xC6, 1, 0x0F,
0xD0, 2, 0xA4, 0xA1,
// ST7789V gamma setting
0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17,
0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E,
0x21, 0,
// display on
0x29, 0 | DELAY, 255,
};
static void display_init(void) {
displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
busio_spi_obj_t *spi = &bus->inline_bus;
common_hal_busio_spi_construct(
spi,
&pin_GPIO2, // CLK
&pin_GPIO3, // MOSI
NULL, // MISO not connected
false); // Not half-duplex
common_hal_busio_spi_never_reset(spi);
bus->base.type = &displayio_fourwire_type;
common_hal_displayio_fourwire_construct(
bus,
spi,
&pin_GPIO1, // DC
&pin_GPIO5, // CS
NULL, // RST (Reset pin tie to 0, do not set here)
40000000, // baudrate
1, // polarity
0 // phase
);
displayio_display_obj_t *display = &allocate_display()->display;
display->base.type = &displayio_display_type;
common_hal_displayio_display_construct(
display,
bus,
240, // width (after rotation)
135, // height (after rotation)
52, // column start
40, // row start
90, // rotation
16, // color depth
false, // grayscale
false, // pixels in a byte share a row. Only valid for depths < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
display_init_sequence,
sizeof(display_init_sequence),
&pin_GPIO4, // backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
false, // auto_brightness
false, // single_byte_bounds
false, // data_as_commands
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false // SH1107_addressing
);
common_hal_never_reset_pin(&pin_GPIO4); // backlight pin
}
void board_init(void) {
// Pin 22 has to be pulled high to turn on the LCD
const uint PWR_PIN = LCD_POWER;
gpio_init(PWR_PIN);
gpio_set_dir(PWR_PIN, GPIO_OUT);
gpio_put(PWR_PIN, 1);
common_hal_never_reset_pin(&pin_GPIO22);
// Display
display_init();
}
bool board_requests_safe_mode(void) {
return false;
}
void reset_board(void) {
}
void board_deinit(void) {
}

View File

@ -0,0 +1,2 @@
#define MICROPY_HW_BOARD_NAME "LILYGO T-DISPLAY"
#define MICROPY_HW_MCU_NAME "rp2040"

View File

@ -0,0 +1,11 @@
USB_VID = 0x1209
USB_PID = 0x2023
USB_PRODUCT = "T-Display"
USB_MANUFACTURER = "Lilygo"
CHIP_VARIANT = RP2040
CHIP_FAMILY = rp2
EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ"
CIRCUITPY__EVE = 1

View File

@ -0,0 +1 @@
// Put board-specific pico-sdk definitions here. This file must exist.

View File

@ -0,0 +1,65 @@
#include "shared-bindings/board/__init__.h"
#include "shared-module/displayio/__init__.h"
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_BUTTON_L), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_BUTTON_R), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) },
{ MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_TFT_POWER), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) },
// 1.14 inch LCD ST7789
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO5) },
{ MP_ROM_QSTR(MP_QSTR_LCD_RESET), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
{ MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) },
{ 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);

View File

@ -48,6 +48,8 @@
#include "lwip/raw.h"
#include "lwip_src/ping.h"
#include "shared/netutils/dhcpserver.h"
#define MAC_ADDRESS_LENGTH 6
#define NETIF_STA (&cyw43_state.netif[CYW43_ITF_STA])
@ -161,7 +163,15 @@ void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self) {
// (by tcpip_link_status). However since ap disconnection isn't working
// either, this is not an issue.
cyw43_wifi_leave(&cyw43_state, CYW43_ITF_AP);
const size_t timeout_ms = 500;
uint64_t start = port_get_raw_ticks(NULL);
uint64_t deadline = start + timeout_ms;
while (port_get_raw_ticks(NULL) < deadline && (cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA) != CYW43_LINK_DOWN)) {
RUN_BACKGROUND_TASKS;
if (mp_hal_is_interrupted()) {
break;
}
}
bindings_cyw43_wifi_enforce_pm();
}
@ -359,11 +369,14 @@ void common_hal_wifi_radio_stop_dhcp_client(wifi_radio_obj_t *self) {
}
void common_hal_wifi_radio_start_dhcp_server(wifi_radio_obj_t *self) {
mp_raise_NotImplementedError(NULL);
ip4_addr_t ipv4_addr, netmask_addr;
ipaddress_ipaddress_to_lwip(common_hal_wifi_radio_get_ipv4_address_ap(self), &ipv4_addr);
ipaddress_ipaddress_to_lwip(common_hal_wifi_radio_get_ipv4_subnet_ap(self), &netmask_addr);
dhcp_server_init(&cyw43_state.dhcp_server, &ipv4_addr, &netmask_addr);
}
void common_hal_wifi_radio_stop_dhcp_server(wifi_radio_obj_t *self) {
mp_raise_NotImplementedError(NULL);
dhcp_server_deinit(&cyw43_state.dhcp_server);
}
void common_hal_wifi_radio_set_ipv4_address(wifi_radio_obj_t *self, mp_obj_t ipv4, mp_obj_t netmask, mp_obj_t gateway, mp_obj_t ipv4_dns) {
@ -380,7 +393,15 @@ void common_hal_wifi_radio_set_ipv4_address(wifi_radio_obj_t *self, mp_obj_t ipv
}
void common_hal_wifi_radio_set_ipv4_address_ap(wifi_radio_obj_t *self, mp_obj_t ipv4, mp_obj_t netmask, mp_obj_t gateway) {
mp_raise_NotImplementedError(NULL);
common_hal_wifi_radio_stop_dhcp_server(self);
ip4_addr_t ipv4_addr, netmask_addr, gateway_addr;
ipaddress_ipaddress_to_lwip(ipv4, &ipv4_addr);
ipaddress_ipaddress_to_lwip(netmask, &netmask_addr);
ipaddress_ipaddress_to_lwip(gateway, &gateway_addr);
netif_set_addr(NETIF_AP, &ipv4_addr, &netmask_addr, &gateway_addr);
common_hal_wifi_radio_start_dhcp_server(self);
}
volatile bool ping_received;

View File

@ -716,7 +716,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
}
#if !MICROPY_VFS
uint mp_import_stat(const char *path) {
mp_import_stat_t mp_import_stat(const char *path) {
struct stat st;
if (stat(path, &st) == 0) {
if (S_ISDIR(st.st_mode)) {

View File

@ -1013,6 +1013,7 @@ bool gc_never_free(void *ptr) {
// Pointers are stored in a linked list where each block is BYTES_PER_BLOCK long and the first
// pointer is the next block of pointers.
void **current_reference_block = MP_STATE_MEM(permanent_pointers);
void **last_reference_block = NULL;
while (current_reference_block != NULL) {
for (size_t i = 1; i < BYTES_PER_BLOCK / sizeof(void *); i++) {
if (current_reference_block[i] == NULL) {
@ -1020,6 +1021,7 @@ bool gc_never_free(void *ptr) {
return true;
}
}
last_reference_block = current_reference_block; // keep a record of last "proper" reference block
current_reference_block = current_reference_block[0];
}
void **next_block = gc_alloc(BYTES_PER_BLOCK, false, true);
@ -1029,7 +1031,7 @@ bool gc_never_free(void *ptr) {
if (MP_STATE_MEM(permanent_pointers) == NULL) {
MP_STATE_MEM(permanent_pointers) = next_block;
} else {
current_reference_block[0] = next_block;
last_reference_block[0] = next_block;
}
next_block[1] = ptr;
return true;

View File

@ -254,12 +254,14 @@ STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args,
STATIC mp_obj_t memoryview_cast(const mp_obj_t self_in, const mp_obj_t typecode_in) {
mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in);
const char *typecode = mp_obj_str_get_str(typecode_in);
size_t element_size = mp_binary_get_size('@', typecode[0], NULL);
size_t bytelen = self->len * mp_binary_get_size('@', self->typecode & ~MP_OBJ_ARRAY_TYPECODE_FLAG_RW, NULL);
if (bytelen % element_size != 0) {
size_t new_element_size = mp_binary_get_size('@', typecode[0], NULL);
size_t old_element_size = mp_binary_get_size('@', self->typecode & ~MP_OBJ_ARRAY_TYPECODE_FLAG_RW, NULL);
size_t bytelen = self->len * old_element_size;
if (bytelen % new_element_size != 0) {
mp_raise_TypeError(MP_ERROR_TEXT("memoryview: length is not a multiple of itemsize"));
}
mp_obj_array_t *result = MP_OBJ_TO_PTR(mp_obj_new_memoryview(*typecode, bytelen / element_size, self->items));
mp_obj_array_t *result = MP_OBJ_TO_PTR(mp_obj_new_memoryview(*typecode, bytelen / new_element_size, self->items));
result->memview_offset = (self->memview_offset * old_element_size) / new_element_size;
// test if the object can be written to
if (self->typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW) {

View File

@ -0,0 +1,21 @@
try:
memoryview(b'a').cast
except:
print("SKIP")
raise SystemExit
b = bytearray(range(16))
def print_memview(mv):
print(", ".join(hex(v) for v in mv))
mv = memoryview(b)
print_memview(mv)
print_memview(mv[4:])
words = mv.cast("I")
print_memview(words)
print_memview(mv[4:].cast("I"))
print_memview(words[1:])
print_memview(words.cast("B"))