2323
2424#if PBSYS_CONFIG_HUB_LIGHT_MATRIX
2525
26- typedef struct {
27- /** Struct for PBIO light matrix implementation. */
28- pbio_light_matrix_t light_matrix ;
29- } pbsys_hub_light_matrix_t ;
30-
31- static pbsys_hub_light_matrix_t pbsys_hub_light_matrix_instance ;
32-
33- /** The hub built-in light matrix instance. */
34- pbio_light_matrix_t * pbsys_hub_light_matrix = & pbsys_hub_light_matrix_instance .light_matrix ;
35-
36- static pbio_error_t pbsys_hub_light_matrix_set_pixel (pbio_light_matrix_t * light_matrix , uint8_t row , uint8_t col , uint8_t brightness ) {
37- #if PBSYS_CONFIG_HUB_LIGHT_MATRIX_LED_ARRAY
38- // REVISIT: currently hub light matrix is hard-coded as LED array at index 0
39- // on all platforms
40- pbdrv_led_array_dev_t * array ;
41- if (pbdrv_led_array_get_dev (0 , & array ) == PBIO_SUCCESS ) {
42- return pbdrv_led_array_set_brightness (array , row * light_matrix -> size + col , brightness );
43- }
44- #elif PBSYS_CONFIG_HUB_LIGHT_MATRIX_DISPLAY
45- pbio_image_t * display = pbdrv_display_get_image ();
46- uint8_t value = brightness * (pbdrv_display_get_max_value () + 1 ) / 100 ;
47- const uint32_t size = PBDRV_CONFIG_DISPLAY_NUM_ROWS / PBSYS_CONFIG_HMI_NUM_SLOTS ;
48- const uint32_t width = size * 4 / 5 ;
49- const uint32_t offset = (PBDRV_CONFIG_DISPLAY_NUM_COLS - (PBSYS_CONFIG_HMI_NUM_SLOTS * size )) / 2 ;
50- pbio_image_fill_rect (display , col * size + offset , row * size , width , width , value );
51- pbdrv_display_update ();
52- return PBIO_SUCCESS ;
53- #endif
54- return PBIO_ERROR_NOT_SUPPORTED ;
55- }
56-
57- static const pbio_light_matrix_funcs_t pbsys_hub_light_matrix_funcs = {
58- .set_pixel = pbsys_hub_light_matrix_set_pixel ,
59- };
26+ // revisit, we will drop this in the next commit
27+ pbio_light_matrix_t * pbsys_hub_light_matrix ;
6028
6129/**
6230 * Displays the idle UI. Has a square stop sign and selected slot on bottom row.
@@ -70,7 +38,7 @@ static void pbsys_hub_light_matrix_show_idle_ui(uint8_t brightness) {
7038 #if PBSYS_CONFIG_HMI_NUM_SLOTS
7139 is_on |= (r == 4 && c == pbsys_status_get_selected_slot ());
7240 #endif
73- pbsys_hub_light_matrix_set_pixel (pbsys_hub_light_matrix , r , c , is_on ? brightness : 0 );
41+ pbio_light_matrix_set_pixel (pbsys_hub_light_matrix , r , c , is_on ? brightness : 0 , false );
7442 }
7543 }
7644}
@@ -109,7 +77,7 @@ static void pbsys_hub_light_matrix_start_power_animation(void) {
10977}
11078
11179void pbsys_hub_light_matrix_init (void ) {
112- pbio_light_matrix_init ( pbsys_hub_light_matrix , 5 , & pbsys_hub_light_matrix_funcs );
80+ pbio_light_matrix_get_dev ( 0 , 5 , & pbsys_hub_light_matrix );
11381 pbsys_hub_light_matrix_start_power_animation ();
11482}
11583
@@ -124,7 +92,7 @@ void pbsys_hub_light_matrix_deinit(void) {
12492static void pbsys_hub_light_matrix_user_program_animation_clear (void ) {
12593 for (uint8_t r = 0 ; r < 3 ; r ++ ) {
12694 for (uint8_t c = 1 ; c < 4 ; c ++ ) {
127- pbsys_hub_light_matrix_set_pixel (pbsys_hub_light_matrix , r , c , 0 );
95+ pbio_light_matrix_set_pixel (pbsys_hub_light_matrix , r , c , 0 , true );
12896 }
12997 }
13098}
@@ -144,7 +112,7 @@ static uint32_t pbsys_hub_light_matrix_user_program_animation_next(pbio_light_an
144112 uint8_t brightness = offset > 200 ? 0 : (offset < 100 ? offset : 200 - offset );
145113
146114 // Set the brightness for this pixel
147- pbsys_hub_light_matrix_set_pixel (pbsys_hub_light_matrix , indexes [i ] / 5 , indexes [i ] % 5 , brightness );
115+ pbio_light_matrix_set_pixel (pbsys_hub_light_matrix , indexes [i ] / 5 , indexes [i ] % 5 , brightness , false );
148116 }
149117 // This increment controls the speed of the pattern
150118 cycle += 9 ;
0 commit comments