fixed palette FX to more closely match original 1D version

- rotation scale is now exactly 180° (divide slider input by 255 instead of 256)
- removed shift offset: offset is now zero at slider 0, to hit 128 on touch input devices is really hard
- added a 90° shift to input rotation, enabling to rotate from 0 to 180° instead of +90 to -90 (which is not useful in 1D)
- changed default settings values to more closely match the old 1D effect
This commit is contained in:
Damian Schneider 2024-11-09 16:38:18 +01:00
parent 271a07a7d6
commit 536444f9d1

View File

@ -1940,7 +1940,7 @@ uint16_t mode_palette() {
using angleType = unsigned; using angleType = unsigned;
constexpr mathType sInt16Scale = 0x7FFF; constexpr mathType sInt16Scale = 0x7FFF;
constexpr mathType maxAngle = 0x8000; constexpr mathType maxAngle = 0x8000;
constexpr mathType staticRotationScale = 256; constexpr mathType staticRotationScale = 255;
constexpr mathType animatedRotationScale = 1; constexpr mathType animatedRotationScale = 1;
constexpr int16_t (*sinFunction)(uint16_t) = &sin16; constexpr int16_t (*sinFunction)(uint16_t) = &sin16;
constexpr int16_t (*cosFunction)(uint16_t) = &cos16; constexpr int16_t (*cosFunction)(uint16_t) = &cos16;
@ -1949,7 +1949,7 @@ uint16_t mode_palette() {
using wideMathType = float; using wideMathType = float;
using angleType = float; using angleType = float;
constexpr mathType sInt16Scale = 1.0f; constexpr mathType sInt16Scale = 1.0f;
constexpr mathType maxAngle = M_PI / 256.0; constexpr mathType maxAngle = M_PI / 255.0;
constexpr mathType staticRotationScale = 1.0f; constexpr mathType staticRotationScale = 1.0f;
constexpr mathType animatedRotationScale = M_TWOPI / double(0xFFFF); constexpr mathType animatedRotationScale = M_TWOPI / double(0xFFFF);
constexpr float (*sinFunction)(float) = &sin_t; constexpr float (*sinFunction)(float) = &sin_t;
@ -1961,7 +1961,7 @@ uint16_t mode_palette() {
const int inputShift = SEGMENT.speed; const int inputShift = SEGMENT.speed;
const int inputSize = SEGMENT.intensity; const int inputSize = SEGMENT.intensity;
const int inputRotation = SEGMENT.custom1; const int inputRotation = SEGMENT.custom1 + 128;
const bool inputAnimateShift = SEGMENT.check1; const bool inputAnimateShift = SEGMENT.check1;
const bool inputAnimateRotation = SEGMENT.check2; const bool inputAnimateRotation = SEGMENT.check2;
const bool inputAssumeSquare = SEGMENT.check3; const bool inputAssumeSquare = SEGMENT.check3;
@ -2016,7 +2016,7 @@ uint16_t mode_palette() {
colorIndex = ((inputSize - 112) * colorIndex) / 16; colorIndex = ((inputSize - 112) * colorIndex) / 16;
} }
// Finally, shift the palette a bit. // Finally, shift the palette a bit.
const int paletteOffset = (!inputAnimateShift) ? (inputShift-128) : (((strip.now * ((inputShift >> 3) +1)) & 0xFFFF) >> 8); const int paletteOffset = (!inputAnimateShift) ? (inputShift) : (((strip.now * ((inputShift >> 3) +1)) & 0xFFFF) >> 8);
colorIndex += paletteOffset; colorIndex += paletteOffset;
const uint32_t color = SEGMENT.color_wheel((uint8_t)colorIndex); const uint32_t color = SEGMENT.color_wheel((uint8_t)colorIndex);
if (isMatrix) { if (isMatrix) {
@ -2028,7 +2028,7 @@ uint16_t mode_palette() {
} }
return FRAMETIME; return FRAMETIME;
} }
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"; static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Shift,Size,Rotation,,,Animate Shift,Animate Rotation,Anamorphic;;!;12;ix=112,c1=0,o1=1,o2=0,o3=1";
// WLED limitation: Analog Clock overlay will NOT work when Fire2012 is active // WLED limitation: Analog Clock overlay will NOT work when Fire2012 is active