File tree Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,6 @@ void pbsys_hmi_init(void) {
175175
176176void pbsys_hmi_handle_status_change (pbsys_status_change_t event , pbio_pybricks_status_t data ) {
177177 pbsys_status_light_handle_status_change (event , data );
178- pbsys_hub_light_matrix_handle_status_change (event , data );
179178}
180179
181180/**
Original file line number Diff line number Diff line change @@ -143,22 +143,19 @@ static uint32_t pbsys_hub_light_matrix_user_program_animation_next(pbio_light_an
143143 return 40 ;
144144}
145145
146- void pbsys_hub_light_matrix_handle_status_change (pbsys_status_change_t event , pbio_pybricks_status_t data ) {
147-
148- pbio_pybricks_status_t status = (intptr_t )data ;
149-
150- // Only need to handle changing program running state.
151- if (status != PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING ) {
152- return ;
153- }
154-
155- if (event == PBSYS_STATUS_CHANGE_SET ) {
146+ /**
147+ * Updates light matrix behavior when program is started or stopped.
148+ *
149+ * @param start @c true for start or @c false for stop.
150+ */
151+ void pbsys_hub_light_matrix_handle_user_program_start (bool start ) {
152+ if (start ) {
156153 // The user animation updates only a subset of pixels to save time,
157154 // so the rest must be cleared before it starts.
158155 pbsys_hub_light_matrix_user_program_animation_clear ();
159156 pbio_light_animation_init (& pbsys_hub_light_matrix -> animation , pbsys_hub_light_matrix_user_program_animation_next );
160157 pbio_light_animation_start (& pbsys_hub_light_matrix -> animation );
161- } else if ( event == PBSYS_STATUS_CHANGE_CLEARED ) {
158+ } else {
162159 // If the user program has ended, show stop sign and selected slot.
163160 pbsys_hub_light_matrix_show_idle_ui (100 );
164161 }
Original file line number Diff line number Diff line change 1111#if PBSYS_CONFIG_HUB_LIGHT_MATRIX
1212void pbsys_hub_light_matrix_init (void );
1313void pbsys_hub_light_matrix_deinit (void );
14- void pbsys_hub_light_matrix_handle_status_change ( pbsys_status_change_t event , pbio_pybricks_status_t data );
14+ void pbsys_hub_light_matrix_handle_user_program_start ( bool start );
1515void pbsys_hub_light_matrix_update_program_slot (void );
1616#else
1717#define pbsys_hub_light_matrix_init ()
1818#define pbsys_hub_light_matrix_deinit ()
19- #define pbsys_hub_light_matrix_handle_status_change ( event , data )
19+ #define pbsys_hub_light_matrix_handle_user_program_start ( start )
2020#define pbsys_hub_light_matrix_update_program_slot ()
2121#endif
2222
Original file line number Diff line number Diff line change 1717#include <pbsys/main.h>
1818#include <pbsys/status.h>
1919
20+ #include "light_matrix.h"
2021#include "program_stop.h"
2122#include "storage.h"
2223#include <pbsys/program_stop.h>
@@ -105,6 +106,7 @@ int main(int argc, char **argv) {
105106 pbsys_status_set_program_id (program .id );
106107 pbsys_status_set (PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING );
107108 pbsys_host_rx_set_callback (pbsys_main_stdin_event );
109+ pbsys_hub_light_matrix_handle_user_program_start (true);
108110
109111 // Handle pending events triggered by the status change, such as
110112 // starting status light animation.
@@ -118,6 +120,7 @@ int main(int argc, char **argv) {
118120 pbsys_status_clear (PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING );
119121 pbsys_host_rx_set_callback (NULL );
120122 pbsys_program_stop_set_buttons (PBIO_BUTTON_CENTER );
123+ pbsys_hub_light_matrix_handle_user_program_start (false);
121124 pbio_stop_all (true);
122125 program .start_request_type = PBSYS_MAIN_PROGRAM_START_REQUEST_TYPE_NONE ;
123126
You can’t perform that action at this time.
0 commit comments