From 010eeae72f733bc8d38906bca5da925c6639a803 Mon Sep 17 00:00:00 2001 From: true Date: Fri, 4 Apr 2025 03:01:05 -0700 Subject: [PATCH] fix bugs in circle fade program --- fw/HackSpaceCon/src/rgbled.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fw/HackSpaceCon/src/rgbled.cpp b/fw/HackSpaceCon/src/rgbled.cpp index f245ee6..3be27db 100644 --- a/fw/HackSpaceCon/src/rgbled.cpp +++ b/fw/HackSpaceCon/src/rgbled.cpp @@ -110,14 +110,14 @@ uint8_t rgbp_circlefade(uint8_t init) // set our timer when initializing. otherwise every call is identical if (init) { prog_timeout = CF_TIMEOUT; - circlefade_idx = 0; + circlefade_idx = 4; // top LED } if (--prog_timeout) { t = (uint8_t)(CF_TIMEOUT - prog_timeout); // get time elapsed t &= 0x3; // light a new LED every 4th loop - // fade each LED down every cycle + // fade each LED down every frame for (i = 0; i < (sizeof(rgbled) / sizeof(rgbled[0])); i++) { if (rgbled[i] >= CF_FADERATE) { rgbled[i] -= CF_FADERATE; @@ -131,7 +131,7 @@ uint8_t rgbp_circlefade(uint8_t init) if (!t) { // then on a loop boundary, light the next LED rgb.setPixelColor(circlefade_idx, CF_BRIGHTNESS, CF_BRIGHTNESS, CF_BRIGHTNESS); - if (++circlefade_idx > RGB_COUNT) { // then work on the next LED in sequence + if (++circlefade_idx >= RGB_COUNT) { // then work on the next LED in sequence circlefade_idx = 0; } }