Skip to content

Commit 700f343

Browse files
committed
pbio/sys/hmi: Move animations to respective HMI.
Relavant animations can be started when successfully starting a program, rather than having variant specific code in the main system loop.
1 parent a79304b commit 700f343

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

lib/pbio/sys/hmi_lcd.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
#include <stdint.h>
1414

1515
#include <pbdrv/bluetooth.h>
16+
#include <pbdrv/display.h>
1617

1718
#include <pbio/button.h>
1819
#include <pbio/os.h>
1920
#include <pbsys/host.h>
21+
#include <pbio/image.h>
22+
#include <pbsys/light.h>
2023
#include <pbsys/main.h>
2124
#include <pbsys/status.h>
2225
#include <pbsys/storage_settings.h>
@@ -116,6 +119,14 @@ static pbio_error_t run_ui(pbio_os_state_t *state, pbio_os_timer_t *timer) {
116119
}
117120
pbdrv_button_get_pressed();
118121
}));
122+
123+
// Clear UI from display to start user program.
124+
pbio_image_fill(pbdrv_display_get_image(), 0);
125+
pbdrv_display_update();
126+
127+
// Start light or display animations.
128+
pbio_color_light_start_breathe_animation(pbsys_status_light_main, PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS_HUE);
129+
119130
PBIO_OS_ASYNC_END(PBIO_SUCCESS);
120131
}
121132

lib/pbio/sys/hmi_pup.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <pbio/button.h>
1818
#include <pbio/os.h>
1919
#include <pbsys/host.h>
20+
#include <pbsys/light.h>
2021
#include <pbsys/main.h>
2122
#include <pbsys/status.h>
2223
#include <pbsys/storage_settings.h>
@@ -208,6 +209,15 @@ static pbio_error_t run_ui(pbio_os_state_t *state, pbio_os_timer_t *timer) {
208209
}
209210
pbdrv_button_get_pressed();
210211
}));
212+
213+
// Start run animations
214+
pbsys_hub_light_matrix_handle_user_program_start();
215+
#if PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS
216+
pbio_color_light_start_breathe_animation(pbsys_status_light_main, PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS_HUE);
217+
#else
218+
pbio_color_light_off(pbsys_status_light_main);
219+
#endif
220+
211221
PBIO_OS_ASYNC_END(PBIO_SUCCESS);
212222
}
213223

lib/pbio/sys/light_matrix.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ static uint32_t pbsys_hub_light_matrix_user_program_animation_next(pbio_light_an
157157
*/
158158
void pbsys_hub_light_matrix_handle_user_program_start(void) {
159159

160-
#if PBSYS_CONFIG_HUB_LIGHT_MATRIX_DISPLAY
161-
pbio_image_fill(pbdrv_display_get_image(), 0);
162-
pbdrv_display_update();
163-
return;
164-
#endif
165-
166160
// The user animation updates only a subset of pixels to save time,
167161
// so the rest must be cleared before it starts.
168162
pbsys_hub_light_matrix_user_program_animation_clear();

lib/pbio/sys/main.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ int main(int argc, char **argv) {
102102
pbsys_status_set_program_id(program.id);
103103
pbsys_status_set(PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING);
104104
pbsys_host_stdin_set_callback(pbsys_main_stdin_event);
105-
pbsys_hub_light_matrix_handle_user_program_start();
106-
107-
#if PBSYS_CONFIG_STATUS_LIGHT
108-
#if PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS
109-
pbio_color_light_start_breathe_animation(pbsys_status_light_main, PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS_HUE);
110-
#else
111-
pbio_color_light_off(pbsys_status_light_main);
112-
#endif
113-
#endif
114105

115106
// Handle pending events triggered by the status change, such as
116107
// starting status light animation.

0 commit comments

Comments
 (0)