From 5abf09b69d1e04e8c2ba9cf87748428500c6e65e Mon Sep 17 00:00:00 2001 From: true Date: Sat, 26 Oct 2024 06:16:13 -0700 Subject: [PATCH] fix RGBLED offsets --- nametag8_CH592/user/led/rgbled.c | 33 +++++++++++++++++++++++---- nametag8_CH592/user/led/rgbled_prog.c | 5 ++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/nametag8_CH592/user/led/rgbled.c b/nametag8_CH592/user/led/rgbled.c index 857edd7..0d59467 100644 --- a/nametag8_CH592/user/led/rgbled.c +++ b/nametag8_CH592/user/led/rgbled.c @@ -45,10 +45,32 @@ static const uint16_t pwm_cie_256in_1024out[] = { }; */ -static const uint8_t rgbled_map[12] = { - 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11 +/* + * there are various RGBLED arrangements to consider: + * addressed order: 0 1 2 3 4 5 6 7 8 9 10 11 + * off by one: 1 2 3 4 5 6 7 8 9 10 11 12 + * connected order: 5 4 6 2 1 3 11 10 12 8 7 9 + * clockwise from TL: 6 3 5 2 4 1 10 7 11 8 12 9 + * these form the following conversion map: + */ + +/* +// rgb output order: +static const uint8_t led_map[12] = { + 2, 5, 0, 3, 1, 4, + 7, 10, 6, 9, 8, 11 }; +*/ +/* +// program input order: +static const uint8_t led_map[12] = { + 4, 3, 5, 1, 0, 2, + 10, 9, 11, 7, 6, 8 +}; +*/ + +// manually figured out order because I can't math when sleep deprived: + @@ -104,7 +126,10 @@ void rgbled_send() memset(awled_fade, 0x00, sizeof(awled_fade)); } else { for (i = 0; i < RGBLED_COUNT; i++) { - hsv2rgb(hsv_out[i].h, hsv_out[i].s, hsv_out[i].v, fade+0, fade+1, fade+2); + hsv2rgb(hsv_out[i].h, + hsv_out[i].s, + hsv_out[i].v, + fade+0, fade+1, fade+2); fade += 3; } } diff --git a/nametag8_CH592/user/led/rgbled_prog.c b/nametag8_CH592/user/led/rgbled_prog.c index 2a861b6..cc69071 100644 --- a/nametag8_CH592/user/led/rgbled_prog.c +++ b/nametag8_CH592/user/led/rgbled_prog.c @@ -24,9 +24,10 @@ #include "user_config.h" + const uint8_t rgb_map[RGBLED_COUNT] = { - 3, 5, 7, 9, 0, 1, - 2, 4, 6, 8, 1, 1 + 2, 5, 0, 3, 1, 4, + 7, 10, 6, 9, 8, 11 }; static uint8_t timeout;