From 4db0f9e3432fc2fbd82b7087ad3ee66491e56417 Mon Sep 17 00:00:00 2001 From: true Date: Sat, 16 Nov 2024 13:28:51 -0800 Subject: [PATCH] minor fixes and cleanups fixed rgb_waving to correct LED count. change some LED program defaults. --- nametag8_CH592/.cproject | 6 +--- .../.settings/language.settings.xml | 2 +- nametag8_CH592/user/led/rgbled_prog.c | 30 +++++++++---------- nametag8_CH592/user/main.c | 6 ++-- nametag8_CH592/user/user_config.c | 4 +-- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/nametag8_CH592/.cproject b/nametag8_CH592/.cproject index 1201a96..3d2d5f3 100644 --- a/nametag8_CH592/.cproject +++ b/nametag8_CH592/.cproject @@ -159,9 +159,5 @@ - - - - - + diff --git a/nametag8_CH592/.settings/language.settings.xml b/nametag8_CH592/.settings/language.settings.xml index fe18132..eeec916 100644 --- a/nametag8_CH592/.settings/language.settings.xml +++ b/nametag8_CH592/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/nametag8_CH592/user/led/rgbled_prog.c b/nametag8_CH592/user/led/rgbled_prog.c index 64a82a3..a1211af 100644 --- a/nametag8_CH592/user/led/rgbled_prog.c +++ b/nametag8_CH592/user/led/rgbled_prog.c @@ -290,7 +290,7 @@ void rgb_waving(uint8_t *a, uint16_t tick) uint8_t desatfade = a[1] & 0x20; rgb_waving_divider++; - rgb_waving_divider %= 10; + rgb_waving_divider %= RGBLED_COUNT; if (!rgb_waving_divider && (a[1] & 0x02)) { for (i = 0; i < RGBLED_COUNT; i++) { if (hsv_out[i].v <= trailfade) { @@ -342,16 +342,16 @@ void rgb_waving(uint8_t *a, uint16_t tick) break; } case 1: { // moving down - hsv_out[rgb_map[ a[6]]].h = uconf.favcolor_hue * 6; - hsv_out[rgb_map[ a[6]]].s = uconf.favcolor_sat; - hsv_out[rgb_map[ a[6]]].v = uconf.favcolor_val; + hsv_out[rgb_map[ a[6]]].h = uconf.favcolor_hue * 6; + hsv_out[rgb_map[ a[6]]].s = uconf.favcolor_sat; + hsv_out[rgb_map[ a[6]]].v = uconf.favcolor_val; - hsv_out[rgb_map[9 - a[6]]].h = uconf.favcolor_hue * 6; - hsv_out[rgb_map[9 - a[6]]].s = uconf.favcolor_sat; - hsv_out[rgb_map[9 - a[6]]].v = uconf.favcolor_val; + hsv_out[rgb_map[RGBLED_COUNT - 1 - a[6]]].h = uconf.favcolor_hue * 6; + hsv_out[rgb_map[RGBLED_COUNT - 1 - a[6]]].s = uconf.favcolor_sat; + hsv_out[rgb_map[RGBLED_COUNT - 1 - a[6]]].v = uconf.favcolor_val; a[6]++; - if (a[6] >= 5) { + if (a[6] >= (RGBLED_COUNT >> 1) - 1) { a[5] = stall; a[4]++; break; @@ -360,16 +360,16 @@ void rgb_waving(uint8_t *a, uint16_t tick) break; } case 3: { // moving up - hsv_out[rgb_map[4 - a[6]]].h = uconf.favcolor_hue * 6; - hsv_out[rgb_map[4 - a[6]]].s = uconf.favcolor_sat; - hsv_out[rgb_map[4 - a[6]]].v = uconf.favcolor_val; + hsv_out[rgb_map[(RGBLED_COUNT >> 1) + 0 - a[6]]].h = uconf.favcolor_hue * 6; + hsv_out[rgb_map[(RGBLED_COUNT >> 1) + 0 - a[6]]].s = uconf.favcolor_sat; + hsv_out[rgb_map[(RGBLED_COUNT >> 1) + 0 - a[6]]].v = uconf.favcolor_val; - hsv_out[rgb_map[5 + a[6]]].h = uconf.favcolor_hue * 6; - hsv_out[rgb_map[5 + a[6]]].s = uconf.favcolor_sat; - hsv_out[rgb_map[5 + a[6]]].v = uconf.favcolor_val; + hsv_out[rgb_map[(RGBLED_COUNT >> 1) + 1 + a[6]]].h = uconf.favcolor_hue * 6; + hsv_out[rgb_map[(RGBLED_COUNT >> 1) + 1 + a[6]]].s = uconf.favcolor_sat; + hsv_out[rgb_map[(RGBLED_COUNT >> 1) + 1 + a[6]]].v = uconf.favcolor_val; a[6]++; - if (a[6] >= 5) { + if (a[6] >= (RGBLED_COUNT >> 1) - 1) { a[5] = stall; a[4]++; break; diff --git a/nametag8_CH592/user/main.c b/nametag8_CH592/user/main.c index bdff234..28882de 100644 --- a/nametag8_CH592/user/main.c +++ b/nametag8_CH592/user/main.c @@ -21,8 +21,6 @@ * * todo: * - decouple oled render routine from interrupt off time. not an issue for now... - * - shrink main tick interrupt routine to incrementing a flag - * - implement better CPU usage statistics * */ @@ -60,7 +58,7 @@ #define PROG_TICK_RATE ((32768-8192-4096) / 256) // not sure why this value can't be 32768/256 // this was checked with a stopwatch and is close enough - // this value IS FRAMERATE DEPENDENT... todo: fix this and make this accurate + // this value IS FRAMERATE DEPENDENT for some reason... figure it out later #define IDLE_SLEEP_START (1 << 0) #define IDLE_MENU_START (1 << 1) #define IDLE_DIM_START (1 << 2) @@ -70,7 +68,7 @@ -const uint8_t vers[] = "241109a"; +const uint8_t vers[] = "241116a"; uint32_t cpu_use = 0; uint32_t cpu_max = 0; diff --git a/nametag8_CH592/user/user_config.c b/nametag8_CH592/user/user_config.c index bb099b7..660ef5e 100644 --- a/nametag8_CH592/user/user_config.c +++ b/nametag8_CH592/user/user_config.c @@ -22,8 +22,8 @@ uint16_t uconf_flash_offset; static const uint8_t uconf_edge_defaults[8][8] = { {0x03, 0x10, 0x04, 0x00, 0x00, 0x00, 0xff, 0xa0}, // solid color - {0x03, 0x10, 0x04, 0x00, 0x00, 0x00, 0xff, 0xa0}, // flicker - {0x15, 0x42, 0x50, 0x00, 0xa0, 0x30, 0xff, 0x20}, // circles + {0x03, 0x1f, 0x04, 0x00, 0x00, 0x00, 0xff, 0xa0}, // flicker + {0x15, 0x42, 0x0b, 0x00, 0xa0, 0x30, 0xff, 0x20}, // circles {0x03, 0x10, 0x04, 0x00, 0x00, 0x00, 0xff, 0xa0}, // waving {0x03, 0x11, 0x05, 0x00, 0x00, 0x00, 0xff, 0x80}, // rainbow {0x00, 0x01, 0x01, 0x00, 0x00, 0x66, 0x46, 0x80}, // cop mode