Skip to content

Commit d45daef

Browse files
committed
MicroPython: Switch from MICROPY_EVENT_POLL_HOOK to mp_event_handle_nowait().
Note: Unsure if mp_event_handle_nowait() is the right answer in all cases, but this seems to be what we want in our blocking loops.
1 parent 1b3d9d9 commit d45daef

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

micropython/modules/badger2040/badger2040.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ mp_obj_t Badger2040_update(mp_obj_t self_in) {
122122
_Badger2040_obj_t *self = MP_OBJ_TO_PTR2(self_in, _Badger2040_obj_t);
123123

124124
while(self->badger2040->is_busy()) {
125-
#ifdef MICROPY_EVENT_POLL_HOOK
126-
MICROPY_EVENT_POLL_HOOK
125+
#ifdef mp_event_handle_nowait
126+
mp_event_handle_nowait();
127127
#endif
128128
}
129129

@@ -133,8 +133,8 @@ MICROPY_EVENT_POLL_HOOK
133133
// Ensure blocking for the minimum amount of time
134134
// in cases where "is_busy" is unreliable.
135135
while(self->badger2040->is_busy() || absolute_time_diff_us(get_absolute_time(), t_end) > 0) {
136-
#ifdef MICROPY_EVENT_POLL_HOOK
137-
MICROPY_EVENT_POLL_HOOK
136+
#ifdef mp_event_handle_nowait
137+
mp_event_handle_nowait();
138138
#endif
139139
}
140140

@@ -166,8 +166,8 @@ mp_obj_t Badger2040_partial_update(size_t n_args, const mp_obj_t *pos_args, mp_m
166166

167167

168168
while(self->badger2040->is_busy()) {
169-
#ifdef MICROPY_EVENT_POLL_HOOK
170-
MICROPY_EVENT_POLL_HOOK
169+
#ifdef mp_event_handle_nowait
170+
mp_event_handle_nowait();
171171
#endif
172172
}
173173

@@ -177,8 +177,8 @@ MICROPY_EVENT_POLL_HOOK
177177
// Ensure blocking for the minimum amount of time
178178
// in cases where "is_busy" is unreliable.
179179
while(self->badger2040->is_busy() || absolute_time_diff_us(get_absolute_time(), t_end) > 0) {
180-
#ifdef MICROPY_EVENT_POLL_HOOK
181-
MICROPY_EVENT_POLL_HOOK
180+
#ifdef mp_event_handle_nowait
181+
mp_event_handle_nowait();
182182
#endif
183183
}
184184

@@ -199,8 +199,8 @@ mp_obj_t Badger2040_halt(mp_obj_t self_in) {
199199

200200
self->badger2040->update_button_states();
201201
while (self->badger2040->button_states() == 0) {
202-
#ifdef MICROPY_EVENT_POLL_HOOK
203-
MICROPY_EVENT_POLL_HOOK
202+
#ifdef mp_event_handle_nowait
203+
mp_event_handle_nowait();
204204
#endif
205205
self->badger2040->update_button_states();
206206
}

micropython/modules/jpegdec/jpegdec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ int32_t jpegdec_seek_callback(JPEGFILE *jpeg, int32_t p) {
8484
}
8585

8686
int JPEGDraw(JPEGDRAW *pDraw) {
87-
#ifdef MICROPY_EVENT_POLL_HOOK
88-
MICROPY_EVENT_POLL_HOOK
87+
#ifdef mp_event_handle_nowait
88+
mp_event_handle_nowait();
8989
#endif
9090
PicoGraphics *current_graphics = (PicoGraphics *)pDraw->pUser;
9191
// "pixel" is slow and clipped,

micropython/modules/pico_scroll/pico_scroll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mp_obj_t picoscroll_scroll_text(mp_uint_t n_args, const mp_obj_t *args) {
110110
self->scroll->clear();
111111
self->scroll->set_bitmap_1d((const char *)draw_buffer, draw_buffer_len, brightness, offset);
112112
self->scroll->update();
113-
MICROPY_EVENT_POLL_HOOK
113+
mp_event_handle_nowait();
114114
sleep_ms(delay_ms);
115115
}
116116

micropython/modules/picographics/picographics.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,16 +623,16 @@ mp_obj_t ModPicoGraphics_update(mp_obj_t self_in) {
623623
*/
624624

625625
while(self->display->is_busy()) {
626-
#ifdef MICROPY_EVENT_POLL_HOOK
627-
MICROPY_EVENT_POLL_HOOK
626+
#ifdef mp_event_handle_nowait
627+
mp_event_handle_nowait();
628628
#endif
629629
}
630630

631631
self->display->update(self->graphics);
632632

633633
while(self->display->is_busy()) {
634-
#ifdef MICROPY_EVENT_POLL_HOOK
635-
MICROPY_EVENT_POLL_HOOK
634+
#ifdef mp_event_handle_nowait
635+
mp_event_handle_nowait();
636636
#endif
637637
}
638638

@@ -647,8 +647,8 @@ mp_obj_t ModPicoGraphics_partial_update(size_t n_args, const mp_obj_t *args) {
647647
ModPicoGraphics_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self], ModPicoGraphics_obj_t);
648648

649649
while(self->display->is_busy()) {
650-
#ifdef MICROPY_EVENT_POLL_HOOK
651-
MICROPY_EVENT_POLL_HOOK
650+
#ifdef mp_event_handle_nowait
651+
mp_event_handle_nowait();
652652
#endif
653653
}
654654

@@ -660,8 +660,8 @@ mp_obj_t ModPicoGraphics_partial_update(size_t n_args, const mp_obj_t *args) {
660660
});
661661

662662
while(self->display->is_busy()) {
663-
#ifdef MICROPY_EVENT_POLL_HOOK
664-
MICROPY_EVENT_POLL_HOOK
663+
#ifdef mp_event_handle_nowait
664+
mp_event_handle_nowait();
665665
#endif
666666
}
667667

micropython/modules/pngdec/pngdec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ void pngdec_open_helper(_PNG_obj_t *self) {
118118
}
119119

120120
void PNGDraw(PNGDRAW *pDraw) {
121-
#ifdef MICROPY_EVENT_POLL_HOOK
122-
MICROPY_EVENT_POLL_HOOK
121+
#ifdef mp_event_handle_nowait
122+
mp_event_handle_nowait();
123123
#endif
124124
_PNG_decode_target *target = (_PNG_decode_target*)pDraw->pUser;
125125
PicoGraphics *current_graphics = (PicoGraphics *)target->target;

0 commit comments

Comments
 (0)