fix bugs in circle fade program
This commit is contained in:
parent
0ac7f4e7e2
commit
010eeae72f
|
@ -110,14 +110,14 @@ uint8_t rgbp_circlefade(uint8_t init)
|
||||||
// set our timer when initializing. otherwise every call is identical
|
// set our timer when initializing. otherwise every call is identical
|
||||||
if (init) {
|
if (init) {
|
||||||
prog_timeout = CF_TIMEOUT;
|
prog_timeout = CF_TIMEOUT;
|
||||||
circlefade_idx = 0;
|
circlefade_idx = 4; // top LED
|
||||||
}
|
}
|
||||||
|
|
||||||
if (--prog_timeout) {
|
if (--prog_timeout) {
|
||||||
t = (uint8_t)(CF_TIMEOUT - prog_timeout); // get time elapsed
|
t = (uint8_t)(CF_TIMEOUT - prog_timeout); // get time elapsed
|
||||||
t &= 0x3; // light a new LED every 4th loop
|
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++) {
|
for (i = 0; i < (sizeof(rgbled) / sizeof(rgbled[0])); i++) {
|
||||||
if (rgbled[i] >= CF_FADERATE) {
|
if (rgbled[i] >= CF_FADERATE) {
|
||||||
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
|
if (!t) { // then on a loop boundary, light the next LED
|
||||||
rgb.setPixelColor(circlefade_idx, CF_BRIGHTNESS, CF_BRIGHTNESS, CF_BRIGHTNESS);
|
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;
|
circlefade_idx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue