Skip to content

Commit 3b0b4d3

Browse files
Merge remote-tracking branch 'upstream/main' into main git diff main pixel_trinkey_test# Please enter a commit message to explain why this merge is necessary,
2 parents 3b864ae + e5e7c9e commit 3b0b4d3

File tree

75 files changed

+516
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+516
-387
lines changed

docs/environment.rst

+48-4
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,14 @@ Wi-Fi SSID to auto-connect to even if user code is not running.
101101
Additional board specific keys
102102
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103103

104-
`MaTouch ESP32-S3 Parallel TFT with Touch 7“ <https://circuitpython.org/board/makerfabs_tft7/>`_
105-
106-
CIRCUITPY_DISPLAY_WIDTH
107-
~~~~~~~~~~~~~~~~~~~~~~~
104+
CIRCUITPY_DISPLAY_WIDTH (Sunton, MaTouch)
105+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108106
Selects the correct screen resolution (1024x600 or 800x640) for the particular board variant.
109107
If the CIRCUITPY_DISPLAY_WIDTH parameter is set to a value of 1024 the display is initialized
110108
during power up at 1024x600 otherwise the display will be initialized at a resolution
111109
of 800x480.
112110

111+
`MaTouch ESP32-S3 Parallel TFT with Touch 7“ <https://circuitpython.org/board/makerfabs_tft7/>`_
113112
`Sunton ESP32-2432S028 <https://circuitpython.org/board/sunton_esp32_2432S028/>`_
114113
`Sunton ESP32-2432S024C <https://circuitpython.org/board/sunton_esp32_2432S024C/>`_
115114

@@ -122,6 +121,8 @@ a rotation of 0. Attempting to initialize the screen with a rotation other than
122121
90, 180 or 270 is not supported and will result in an unexpected screen rotation.
123122

124123
`Sunton ESP32-8048S050 <https://circuitpython.org/board/sunton_esp32_8048S050/>`_
124+
`Adafruit Feather RP2350 <https://circuitpython.org/board/adafruit_feather_rp2350/>`_
125+
`Adafruit Metro RP2350 <https://circuitpython.org/board/adafruit_metro_rp2350/>`_
125126

126127
CIRCUITPY_DISPLAY_FREQUENCY
127128
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -130,3 +131,46 @@ If a valid frequency is not defined the board will initialize the framebuffer wi
130131
frequency of 12500000hz (12.5Mhz). The value should be entered as an integer in hertz
131132
i.e. CIRCUITPY_DISPLAY_FREQUENCY=16000000 will override the default value with a 16Mhz
132133
display frequency.
134+
135+
`Sunton ESP32-8048S050 <https://circuitpython.org/board/sunton_esp32_8048S050/>`_
136+
137+
138+
CIRCUITPY_PICODVI_ENABLE
139+
~~~~~~~~~~~~~~~~~~~~~~~~
140+
Whether to configure the display at board initialization time, one of the following:
141+
142+
.. code-block::
143+
144+
CIRCUITPY_PICODVI_ENABLE="detect" # when EDID EEPROM is detected (default)
145+
CIRCUITPY_PICODVI_ENABLE="always"
146+
CIRCUITPY_PICODVI_ENABLE="never"
147+
148+
A display configured in this manner is available at ``supervisor.runtime.display``
149+
until it is released by ``displayio.release_displays()``. It does not appear at
150+
``board.DISPLAY``.
151+
152+
`Adafruit Feather RP2350 <https://circuitpython.org/board/adafruit_feather_rp2350/>`_
153+
`Adafruit Metro RP2350 <https://circuitpython.org/board/adafruit_metro_rp2350/>`_
154+
155+
CIRCUITPY_DISPLAY_WIDTH, CIRCUITPY_DISPLAY_HEIGHT, and CIRCUITPY_DISPLAY_COLOR_DEPTH (RP2350 boards with DVI or HSTX connector)
156+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157+
Selects the desired resolution and color depth.
158+
159+
Supported resolutions are:
160+
* 640x480 with color depth 1, 2, 4 or 8 bits per pixel
161+
* 320x240 with color depth 8 or 16 bits per pixel
162+
163+
The default value, if unspecified, is 320x240 with 16 bits per pixel.
164+
165+
If height is unspecified, it is set from the width. For example, a width of 640
166+
implies a height of 480.
167+
168+
Example: Configure the display to 640x480 black and white (1 bit per pixel):
169+
170+
.. code-block::
171+
172+
CIRCUITPY_DISPLAY_WIDTH=640
173+
CIRCUITPY_DISPLAY_COLOR_DEPTH=1
174+
175+
`Adafruit Feather RP2350 <https://circuitpython.org/board/adafruit_feather_rp2350/>`_
176+
`Adafruit Metro RP2350 <https://circuitpython.org/board/adafruit_metro_rp2350/>`_

