Skip to content

Commit 8a9fa6b

Browse files
committed
Fix for 1D & remove segment ID
1 parent b97186c commit 8a9fa6b

File tree

1 file changed

+26
-42
lines changed

1 file changed

+26
-42
lines changed

wled00/FX.cpp

+26-42
Original file line numberDiff line numberDiff line change
@@ -1933,62 +1933,49 @@ uint16_t mode_palette() {
19331933
using mathType = int32_t;
19341934
using wideMathType = int64_t;
19351935
using angleType = uint16_t;
1936-
constexpr mathType sInt16Scale = 0x7FFF;
1937-
constexpr mathType maxAngle = 0xFFFF;
1938-
constexpr mathType staticRotationScale = 256;
1939-
constexpr mathType animatedRotationScale = 1;
1936+
constexpr mathType sInt16Scale = 0x7FFF;
1937+
constexpr mathType maxAngle = 0xFFFF;
1938+
constexpr mathType staticRotationScale = 256;
1939+
constexpr mathType animatedRotationScale = 1;
19401940
constexpr int16_t (*sinFunction)(uint16_t) = &sin16;
19411941
constexpr int16_t (*cosFunction)(uint16_t) = &cos16;
19421942
#else
19431943
using mathType = float;
19441944
using wideMathType = float;
19451945
using angleType = float;
1946-
constexpr mathType sInt16Scale = 1.0f;
1947-
constexpr mathType maxAngle = M_TWOPI / 256.0;
1948-
constexpr mathType staticRotationScale = 1.0f;
1946+
constexpr mathType sInt16Scale = 1.0f;
1947+
constexpr mathType maxAngle = M_TWOPI / 256.0;
1948+
constexpr mathType staticRotationScale = 1.0f;
19491949
constexpr mathType animatedRotationScale = M_TWOPI / double(0xFFFF);
1950-
constexpr float (*sinFunction)(float) = &sin_t;
1951-
constexpr float (*cosFunction)(float) = &cos_t;
1950+
constexpr float (*sinFunction)(float) = &sin_t;
1951+
constexpr float (*cosFunction)(float) = &cos_t;
19521952
#endif
1953-
const bool isMatrix = strip.isMatrix;
1954-
const int cols = SEGMENT.virtualWidth();
1955-
const int rows = isMatrix ? SEGMENT.virtualHeight() : strip.getSegmentsNum();
1956-
1957-
const int inputShift = SEGMENT.speed;
1958-
const int inputSize = SEGMENT.intensity;
1959-
const int inputRotation = SEGMENT.custom1;
1960-
const bool inputAnimateShift = SEGMENT.check1;
1953+
const unsigned cols = SEGMENT.is2D() ? SEGMENT.virtualWidth() : 1;
1954+
const unsigned rows = SEGMENT.is2D() ? SEGMENT.virtualHeight() : SEGMENT.virtualLength();
1955+
1956+
const int inputShift = SEGMENT.speed;
1957+
const int inputSize = SEGMENT.intensity;
1958+
const int inputRotation = SEGMENT.custom1;
1959+
const bool inputAnimateShift = SEGMENT.check1;
19611960
const bool inputAnimateRotation = SEGMENT.check2;
1962-
const bool inputAssumeSquare = SEGMENT.check3;
1961+
const bool inputAssumeSquare = SEGMENT.check3;
19631962

19641963
const int paletteOffset = (!inputAnimateShift) ? (inputShift) : (((strip.now * ((inputShift >> 3) +1)) & 0xFFFF) >> 8);
19651964

1966-
mathType sinTheta;
1967-
mathType cosTheta;
1968-
if (rows <= 1) {
1969-
sinTheta = 0;
1970-
cosTheta = sInt16Scale;
1971-
} else if (cols <= 1) {
1972-
sinTheta = sInt16Scale;
1973-
cosTheta = 0;
1974-
} else {
1975-
const angleType theta = (!inputAnimateRotation) ? (inputRotation * maxAngle / staticRotationScale) : (((strip.now * ((inputRotation >> 4) +1)) & 0xFFFF) * animatedRotationScale);
1976-
sinTheta = sinFunction(theta);
1977-
cosTheta = cosFunction(theta);
1978-
}
1965+
const angleType theta = (!inputAnimateRotation) ? (inputRotation * maxAngle / staticRotationScale) : (((strip.now * ((inputRotation >> 4) +1)) & 0xFFFF) * animatedRotationScale);
1966+
const mathType sinTheta = sinFunction(theta);
1967+
const mathType cosTheta = cosFunction(theta);
19791968

1980-
const mathType maxX = std::max(1, cols-1);
1981-
const mathType maxY = std::max(1, rows-1);
1969+
const mathType maxX = cols;
1970+
const mathType maxY = rows;
19821971
const mathType maxXIn = inputAssumeSquare ? maxX : mathType(1);
19831972
const mathType maxYIn = inputAssumeSquare ? maxY : mathType(1);
19841973
const mathType maxXOut = !inputAssumeSquare ? maxX : mathType(1);
19851974
const mathType maxYOut = !inputAssumeSquare ? maxY : mathType(1);
19861975
const mathType centerX = sInt16Scale * maxXOut / mathType(2);
19871976
const mathType centerY = sInt16Scale * maxYOut / mathType(2);
19881977
const mathType scale = std::abs(cosTheta) + (std::abs(sinTheta) * maxYOut / maxXOut);
1989-
const int yFrom = isMatrix ? 0 : strip.getCurrSegmentId();
1990-
const int yTo = isMatrix ? maxY : yFrom;
1991-
for (int y = yFrom; y <= yTo; ++y) {
1978+
for (int y = 0; y < rows; ++y) {
19921979
const mathType ytSinTheta = mathType((wideMathType(sinTheta) * wideMathType(y * sInt16Scale - centerY * maxYIn))/wideMathType(maxYIn * scale));
19931980
for (int x = 0; x < cols; ++x) {
19941981
const mathType xtCosTheta = mathType((wideMathType(cosTheta) * wideMathType(x * sInt16Scale - centerX * maxXIn))/wideMathType(maxXIn * scale));
@@ -2002,16 +1989,13 @@ uint16_t mode_palette() {
20021989
}
20031990
colorIndex += paletteOffset;
20041991
const uint32_t color = SEGMENT.color_wheel((uint8_t)colorIndex);
2005-
if (isMatrix) {
2006-
SEGMENT.setPixelColorXY(x, y, color);
2007-
} else {
2008-
SEGMENT.setPixelColor(x, color);
2009-
}
1992+
if (SEGMENT.is2D()) SEGMENT.setPixelColorXY(x, y, color);
1993+
else SEGMENT.setPixelColor(y, color);
20101994
}
20111995
}
20121996
return FRAMETIME;
20131997
}
2014-
static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Shift,Size,Rotation,,,Animate Shift,Animate Rotation,Physical Square;;!;12;o1=1,o2=1";
1998+
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";
20151999

20162000

20172001
// WLED limitation: Analog Clock overlay will NOT work when Fire2012 is active

0 commit comments

Comments
 (0)