Skip to content

Commit 5b4f70d

Browse files
committed
revert last commit
1 parent 26c4b37 commit 5b4f70d

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

shared-module/displayio/__init__.c

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -463,37 +463,13 @@ void displayio_gc_collect(void) {
463463
}
464464
}
465465

466-
/*
467466
static bool is_display_active(mp_obj_base_t *display_maybe) {
468467
return display_maybe->type != &mp_type_NoneType && display_maybe->type != NULL;
469468
}
470-
*/
471-
472-
static bool is_any_display_active(primary_display_t *display_maybe) {
473-
if (display_maybe->display_base.type != &mp_type_NoneType && display_maybe->display_base.type != NULL) {
474-
return true;
475-
}
476-
#if CIRCUITPY_BUSDISPLAY
477-
if (display_maybe->display.base.type != &mp_type_NoneType && display_maybe->display.base.type != NULL) {
478-
return true;
479-
}
480-
#endif
481-
#if CIRCUITPY_FRAMEBUFFERIO
482-
if (display_maybe->framebuffer_display.base.type != &mp_type_NoneType && display_maybe->framebuffer_display.base.type != NULL) {
483-
return true;
484-
}
485-
#endif
486-
#if CIRCUITPY_EPAPERDISPLAY
487-
if (display_maybe->epaper_display.base.type != &mp_type_NoneType && display_maybe->epaper_display.base.type != NULL) {
488-
return true;
489-
}
490-
#endif
491-
return false;
492-
}
493469

494470
primary_display_t *allocate_display(void) {
495471
for (uint8_t i = 0; i < max_num_displays; i++) {
496-
if (!is_any_display_active(DYN_DISPLAYS_ADR0(i))) {
472+
if (!is_display_active(DYN_DISPLAYS_ADR(i, display_base))) {
497473
// Clear this memory so it is in a known state before init.
498474
memset(DYN_DISPLAYS_ADR0(i), 0, sizeof(displays[0]));
499475
// Default to None so that it works as board.DISPLAY.
@@ -553,8 +529,8 @@ mp_obj_t common_hal_displayio_get_primary_display(void) {
553529
if (primary_display_number == -1 || primary_display_number >= max_num_displays) {
554530
return mp_const_none;
555531
}
556-
primary_display_t *primary_display = DYN_DISPLAYS_ADR0(primary_display_number);
557-
if (is_any_display_active(primary_display)) {
532+
mp_obj_base_t *primary_display = DYN_DISPLAYS_ADR(primary_display_number, display_base);
533+
if (is_display_active(primary_display)) {
558534
return MP_OBJ_FROM_PTR(primary_display);
559535
}
560536
return mp_const_none;
@@ -567,7 +543,7 @@ void common_hal_displayio_set_primary_display(mp_obj_t new_primary_display) {
567543
}
568544
for (uint8_t i = 0; i < max_num_displays; i++) {
569545
mp_obj_t display = MP_OBJ_FROM_PTR(DYN_DISPLAYS_ADR0(i));
570-
if (new_primary_display == display && is_any_display_active(display)) {
546+
if (new_primary_display == display && is_display_active(display)) {
571547
primary_display_number = i;
572548
return;
573549
}
@@ -581,7 +557,7 @@ void common_hal_displayio_auto_primary_display(void) {
581557
return;
582558
}
583559
for (uint8_t i = 0; i < max_num_displays; i++) {
584-
if (is_any_display_active(DYN_DISPLAYS_ADR0(i))) {
560+
if (is_display_active(DYN_DISPLAYS_ADR(i, display_base))) {
585561
primary_display_number = i;
586562
return;
587563
}

0 commit comments

Comments
 (0)