main.c

+7
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ static bool __attribute__((noinline)) run_code_py(safe_mode_t safe_mode, bool *s
772772
#if CIRCUITPY_ALARM
773773
if (fake_sleeping) {
774774
board_init();
775+
#if CIRCUITPY_DISPLAYIO
776+
common_hal_displayio_auto_primary_display();
777+
#endif
775778
// Pretend that the next run is the first run, as if we were reset.
776779
*simulate_reset = true;
777780
}
@@ -1053,6 +1056,10 @@ int __attribute__((used)) main(void) {
10531056
// displays init after filesystem, since they could share the flash SPI
10541057
board_init();
10551058

1059+
#if CIRCUITPY_DISPLAYIO
1060+
common_hal_displayio_auto_primary_display();
1061+
#endif
1062+
10561063
mp_hal_stdout_tx_str(line_clear);
10571064

10581065
// This is first time we are running CircuitPython after a reset or power-up.

ports/espressif/bindings/espcamera/Camera.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "shared-bindings/displayio/Bitmap.h"
1919
#include "shared-bindings/microcontroller/Pin.h"
2020
#include "shared-bindings/util.h"
21+
#include "shared/runtime/context_manager_helpers.h"
2122
#include "esp_camera.h"
2223
#include "sensor.h"
2324

@@ -169,11 +170,7 @@ static void check_for_deinit(espcamera_camera_obj_t *self) {
169170
//| :ref:`lifetime-and-contextmanagers` for more info."""
170171
//| ...
171172
//|
172-
static mp_obj_t espcamera_camera_obj___exit__(size_t n_args, const mp_obj_t *args) {
173-
(void)n_args;
174-
return espcamera_camera_deinit(args[0]);
175-
}
176-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espcamera_camera___exit___obj, 4, 4, espcamera_camera_obj___exit__);
173+
// Provided by context manager helper.
177174

178175
//| frame_available: bool
179176
//| """True if a frame is available, False otherwise"""
@@ -947,8 +944,8 @@ static const mp_rom_map_elem_t espcamera_camera_locals_table[] = {
947944
{ MP_ROM_QSTR(MP_QSTR_denoise), MP_ROM_PTR(&espcamera_camera_denoise_obj) },
948945
{ MP_ROM_QSTR(MP_QSTR_framebuffer_count), MP_ROM_PTR(&espcamera_camera_framebuffer_count_obj) },
949946
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&espcamera_camera_deinit_obj) },
950-
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
951-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espcamera_camera___exit___obj) },
947+
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
948+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
952949
{ MP_ROM_QSTR(MP_QSTR_exposure_ctrl), MP_ROM_PTR(&espcamera_camera_exposure_ctrl_obj) },
953950
{ MP_ROM_QSTR(MP_QSTR_frame_available), MP_ROM_PTR(&espcamera_camera_frame_available_obj) },
954951
{ MP_ROM_QSTR(MP_QSTR_frame_size), MP_ROM_PTR(&espcamera_camera_frame_size_obj) },

ports/espressif/bindings/espnow/ESPNow.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "py/stream.h"
1313

1414
#include "shared-bindings/util.h"
15+
#include "shared/runtime/context_manager_helpers.h"
1516

1617
#include "bindings/espnow/ESPNow.h"
1718
#include "bindings/espnow/Peer.h"
@@ -92,11 +93,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(espnow_deinit_obj, espnow_deinit);
9293
//| :ref:`lifetime-and-contextmanagers` for more info."""
9394
//| ...
9495
//|
95-
static mp_obj_t espnow_obj___exit__(size_t n_args, const mp_obj_t *args) {
96-
(void)n_args;
97-
return espnow_deinit(args[0]);
98-
}
99-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espnow___exit___obj, 4, 4, espnow_obj___exit__);
96+
// Provided by context manager helper.
10097

10198
// --- Send and Read messages ---
10299

@@ -270,8 +267,8 @@ MP_PROPERTY_GETTER(espnow_peers_obj,
270267

271268
static const mp_rom_map_elem_t espnow_locals_dict_table[] = {
272269
// Context managers
273-
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
274-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espnow___exit___obj) },
270+
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
271+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
275272

