diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 3a2e1c86b..cb337a12e 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1934,7 +1934,7 @@ uint16_t mode_palette() { using wideMathType = int64_t; using angleType = uint16_t; constexpr mathType sInt16Scale = 0x7FFF; - constexpr mathType maxAngle = 0xFFFF; + constexpr mathType maxAngle = 0x8000; constexpr mathType staticRotationScale = 256; constexpr mathType animatedRotationScale = 1; constexpr int16_t (*sinFunction)(uint16_t) = &sin16; @@ -1944,7 +1944,7 @@ uint16_t mode_palette() { using wideMathType = float; using angleType = float; constexpr mathType sInt16Scale = 1.0f; - constexpr mathType maxAngle = M_TWOPI / 256.0; + constexpr mathType maxAngle = M_PI / 256.0; constexpr mathType staticRotationScale = 1.0f; constexpr mathType animatedRotationScale = M_TWOPI / double(0xFFFF); constexpr float (*sinFunction)(float) = &sin_t; @@ -1952,7 +1952,7 @@ uint16_t mode_palette() { #endif const bool isMatrix = strip.isMatrix; const int cols = SEGMENT.virtualWidth(); - const int rows = isMatrix ? SEGMENT.virtualHeight() : strip.getSegmentsNum(); + const int rows = isMatrix ? SEGMENT.virtualHeight() : strip.getActiveSegmentsNum(); const int inputShift = SEGMENT.speed; const int inputSize = SEGMENT.intensity; @@ -1961,7 +1961,7 @@ uint16_t mode_palette() { const bool inputAnimateRotation = SEGMENT.check2; const bool inputAssumeSquare = SEGMENT.check3; - const int paletteOffset = (!inputAnimateShift) ? (inputShift) : (((strip.now * ((inputShift >> 3) +1)) & 0xFFFF) >> 8); + const int paletteOffset = (!inputAnimateShift) ? (inputShift-128) : (((strip.now * ((inputShift >> 3) +1)) & 0xFFFF) >> 8); const angleType theta = (!inputAnimateRotation) ? (inputRotation * maxAngle / staticRotationScale) : (((strip.now * ((inputRotation >> 4) +1)) & 0xFFFF) * animatedRotationScale); const mathType sinTheta = sinFunction(theta); @@ -1975,14 +1975,14 @@ uint16_t mode_palette() { const mathType maxYOut = !inputAssumeSquare ? maxY : mathType(1); const mathType centerX = sInt16Scale * maxXOut / mathType(2); const mathType centerY = sInt16Scale * maxYOut / mathType(2); - const mathType scale = std::abs(cosTheta) + (std::abs(sinTheta) * maxYOut / maxXOut); + const mathType scale = std::abs(sinTheta) + (std::abs(cosTheta) * maxYOut / maxXOut); const int yFrom = isMatrix ? 0 : strip.getCurrSegmentId(); const int yTo = isMatrix ? maxY : yFrom; for (int y = yFrom; y <= yTo; ++y) { - const mathType ytSinTheta = mathType((wideMathType(sinTheta) * wideMathType(y * sInt16Scale - centerY * maxYIn))/wideMathType(maxYIn * scale)); + const mathType ytCosTheta = mathType((wideMathType(cosTheta) * wideMathType(y * sInt16Scale - centerY * maxYIn))/wideMathType(maxYIn * scale)); for (int x = 0; x < cols; ++x) { - const mathType xtCosTheta = mathType((wideMathType(cosTheta) * wideMathType(x * sInt16Scale - centerX * maxXIn))/wideMathType(maxXIn * scale)); - const mathType sourceX = xtCosTheta + ytSinTheta + centerX; + const mathType xtSinTheta = mathType((wideMathType(sinTheta) * wideMathType(x * sInt16Scale - centerX * maxXIn))/wideMathType(maxXIn * scale)); + const mathType sourceX = xtSinTheta + ytCosTheta + centerX; int colorIndex = (std::min(std::max(sourceX, mathType(0)), maxXOut * sInt16Scale) * 255) / (sInt16Scale * maxXOut); if (inputSize <= 128) { colorIndex = (colorIndex * inputSize) / 128; @@ -2001,7 +2001,7 @@ uint16_t mode_palette() { } return FRAMETIME; } -static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Shift,Size,Rotation,,,Animate Shift,Animate Rotation,Physical Square;;!;12;c1=64,o1=1,o2=1,o3=0"; +static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Shift,Size,Rotation,,,Animate Shift,Animate Rotation,Anamorphic;;!;12;c1=128,c2=128,c3=128,o1=1,o2=1,o3=0"; // WLED limitation: Analog Clock overlay will NOT work when Fire2012 is active