99
1010#include <contiki.h>
1111
12+ #include <pbdrv/display.h>
1213#include <pbdrv/led.h>
14+ #include <pbio/image.h>
1315#include <pbio/error.h>
1416#include <pbio/light_matrix.h>
1517#include <pbio/util.h>
@@ -32,14 +34,24 @@ static pbsys_hub_light_matrix_t pbsys_hub_light_matrix_instance;
3234pbio_light_matrix_t * pbsys_hub_light_matrix = & pbsys_hub_light_matrix_instance .light_matrix ;
3335
3436static 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
3538 // REVISIT: currently hub light matrix is hard-coded as LED array at index 0
3639 // on all platforms
3740 pbdrv_led_array_dev_t * array ;
3841 if (pbdrv_led_array_get_dev (0 , & array ) == PBIO_SUCCESS ) {
3942 return pbdrv_led_array_set_brightness (array , row * light_matrix -> size + col , brightness );
4043 }
41-
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 ();
4252 return PBIO_SUCCESS ;
53+ #endif
54+ return PBIO_ERROR_NOT_SUPPORTED ;
4355}
4456
4557static const pbio_light_matrix_funcs_t pbsys_hub_light_matrix_funcs = {
0 commit comments