Merge pull request #1804 from blazoncek/chunchun-fix

Slight modification of Chunchun effect.
This commit is contained in:
Aircoookie 2021-03-19 00:05:21 +01:00 committed by GitHub
commit e2242f5d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3627,15 +3627,15 @@ uint16_t WS2812FX::mode_chunchun(void)
{ {
fill(SEGCOLOR(1)); fill(SEGCOLOR(1));
uint16_t counter = now*(6 + (SEGMENT.speed >> 4)); uint16_t counter = now*(6 + (SEGMENT.speed >> 4));
uint16_t numBirds = SEGLEN >> 2; uint16_t numBirds = 2 + (SEGLEN >> 3); // 2 + 1/8 of a segment
uint16_t span = SEGMENT.intensity << 8; uint16_t span = (SEGMENT.intensity << 8) / numBirds;
for (uint16_t i = 0; i < numBirds; i++) for (uint16_t i = 0; i < numBirds; i++)
{ {
counter -= span/numBirds; counter -= span;
int megumin = sin16(counter) + 0x8000; uint16_t megumin = sin16(counter) + 0x8000;
uint32_t bird = (megumin * SEGLEN) >> 16; uint32_t bird = (megumin * SEGLEN) >> 16;
uint32_t c = color_from_palette((i * 255)/ numBirds, false, true, 0); uint32_t c = color_from_palette((i * 255)/ numBirds, false, false, 0); // no palette wrapping
setPixelColor(bird, c); setPixelColor(bird, c);
} }
return FRAMETIME; return FRAMETIME;