Skip to content

Commit 7167db4

Browse files
committed
Polar Lights upgrade
* stop flickering when rows > 56 * blur option added * allow to use palettes
1 parent db1db33 commit 7167db4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

wled00/FX.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5972,17 +5972,19 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
59725972
const uint16_t cols = SEGMENT.virtualWidth();
59735973
const uint16_t rows = SEGMENT.virtualHeight();
59745974
const float maxRows = (rows <= 32) ? 32.0f : (rows <= 64) ? 64.0f : 128.0f; // WLEDMM safe up to 128x128
5975-
const float minScale = (rows <= 32) ? 12.0f : (rows <= 64) ? 4.6f : 2.1f; // WLEDMM
5975+
const float minScale = (rows <= 32) ? 12.0f : (rows <= 64) ? 7.2f : 4.6f; // WLEDMM
5976+
const float maxCols = (cols <= 32) ? 32.0f : (cols <= 64) ? 64.0f : 128.0f; // WLEDMM safe up to 128x128
59765977

59775978
const CRGBPalette16 auroraPalette = {0x000000, 0x003300, 0x006600, 0x009900, 0x00cc00, 0x00ff00, 0x33ff00, 0x66ff00, 0x99ff00, 0xccff00, 0xffff00, 0xffcc00, 0xff9900, 0xff6600, 0xff3300, 0xff0000};
5979+
const CRGBPalette16 &effectPalette = SEGENV.check1 ? SEGPALETTE : auroraPalette;
59785980

59795981
if (SEGENV.call == 0) {
59805982
SEGMENT.setUpLeds();
59815983
SEGMENT.fill(BLACK);
59825984
}
59835985

59845986
float adjustHeight = mapf(rows, 8, maxRows, 28, minScale); // maybe use mapf() ??? // WLEDMM yes!
5985-
uint16_t adjScale = map2(cols, 8, 64, 310, 63);
5987+
uint16_t adjScale = map2(cols, 8, maxCols, 310, 63); // WLEDMM
59865988

59875989
adjustHeight = max(min(adjustHeight, 28.0f), minScale); // WLEDMM bugfix for larger fixtures
59885990
adjScale = max(min(adjScale, uint16_t(310)), uint16_t(63)); // WLEDMM
@@ -6002,11 +6004,11 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
60026004
}
60036005
*/
60046006
uint16_t _scale = map2(SEGMENT.intensity, 0, 255, 30, adjScale);
6005-
byte _speed = map2(SEGMENT.speed, 0, 255, 128, 16);
6007+
byte _speed = map2(SEGMENT.speed, 0, 255, 136, 20);
60066008

60076009
//WLEDMM add SuperSync control
60086010
uint16_t xStart, xEnd, yStart, yEnd;
6009-
if (SEGMENT.check1) { //Master (sync on needs to show the whole effect, children only their first panel)
6011+
if (SEGMENT.check2) { //Master (sync on needs to show the whole effect, children only their first panel)
60106012
xStart = strip.panel[0].xOffset;
60116013
xEnd = strip.panel[0].xOffset + strip.panel[0].width;
60126014
yStart = strip.panel[0].yOffset;
@@ -6024,16 +6026,17 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
60246026
for (int x = xStart; x < xEnd; x++) {
60256027
for (int y = yStart; y < yEnd; y++) {
60266028
SEGENV.step++;
6027-
SEGMENT.setPixelColorXY(x, y, ColorFromPalette(auroraPalette,
6029+
SEGMENT.setPixelColorXY(x, y, ColorFromPalette(effectPalette,
60286030
qsub8(
60296031
inoise8((SEGENV.step%2) + x * _scale, y * 16 + SEGENV.step % 16, SEGENV.step / _speed),
60306032
fabsf(rows_2 - (float)y) * adjustHeight))); // WLEDMM
60316033
}
60326034
}
60336035

6036+
if (SEGENV.check3) SEGMENT.blurRows(192);
60346037
return FRAMETIME;
60356038
} // mode_2DPolarLights()
6036-
static const char _data_FX_MODE_2DPOLARLIGHTS[] PROGMEM = "Polar Lights@!,Scale,,,,SuperSync;;;2";
6039+
static const char _data_FX_MODE_2DPOLARLIGHTS[] PROGMEM = "Polar Lights@!,Scale,,,,Use Palette,SuperSync, Blur;;!;2";
60376040

60386041

60396042
/////////////////////////

0 commit comments

Comments
 (0)