File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 55#include <stdbool.h>
66#include <stdint.h>
77
8+ #include <contiki.h>
9+
810#include <pbdrv/led.h>
911#include <pbio/color.h>
1012#include <pbio/error.h>
@@ -178,12 +180,33 @@ static void pbsys_status_light_handle_status_change() {
178180 }
179181}
180182
183+ static clock_time_t default_user_program_light_animation_next (pbio_light_animation_t * animation ) {
184+ // Each pixel has a repeating brightness pattern of the form /\_ through
185+ // which we can cycle in 256 steps.
186+ static uint8_t cycle = 0 ;
187+
188+ // The pixels are spread equally across the pattern with minimum brightness of 50.
189+ pbio_color_hsv_t hsv = {
190+ .h = PBIO_COLOR_HUE_GREEN ,
191+ .s = 100 ,
192+ .v = (cycle > 200 ? 0 : (cycle < 100 ? cycle : 200 - cycle )) / 2 + 50 ,
193+ };
194+
195+ pbsys_status_light -> funcs -> set_hsv (pbsys_status_light , & hsv );
196+
197+ // This increment controls the speed of the pattern
198+ cycle += 4 ;
199+
200+ return clock_from_msec (40 );
201+ }
202+
181203void pbsys_status_light_handle_event (process_event_t event , process_data_t data ) {
182204 if (event == PBIO_EVENT_STATUS_SET || event == PBIO_EVENT_STATUS_CLEARED ) {
183205 pbsys_status_light_handle_status_change ();
184206 }
185207 if (event == PBIO_EVENT_STATUS_SET && (pbsys_status_t )data == PBSYS_STATUS_USER_PROGRAM_RUNNING ) {
186- pbio_color_light_on (pbsys_status_light , PBIO_COLOR_GREEN );
208+ pbio_light_animation_init (& pbsys_status_light -> animation , default_user_program_light_animation_next );
209+ pbio_light_animation_start (& pbsys_status_light -> animation );
187210 }
188211}
189212
You can’t perform that action at this time.
0 commit comments