Skip to content

Commit c9d7195

Browse files
authored
Merge pull request #8447 from tannewt/5.1_enable_rgbmatrix
Enable rgbmatrix on IDF 5.1
2 parents f3fc1f7 + 376cb87 commit c9d7195

File tree

12 files changed

+46
-20
lines changed

12 files changed

+46
-20
lines changed

main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ STATIC void stop_mp(void) {
219219
usb_background();
220220
#endif
221221

222+
// Set the qstr pool back to the const pools. The heap allocated ones will
223+
// be overwritten.
224+
qstr_reset();
225+
222226
gc_deinit();
223227
}
224228

ports/espressif/boards/adafruit_feather_esp32s3_4mbflash_2mbpsram/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ IDF_TARGET = esp32s3
77

88
CIRCUITPY_ESP_FLASH_SIZE = 4MB
99
CIRCUITPY_ESP_FLASH_MODE = qio
10-
CIRCUITPY_ESP_FLASH_FREQ = 40m
10+
CIRCUITPY_ESP_FLASH_FREQ = 80m
1111

1212
CIRCUITPY_ESP_PSRAM_SIZE = 2MB
1313
CIRCUITPY_ESP_PSRAM_MODE = qio

ports/espressif/mpconfigport.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ CIRCUITPY_NVM ?= 1
3939
# Turn off because it uses the old I2S driver which conflicts with the new ADC driver.
4040
CIRCUITPY_PARALLELDISPLAY ?= 0
4141
CIRCUITPY_PS2IO ?= 1
42-
# Disabled temporarily
43-
CIRCUITPY_RGBMATRIX ?= 0
42+
CIRCUITPY_RGBMATRIX ?= 1
4443
CIRCUITPY_ROTARYIO ?= 1
4544
CIRCUITPY_SYNTHIO_MAX_CHANNELS ?= 12
4645
CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1

py/qstr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@ extern const qstr_pool_t MICROPY_QSTR_EXTRA_POOL;
122122
#define CONST_POOL mp_qstr_const_pool
123123
#endif
124124