276273
// Deinit the object
277274
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&espnow_deinit_obj) },

ports/espressif/bindings/espulp/ULP.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "shared-bindings/microcontroller/Pin.h"
88
#include "shared-bindings/util.h"
9+
#include "shared/runtime/context_manager_helpers.h"
910
#include "bindings/espulp/ULP.h"
1011

1112
#include "py/enum.h"
@@ -69,11 +70,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(espulp_ulp_deinit_obj, espulp_ulp_deinit);
6970
//| :ref:`lifetime-and-contextmanagers` for more info."""
7071
//| ...
7172
//|
72-
static mp_obj_t espulp_ulp_obj___exit__(size_t n_args, const mp_obj_t *args) {
73-
(void)n_args;
74-
return espulp_ulp_deinit(args[0]);
75-
}
76-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espulp_ulp___exit___obj, 4, 4, espulp_ulp_obj___exit__);
73+
// Provided by context manager helper.
7774

7875
//| def set_wakeup_period(self, period_index: int, period_us: int) -> None:
7976
//| """Sets the wakeup period for the ULP.
@@ -188,8 +185,8 @@ MP_PROPERTY_GETTER(espulp_ulp_arch_obj,
188185

189186
static const mp_rom_map_elem_t espulp_ulp_locals_table[] = {
190187
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&espulp_ulp_deinit_obj) },
191-
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
192-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espulp_ulp___exit___obj) },
188+
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
189+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
193190
{ MP_ROM_QSTR(MP_QSTR_set_wakeup_period), MP_ROM_PTR(&espulp_ulp_set_wakeup_period_obj) },
194191
{ MP_ROM_QSTR(MP_QSTR_run), MP_ROM_PTR(&espulp_ulp_run_obj) },
195192
{ MP_ROM_QSTR(MP_QSTR_halt), MP_ROM_PTR(&espulp_ulp_halt_obj) },

ports/raspberrypi/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ ifeq ($(CIRCUITPY_PICODVI),1)
556556
SRC_C += \
557557
bindings/picodvi/__init__.c \
558558
bindings/picodvi/Framebuffer.c \
559+
common-hal/picodvi/__init__.c \
559560
common-hal/picodvi/Framebuffer_$(CHIP_VARIANT).c \
560561

561562
ifeq ($(CHIP_VARIANT),RP2040)

ports/raspberrypi/bindings/picodvi/Framebuffer.h

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
extern const mp_obj_type_t picodvi_framebuffer_type;
1414

15+
bool common_hal_picodvi_framebuffer_preflight(
16+
mp_uint_t width, mp_uint_t height,
17+
mp_uint_t color_depth);
1518
void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
1619
mp_uint_t width, mp_uint_t height,
1720
const mcu_pin_obj_t *clk_dp, const mcu_pin_obj_t *clk_dn,

ports/raspberrypi/bindings/rp2pio/StateMachine.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,6 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_deinit_obj, rp2pio_statemachine_ob
378378
//| :ref:`lifetime-and-contextmanagers` for more info."""
379379
//| ...
380380
//|
381-
static mp_obj_t rp2pio_statemachine_obj___exit__(size_t n_args, const mp_obj_t *args) {
382-
(void)n_args;
383-
common_hal_rp2pio_statemachine_deinit(args[0]);
384-
return mp_const_none;
385-
}
386-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(rp2pio_statemachine_obj___exit___obj, 4, 4, rp2pio_statemachine_obj___exit__);
387381

388382

389383
static void check_for_deinit(rp2pio_statemachine_obj_t *self) {
@@ -1126,7 +1120,7 @@ MP_PROPERTY_GETTER(rp2pio_statemachine_last_write_obj,
11261120
static const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = {
11271121
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&rp2pio_statemachine_deinit_obj) },
11281122
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
1129-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&rp2pio_statemachine_obj___exit___obj) },
1123+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
11301124

11311125
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&rp2pio_statemachine_stop_obj) },
11321126
{ MP_ROM_QSTR(MP_QSTR_restart), MP_ROM_PTR(&rp2pio_statemachine_restart_obj) },

ports/raspberrypi/boards/adafruit_feather_rp2350/board.c

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
//
55
// SPDX-License-Identifier: MIT
66

7+
#include "py/obj.h"
78
#include "supervisor/board.h"
89

10+
#include "common-hal/picodvi/__init__.h"
11+
912
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
13+
14+
void board_init(void) {
15+
picodvi_autoconstruct();
16+
}

