From 6171f0dc604d5905ce06e9d417775439ba12c9a9 Mon Sep 17 00:00:00 2001 From: Will Toohey Date: Tue, 6 Apr 2021 20:52:19 +1000 Subject: [PATCH] Make h44b light mapping explicit --- src/main/jbio-p4io/jbio.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/jbio-p4io/jbio.c b/src/main/jbio-p4io/jbio.c index e3c42c1..576da8b 100644 --- a/src/main/jbio-p4io/jbio.c +++ b/src/main/jbio-p4io/jbio.c @@ -190,11 +190,34 @@ bool jb_io_set_panel_mode(enum jb_io_panel_mode mode) void jb_io_set_rgb_led(enum jb_io_rgb_led unit, uint8_t r, uint8_t g, uint8_t b) { - // enum jb_io_rgb_led matches the ACIO message order - uint8_t *raw_lights = (uint8_t*)&jb_io_new_lights; - raw_lights[unit * 3] = r; - raw_lights[unit * 3 + 1] = g; - raw_lights[unit * 3 + 2] = b; + uint8_t *light; + + switch(unit) { + case JB_IO_RGB_LED_FRONT: + light = jb_io_new_lights.front_rgb; + break; + case JB_IO_RGB_LED_TOP: + light = jb_io_new_lights.top_rgb; + break; + case JB_IO_RGB_LED_LEFT: + light = jb_io_new_lights.left_rgb; + break; + case JB_IO_RGB_LED_RIGHT: + light = jb_io_new_lights.right_rgb; + break; + case JB_IO_RGB_LED_TITLE: + light = jb_io_new_lights.title_rgb; + break; + case JB_IO_RGB_LED_WOOFER: + light = jb_io_new_lights.woofer_rgb; + break; + default: + return; + } + + light[0] = r; + light[1] = g; + light[2] = b; } bool jb_io_set_coin_blocker(bool blocked) {