Default palette gamma fix.
Reverted to leds[] in SR effects. Code optimisations.
This commit is contained in:
parent
d328db543e
commit
dde5367560
395
wled00/FX.cpp
395
wled00/FX.cpp
File diff suppressed because it is too large
Load Diff
@ -502,9 +502,9 @@ typedef struct Segment {
|
|||||||
inline bool isSelected(void) { return getOption(0); }
|
inline bool isSelected(void) { return getOption(0); }
|
||||||
inline bool isActive(void) { return stop > start; }
|
inline bool isActive(void) { return stop > start; }
|
||||||
inline bool is2D(void) { return !(startY == 0 && stopY == 1); }
|
inline bool is2D(void) { return !(startY == 0 && stopY == 1); }
|
||||||
inline uint16_t width(void) { return stop - start; }
|
inline uint16_t width(void) { return stop - start; } // segment width in physical pixels (length if 1D)
|
||||||
inline uint16_t height(void) { return stopY - startY; }
|
inline uint16_t height(void) { return stopY - startY; } // segment height (if 2D) in physical pixels
|
||||||
inline uint16_t length(void) { return width(); }
|
inline uint16_t length(void) { return width() * height(); } // segment length (count) in physical pixels
|
||||||
inline uint16_t groupLength(void) { return grouping + spacing; }
|
inline uint16_t groupLength(void) { return grouping + spacing; }
|
||||||
inline uint8_t getLightCapabilities(void) { return _capabilities; }
|
inline uint8_t getLightCapabilities(void) { return _capabilities; }
|
||||||
|
|
||||||
|
@ -114,22 +114,24 @@ void IRAM_ATTR WS2812FX::setPixelColorXY(int x, int y, uint32_t col)
|
|||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
if (!isMatrix) return; // not a matrix set-up
|
if (!isMatrix) return; // not a matrix set-up
|
||||||
uint16_t index = y * matrixWidth + x;
|
uint16_t index = y * matrixWidth + x;
|
||||||
|
#else
|
||||||
|
uint16_t index = x;
|
||||||
|
#endif
|
||||||
if (index >= _length) return;
|
if (index >= _length) return;
|
||||||
if (index < customMappingSize) index = customMappingTable[index];
|
if (index < customMappingSize) index = customMappingTable[index];
|
||||||
busses.setPixelColor(index, col);
|
busses.setPixelColor(index, col);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns RGBW values of pixel
|
// returns RGBW values of pixel
|
||||||
uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
uint16_t index = (y * matrixWidth + x);
|
uint16_t index = (y * matrixWidth + x);
|
||||||
|
#else
|
||||||
|
uint16_t index = x;
|
||||||
|
#endif
|
||||||
if (index >= _length) return 0;
|
if (index >= _length) return 0;
|
||||||
if (index < customMappingSize) index = customMappingTable[index];
|
if (index < customMappingSize) index = customMappingTable[index];
|
||||||
return busses.getPixelColor(index);
|
return busses.getPixelColor(index);
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -143,7 +145,7 @@ uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) {
|
|||||||
uint16_t height = virtualHeight(); // segment height in logical pixels
|
uint16_t height = virtualHeight(); // segment height in logical pixels
|
||||||
return (x%width) + (y%height) * width;
|
return (x%width) + (y%height) * width;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return x;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,6 +753,7 @@ uint32_t IRAM_ATTR Segment::color_from_palette(uint16_t i, bool mapping, bool wr
|
|||||||
// default palette or no RGB support on segment
|
// default palette or no RGB support on segment
|
||||||
if ((palette == 0 && mcol < NUM_COLORS) || !(_capabilities & 0x01)) {
|
if ((palette == 0 && mcol < NUM_COLORS) || !(_capabilities & 0x01)) {
|
||||||
uint32_t color = (transitional && _t) ? _t->_colorT[mcol] : colors[mcol];
|
uint32_t color = (transitional && _t) ? _t->_colorT[mcol] : colors[mcol];
|
||||||
|
color = strip.gammaCorrectCol ? gamma32(color) : color;
|
||||||
if (pbri == 255) return color;
|
if (pbri == 255) return color;
|
||||||
return RGBW32(scale8_video(R(color),pbri), scale8_video(G(color),pbri), scale8_video(B(color),pbri), scale8_video(W(color),pbri));
|
return RGBW32(scale8_video(R(color),pbri), scale8_video(G(color),pbri), scale8_video(B(color),pbri), scale8_video(W(color),pbri));
|
||||||
}
|
}
|
||||||
@ -897,6 +898,39 @@ void WS2812FX::setPixelColor(int i, uint32_t col)
|
|||||||
if (realtimeMode && useMainSegmentOnly) {
|
if (realtimeMode && useMainSegmentOnly) {
|
||||||
Segment &seg = _segments[_mainSegment];
|
Segment &seg = _segments[_mainSegment];
|
||||||
uint16_t len = seg.length(); // length of segment in number of pixels
|
uint16_t len = seg.length(); // length of segment in number of pixels
|
||||||
|
if (i >= seg.virtualLength()) return;
|
||||||
|
|
||||||
|
#ifndef WLED_DISABLE_2D
|
||||||
|
// adjust pixel index if within 2D segment
|
||||||
|
if (isMatrix) {
|
||||||
|
uint16_t vH = seg.virtualHeight(); // segment height in logical pixels
|
||||||
|
uint16_t vW = seg.virtualWidth();
|
||||||
|
switch (seg.map1D2D) {
|
||||||
|
case M12_Pixels:
|
||||||
|
// use all available pixels as a long strip
|
||||||
|
setPixelColorXY(seg.start + i % vW, seg.startY + i / vW, col);
|
||||||
|
break;
|
||||||
|
case M12_VerticalBar:
|
||||||
|
// expand 1D effect vertically
|
||||||
|
for (int y = 0; y < vH; y++) setPixelColorXY(seg.start + i, seg.startY + y, col);
|
||||||
|
break;
|
||||||
|
case M12_Circle:
|
||||||
|
// expand in circular fashion from center
|
||||||
|
for (float degrees = 0.0f; degrees <= 90.0f; degrees += 89.99f / (sqrtf((float)max(vH,vW))*i+1)) { // this may prove too many iterations on larger matrices
|
||||||
|
// may want to try float version as well (with or without antialiasing)
|
||||||
|
int x = roundf(sin_t(degrees*DEG_TO_RAD) * i);
|
||||||
|
int y = roundf(cos_t(degrees*DEG_TO_RAD) * i);
|
||||||
|
setPixelColorXY(seg.start + x, seg.startY + y, col);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case M12_Block:
|
||||||
|
for (int x = 0; x <= i; x++) setPixelColorXY(seg.start + x, seg.startY + i, col);
|
||||||
|
for (int y = 0; y < i; y++) setPixelColorXY(seg.start + i, seg.startY + y, col);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (seg.opacity < 255) {
|
if (seg.opacity < 255) {
|
||||||
byte r = scale8(R(col), seg.opacity);
|
byte r = scale8(R(col), seg.opacity);
|
||||||
|
Loading…
Reference in New Issue
Block a user