@@ -1933,62 +1933,49 @@ uint16_t mode_palette() {
1933
1933
using mathType = int32_t ;
1934
1934
using wideMathType = int64_t ;
1935
1935
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 ;
1940
1940
constexpr int16_t (*sinFunction)(uint16_t ) = &sin16;
1941
1941
constexpr int16_t (*cosFunction)(uint16_t ) = &cos16;
1942
1942
#else
1943
1943
using mathType = float ;
1944
1944
using wideMathType = float ;
1945
1945
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 ;
1949
1949
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 ;
1952
1952
#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 ;
1961
1960
const bool inputAnimateRotation = SEGMENT.check2 ;
1962
- const bool inputAssumeSquare = SEGMENT.check3 ;
1961
+ const bool inputAssumeSquare = SEGMENT.check3 ;
1963
1962
1964
1963
const int paletteOffset = (!inputAnimateShift) ? (inputShift) : (((strip.now * ((inputShift >> 3 ) +1 )) & 0xFFFF ) >> 8 );
1965
1964
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);
1979
1968
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;
1982
1971
const mathType maxXIn = inputAssumeSquare ? maxX : mathType (1 );
1983
1972
const mathType maxYIn = inputAssumeSquare ? maxY : mathType (1 );
1984
1973
const mathType maxXOut = !inputAssumeSquare ? maxX : mathType (1 );
1985
1974
const mathType maxYOut = !inputAssumeSquare ? maxY : mathType (1 );
1986
1975
const mathType centerX = sInt16Scale * maxXOut / mathType (2 );
1987
1976
const mathType centerY = sInt16Scale * maxYOut / mathType (2 );
1988
1977
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) {
1992
1979
const mathType ytSinTheta = mathType ((wideMathType (sinTheta) * wideMathType (y * sInt16Scale - centerY * maxYIn))/wideMathType (maxYIn * scale));
1993
1980
for (int x = 0 ; x < cols; ++x) {
1994
1981
const mathType xtCosTheta = mathType ((wideMathType (cosTheta) * wideMathType (x * sInt16Scale - centerX * maxXIn))/wideMathType (maxXIn * scale));
@@ -2002,16 +1989,13 @@ uint16_t mode_palette() {
2002
1989
}
2003
1990
colorIndex += paletteOffset;
2004
1991
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);
2010
1994
}
2011
1995
}
2012
1996
return FRAMETIME;
2013
1997
}
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 " ;
2015
1999
2016
2000
2017
2001
// WLED limitation: Analog Clock overlay will NOT work when Fire2012 is active
0 commit comments