Skip to content

Commit 52447b3

Browse files
committed
sys/light_matrix: don't show stop on shutdown
Ordering of the shutdown and user program events is not guaranteed so we need to make sure that a user program stop event doesn't turn the light light matrix back on while we are shutting down. Fixes: pybricks/support#384
1 parent 7de4629 commit 52447b3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/pbio/sys/light_matrix.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ void pbsys_hub_light_matrix_handle_event(process_event_t event, process_data_t d
107107
// REVISIT: could do a shutdown animation
108108
pbsys_hub_light_matrix_clear();
109109
}
110-
} else if (event == PBIO_EVENT_STATUS_CLEARED && (pbio_pybricks_status_t)data == PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING) {
111-
pbsys_hub_light_matrix_show_stop_sign();
110+
} else if (event == PBIO_EVENT_STATUS_CLEARED) {
111+
pbio_pybricks_status_t status = (intptr_t)data;
112+
113+
if (status == PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING && !pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN)) {
114+
pbsys_hub_light_matrix_show_stop_sign();
115+
}
112116
}
113117
}
114118

0 commit comments

Comments
 (0)