125-
void qstr_init(void) {
125+
void qstr_reset(void) {
126126
MP_STATE_VM(last_pool) = (qstr_pool_t *)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left
127127
MP_STATE_VM(qstr_last_chunk) = NULL;
128+
}
129+
130+
void qstr_init(void) {
131+
qstr_reset();
128132

129133
#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
130134
mp_thread_mutex_init(&MP_STATE_VM(qstr_mutex));

py/qstr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef struct _qstr_pool_t {
7878

7979
#define QSTR_TOTAL() (MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len)
8080

81+
void qstr_reset(void);
8182
void qstr_init(void);
8283

8384
mp_uint_t qstr_compute_hash(const byte *data, size_t len);

shared-bindings/displayio/Display.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,15 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos
276276
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
277277

278278
displayio_display_obj_t *self = native_display(pos_args[0]);
279-
uint32_t maximum_ms_per_real_frame = 0xffffffff;
279+
uint32_t maximum_ms_per_real_frame = NO_FPS_LIMIT;
280280
mp_int_t minimum_frames_per_second = args[ARG_minimum_frames_per_second].u_int;
281281
if (minimum_frames_per_second > 0) {
282282
maximum_ms_per_real_frame = 1000 / minimum_frames_per_second;
283283
}
284284

285285
uint32_t target_ms_per_frame;
286286
if (args[ARG_target_frames_per_second].u_obj == mp_const_none) {
287-
target_ms_per_frame = 0xffffffff;
287+
target_ms_per_frame = NO_FPS_LIMIT;
288288
} else {
289289
target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj);
290290
}

shared-bindings/displayio/Display.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
extern const mp_obj_type_t displayio_display_type;
3636

3737
#define NO_BRIGHTNESS_COMMAND 0x100
38+
#define NO_FPS_LIMIT 0xffffffff
3839

3940
void common_hal_displayio_display_construct(displayio_display_obj_t *self,
4041
mp_obj_t bus, uint16_t width, uint16_t height,

shared-bindings/framebufferio/FramebufferDisplay.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,39 +100,55 @@ static framebufferio_framebufferdisplay_obj_t *native_display(mp_obj_t display_o
100100
}
101101

102102
//| def refresh(
103-
//| self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1
103+
//| self,
104+
//| *,
105+
//| target_frames_per_second: Optional[int] = None,
106+
//| minimum_frames_per_second: int = 0
104107
//| ) -> bool:
105-
//| """When auto refresh is off, waits for the target frame rate and then refreshes the display,
106-
//| returning True. If the call has taken too long since the last refresh call for the given
107-
//| target frame rate, then the refresh returns False immediately without updating the screen to
108+
//| """When auto_refresh is off, and :py:attr:`target_frames_per_second` is not `None` this waits
109+
//| for the target frame rate and then refreshes the display,
110+
//| returning `True`. If the call has taken too long since the last refresh call for the given
111+
//| target frame rate, then the refresh returns `False` immediately without updating the screen to
108112
//| hopefully help getting caught up.
109113
//|
110114
//| If the time since the last successful refresh is below the minimum frame rate, then an
111-
//| exception will be raised. Set minimum_frames_per_second to 0 to disable.
115+
//| exception will be raised. The default :py:attr:`minimum_frames_per_second` of 0 disables this behavior.
112116
//|
113-
//| When auto refresh is on, updates the display immediately. (The display will also update
117+
//| When auto_refresh is off, and :py:attr:`target_frames_per_second` is `None` this
118+
//| will update the display immediately.
119+
//|
120+
//| When auto_refresh is on, updates the display immediately. (The display will also update
114121
//| without calls to this.)
115122
//|
116-
//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated.
123+
//| :param Optional[int] target_frames_per_second: The target frame rate that :py:func:`refresh` should try to
124+
//| achieve. Set to `None` for immediate refresh.
117125
//| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.
118126
//| """
119127
//| ...
120128
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
121129
enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second };
122130
static const mp_arg_t allowed_args[] = {
123-
{ MP_QSTR_target_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 60} },
124-
{ MP_QSTR_minimum_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
131+
{ MP_QSTR_target_frames_per_second, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
132+
{ MP_QSTR_minimum_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
125133
};
134+
126135
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
127136
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
128137

129138
framebufferio_framebufferdisplay_obj_t *self = native_display(pos_args[0]);
130-
uint32_t maximum_ms_per_real_frame = 0xffffffff;
139+
uint32_t maximum_ms_per_real_frame = NO_FPS_LIMIT;
131140
mp_int_t minimum_frames_per_second = args[ARG_minimum_frames_per_second].u_int;
132141
if (minimum_frames_per_second > 0) {
133142
maximum_ms_per_real_frame = 1000 / minimum_frames_per_second;
134143
}
135-
return mp_obj_new_bool(common_hal_framebufferio_framebufferdisplay_refresh(self, 1000 / args[ARG_target_frames_per_second].u_int, maximum_ms_per_real_frame));
144+
145+
uint32_t target_ms_per_frame;
146+
if (args[ARG_target_frames_per_second].u_obj == mp_const_none) {
147+
target_ms_per_frame = NO_FPS_LIMIT;
148+
} else {
149+
target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj);
150+
}
151+
return mp_obj_new_bool(common_hal_framebufferio_framebufferdisplay_refresh(self, target_ms_per_frame, maximum_ms_per_real_frame));
136152
}
137153
MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_refresh_obj, 1, framebufferio_framebufferdisplay_obj_refresh);
138154

shared-bindings/framebufferio/FramebufferDisplay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
extern const mp_obj_type_t framebufferio_framebufferdisplay_type;
3737

3838
#define NO_BRIGHTNESS_COMMAND 0x100
39+
#define NO_FPS_LIMIT 0xffffffff
3940

4041
void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t *self,
4142
mp_obj_t framebuffer,

0 commit comments

Comments
 (0)