ports/raspberrypi/boards/adafruit_feather_rp2350/mpconfigboard.h

+9
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@
2020
#define DEFAULT_UART_BUS_TX (&pin_GPIO0)
2121

2222
#define CIRCUITPY_PSRAM_CHIP_SELECT (&pin_GPIO8)
23+
24+
#define DEFAULT_DVI_BUS_CLK_DN (&pin_GPIO15)
25+
#define DEFAULT_DVI_BUS_CLK_DP (&pin_GPIO14)
26+
#define DEFAULT_DVI_BUS_RED_DN (&pin_GPIO19)
27+
#define DEFAULT_DVI_BUS_RED_DP (&pin_GPIO18)
28+
#define DEFAULT_DVI_BUS_GREEN_DN (&pin_GPIO17)
29+
#define DEFAULT_DVI_BUS_GREEN_DP (&pin_GPIO16)
30+
#define DEFAULT_DVI_BUS_BLUE_DN (&pin_GPIO13)
31+
#define DEFAULT_DVI_BUS_BLUE_DP (&pin_GPIO12)

ports/raspberrypi/boards/adafruit_metro_rp2350/board.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "shared-bindings/usb_host/Port.h"
1010
#include "supervisor/board.h"
1111

12+
#include "common-hal/picodvi/__init__.h"
13+
1214
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
1315

1416

@@ -29,8 +31,9 @@ bool board_reset_pin_number(uint8_t pin_number) {
2931
}
3032
#endif
3133

32-
#if defined(DEFAULT_USB_HOST_DATA_PLUS)
3334
void board_init(void) {
35+
#if defined(DEFAULT_USB_HOST_DATA_PLUS)
3436
common_hal_usb_host_port_construct(DEFAULT_USB_HOST_DATA_PLUS, DEFAULT_USB_HOST_DATA_MINUS);
37+
#endif
38+
picodvi_autoconstruct();
3539
}
36-
#endif

ports/raspberrypi/boards/adafruit_metro_rp2350/mpconfigboard.h

+9
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,12 @@
2626
#define DEFAULT_USB_HOST_DATA_MINUS (&pin_GPIO33)
2727
#define DEFAULT_USB_HOST_5V_POWER (&pin_GPIO29)
2828
#define CIRCUITPY_PSRAM_CHIP_SELECT (&pin_GPIO47)
29+
30+
#define DEFAULT_DVI_BUS_CLK_DN (&pin_GPIO15)
31+
#define DEFAULT_DVI_BUS_CLK_DP (&pin_GPIO14)
32+
#define DEFAULT_DVI_BUS_RED_DN (&pin_GPIO19)
33+
#define DEFAULT_DVI_BUS_RED_DP (&pin_GPIO18)
34+
#define DEFAULT_DVI_BUS_GREEN_DN (&pin_GPIO17)
35+
#define DEFAULT_DVI_BUS_GREEN_DP (&pin_GPIO16)
36+
#define DEFAULT_DVI_BUS_BLUE_DN (&pin_GPIO13)
37+
#define DEFAULT_DVI_BUS_BLUE_DP (&pin_GPIO12)

ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ static void __not_in_flash_func(dma_irq_handler)(void) {
129129
ch->al3_read_addr_trig = (uintptr_t)active_picodvi->dma_commands;
130130
}
131131

132+
bool common_hal_picodvi_framebuffer_preflight(
133+
mp_uint_t width, mp_uint_t height,
134+
mp_uint_t color_depth) {
135+
136+
// for each supported resolution, check the color depth is supported
137+
if (width == 640 && height == 640) {
138+
return color_depth == 1 || color_depth == 2 || color_depth == 4 || color_depth == 8;
139+
}
140+
if (width == 320 && height == 240) {
141+
return color_depth == 8 || color_depth == 16;
142+
}
143+
return false;
144+
}
145+
132146
void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
133147
mp_uint_t width, mp_uint_t height,
134148
const mcu_pin_obj_t *clk_dp, const mcu_pin_obj_t *clk_dn,
@@ -140,7 +154,7 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
140154
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("%q in use"), MP_QSTR_picodvi);
141155
}
142156

143-
if (!(width == 640 && height == 480) && !(width == 320 && height == 240 && (color_depth == 16 || color_depth == 8))) {
157+
if (!common_hal_picodvi_framebuffer_preflight(width, height, color_depth)) {
144158
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q and %q"), MP_QSTR_width, MP_QSTR_height);
145159
}
146160

0 commit comments

Comments
 (0)