Skip to content

Commit 5ea9cb1

Browse files
committed
Octopus code improvements
* removed dead code * merge octopusStep and radialStep --> octoSpeed * improve speed slider resolution by first multiplying, then dividing Thanks @ewoudwijma
1 parent 9046ec4 commit 5ea9cb1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

wled00/FX.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8628,13 +8628,14 @@ uint16_t mode_2Doctopus() {
86288628
}
86298629
}
86308630

8631-
if (true) // WLEDMM SuperSync
8632-
SEGENV.step = strip.now * (SEGMENT.speed / 32 + 1) / 25; // WLEDMM 40fps
8633-
else
8634-
SEGENV.step += SEGMENT.speed / 32 + 1; // 1-4 range
8631+
// WLEDMM SuperSync
8632+
SEGENV.step = (strip.now * (SEGMENT.speed+15)) / 33 / 25; // WLEDMM 40fps; speed range 0.4 ... 8
86358633

8636-
uint32_t octopusStep = SEGENV.step/2; // 1/2 for Octopus mode
8637-
uint32_t radialStep = 7*SEGENV.step/6; // 7/6 = 1.16 for RadialWave mode
8634+
// speed of motion and color change
8635+
uint32_t colorSpeed = SEGENV.step / 2;
8636+
uint32_t octoSpeed;
8637+
if (SEGMENT.check3) octoSpeed = 4*SEGENV.step/5; // 4/5 = 0.8 for RadialWave mode
8638+
else octoSpeed = SEGENV.step/2; // 1/2 = 0.5 for Octopus mode
86388639

86398640
for (int x = xStart; x < xEnd; x++) {
86408641
for (int y = yStart; y < yEnd; y++) {
@@ -8643,12 +8644,12 @@ uint16_t mode_2Doctopus() {
86438644
//CRGB c = CHSV(SEGENV.step / 2 - radius, 255, sin8(sin8((angle * 4 - radius) / 4 + SEGENV.step) + radius - SEGENV.step * 2 + angle * (SEGMENT.custom3/3+1)));
86448645
uint16_t intensity;
86458646
if (SEGMENT.check3)
8646-
intensity = sin8(radialStep + sin8(radialStep - radius) + angle * (SEGMENT.custom3/4+1)); // RadialWave
8647+
intensity = sin8(octoSpeed + sin8(octoSpeed - radius) + angle * (SEGMENT.custom3/4+1)); // RadialWave
86478648
else
8648-
intensity = sin8(sin8((angle * 4 - radius) / 4 + octopusStep) + radius - SEGENV.step + angle * (SEGMENT.custom3/4+1)); // Octopus
8649+
intensity = sin8(sin8((angle * 4 - radius) / 4 + octoSpeed) + radius - SEGENV.step + angle * (SEGMENT.custom3/4+1)); // Octopus
86498650
//intensity = map(intensity*intensity, 0, 65535, 0, 255); // add a bit of non-linearity for cleaner display
86508651
intensity = (intensity * intensity) / 255; // WLEDMM same as above, but faster and a bit more accurate
8651-
CRGB c = ColorFromPalette(SEGPALETTE, SEGENV.step / 2 - radius, intensity);
8652+
CRGB c = ColorFromPalette(SEGPALETTE, colorSpeed - radius, intensity);
86528653
SEGMENT.setPixelColorXY(x, y, c);
86538654
}
86548655
}

0 commit comments

Comments
 (0)