mirror of
https://github.com/wled/WLED.git
synced 2025-04-24 23:07:19 +00:00
Polar Lights fix.
Cleanup.
This commit is contained in:
parent
17be0a2c12
commit
9920424a31
@ -5192,20 +5192,21 @@ uint16_t WS2812FX::mode_2DPolarLights(void) { // By: Kostyantyn Matviyevs
|
|||||||
uint16_t height = SEGMENT.virtualHeight();
|
uint16_t height = SEGMENT.virtualHeight();
|
||||||
uint16_t dataSize = sizeof(CRGB) * width * height;
|
uint16_t dataSize = sizeof(CRGB) * width * height;
|
||||||
|
|
||||||
if (!SEGENV.allocateData(dataSize + sizeof(unsigned long))) return mode_static(); //allocation failed
|
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||||
CRGB *leds = reinterpret_cast<CRGB*>(SEGENV.data);
|
CRGB *leds = reinterpret_cast<CRGB*>(SEGENV.data);
|
||||||
unsigned long *timer = reinterpret_cast<unsigned long*>(SEGENV.data + dataSize);
|
|
||||||
|
CRGBPalette16 auroraPalette = {0x000000, 0x003300, 0x006600, 0x009900, 0x00cc00, 0x00ff00, 0x33ff00, 0x66ff00, 0x99ff00, 0xccff00, 0xffff00, 0xffcc00, 0xff9900, 0xff6600, 0xff3300, 0xff0000};
|
||||||
|
|
||||||
if (SEGENV.call == 0) {
|
if (SEGENV.call == 0) {
|
||||||
*timer = 0;
|
SEGENV.step = 0;
|
||||||
fill_solid(leds, CRGB::Black);
|
fill_solid(leds, CRGB::Black);
|
||||||
}
|
}
|
||||||
|
|
||||||
float adjustHeight = fmap(height, 8, 32, 28, 12);
|
float adjustHeight = (float)map(height, 8, 32, 28, 12);
|
||||||
uint16_t adjScale = map(width, 8, 64, 310, 63);
|
uint16_t adjScale = map(width, 8, 64, 310, 63);
|
||||||
|
/*
|
||||||
if (SEGENV.aux1 != SEGMENT.custom1/12) { // Hacky palette rotation. We need that black.
|
if (SEGENV.aux1 != SEGMENT.custom1/12) { // Hacky palette rotation. We need that black.
|
||||||
SEGENV.aux1 = SEGMENT.custom1;
|
SEGENV.aux1 = SEGMENT.custom1/12;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
long ilk;
|
long ilk;
|
||||||
ilk = (long)currentPalette[i].r << 16;
|
ilk = (long)currentPalette[i].r << 16;
|
||||||
@ -5217,16 +5218,16 @@ uint16_t WS2812FX::mode_2DPolarLights(void) { // By: Kostyantyn Matviyevs
|
|||||||
currentPalette[i].b = ilk;
|
currentPalette[i].b = ilk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
uint16_t _scale = map(SEGMENT.intensity, 1, 255, 30, adjScale);
|
uint16_t _scale = map(SEGMENT.intensity, 0, 255, 30, adjScale);
|
||||||
byte _speed = map(SEGMENT.speed, 1, 255, 128, 16);
|
byte _speed = map(SEGMENT.speed, 0, 255, 128, 16);
|
||||||
|
|
||||||
for (uint16_t x = 0; x < width; x++) {
|
for (uint16_t x = 0; x < width; x++) {
|
||||||
for (uint16_t y = 0; y < height; y++) {
|
for (uint16_t y = 0; y < height; y++) {
|
||||||
(*timer)++;
|
SEGENV.step++;
|
||||||
leds[XY(x, y)] = ColorFromPalette(currentPalette,
|
leds[XY(x, y)] = ColorFromPalette(auroraPalette,
|
||||||
qsub8(
|
qsub8(
|
||||||
inoise8(SEGENV.aux0 % 2 + x * _scale, y * 16 + *timer % 16, *timer / _speed),
|
inoise8((SEGENV.step%2) + x * _scale, y * 16 + SEGENV.step % 16, SEGENV.step / _speed),
|
||||||
fabs((float)height / 2 - (float)y) * adjustHeight));
|
fabs((float)height / 2 - (float)y) * adjustHeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5234,7 +5235,7 @@ uint16_t WS2812FX::mode_2DPolarLights(void) { // By: Kostyantyn Matviyevs
|
|||||||
setPixels(leds);
|
setPixels(leds);
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
} // mode_2DPolarLights()
|
} // mode_2DPolarLights()
|
||||||
static const char *_data_FX_MODE_POLAR_LIGHTS PROGMEM = "2D Polar Lights@Speed,X scale,Palette;!,!,!;!";
|
static const char *_data_FX_MODE_POLAR_LIGHTS PROGMEM = "2D Polar Lights@Speed,Scale;;";
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
157
wled00/FX.h
157
wled00/FX.h
@ -1068,161 +1068,4 @@ class WS2812FX {
|
|||||||
extern const char JSON_mode_names[];
|
extern const char JSON_mode_names[];
|
||||||
extern const char JSON_palette_names[];
|
extern const char JSON_palette_names[];
|
||||||
|
|
||||||
// the following has been moved to FX_fcn.cpp instead
|
|
||||||
/*
|
|
||||||
// WLEDSR: extensions
|
|
||||||
// Technical notes
|
|
||||||
// ===============
|
|
||||||
// If an effect name is followed by an @, slider and color control is effective.
|
|
||||||
// See setSliderAndColorControl in index.js for implementation
|
|
||||||
// If not effective then:
|
|
||||||
// - For AC effects (id<128) 2 sliders and 3 colors and the palette will be shown
|
|
||||||
// - For SR effects (id>128) 5 sliders and 3 colors and the palette will be shown
|
|
||||||
// If effective (@)
|
|
||||||
// - a ; seperates slider controls (left) from color controls (middle) and palette control (right)
|
|
||||||
// - if left, middle or right is empty no controls are shown
|
|
||||||
// - a , seperates slider controls (max 5) or color controls (max 3). Palette has only one value
|
|
||||||
// - a ! means that the default is used.
|
|
||||||
// - For sliders: Effect speeds, Effect intensity, Custom 1, Custom 2, Custom 3
|
|
||||||
// - For colors: Fx color, Background color, Custom
|
|
||||||
// - For palette: prompt for color palette OR palette ID if numeric (will hide palette selection)
|
|
||||||
//
|
|
||||||
// Note: If palette is on and no colors are specified 1,2 and 3 is shown in each color circle.
|
|
||||||
// If a color is specified, the 1,2 or 3 is replaced by that specification.
|
|
||||||
// Note: Effects can override default pattern behaviour
|
|
||||||
// - FadeToBlack can override the background setting
|
|
||||||
// - Defining SEGCOL(<i>) can override a specific palette using these values (e.g. Color Gradient)
|
|
||||||
const char JSON_mode_names[] PROGMEM = R"=====([
|
|
||||||
"Solid",
|
|
||||||
"Blink@!,;!,!,;!",
|
|
||||||
"Breathe@!,;!,!;!",
|
|
||||||
"Wipe@!,!;!,!,;!",
|
|
||||||
"Wipe Random@!,;;!",
|
|
||||||
"Random Colors@!,Fade time;;!",
|
|
||||||
"Sweep@!,!;!,!,;!",
|
|
||||||
"Dynamic",
|
|
||||||
"Colorloop@!,Saturation;;!",
|
|
||||||
"Rainbow",
|
|
||||||
"Scan@!,# of dots;!,!,;!",
|
|
||||||
"Scan Dual@!,# of dots;!,!,;!",
|
|
||||||
"Fade",
|
|
||||||
"Theater@!,Gap size;!,!,;!",
|
|
||||||
"Theater Rainbow",
|
|
||||||
"Running@!,Wave width;!,!,;!",
|
|
||||||
"Saw@!,Width;!,!,;!",
|
|
||||||
"Twinkle",
|
|
||||||
"Dissolve",
|
|
||||||
"Dissolve Rnd",
|
|
||||||
"Sparkle",
|
|
||||||
"Sparkle Dark",
|
|
||||||
"Sparkle+",
|
|
||||||
"Strobe",
|
|
||||||
"Strobe Rainbow",
|
|
||||||
"Strobe Mega",
|
|
||||||
"Blink Rainbow",
|
|
||||||
"Android",
|
|
||||||
"Chase",
|
|
||||||
"Chase Random",
|
|
||||||
"Chase Rainbow",
|
|
||||||
"Chase Flash",
|
|
||||||
"Chase Flash Rnd",
|
|
||||||
"Rainbow Runner",
|
|
||||||
"Colorful",
|
|
||||||
"Traffic Light",
|
|
||||||
"Sweep Random",
|
|
||||||
"Chase 2@!,Width;!,!,;!",
|
|
||||||
"Aurora",
|
|
||||||
"Stream",
|
|
||||||
"Scanner",
|
|
||||||
"Lighthouse",
|
|
||||||
"Fireworks",
|
|
||||||
"Rain",
|
|
||||||
"Tetrix@!,Width;!,!,;!",
|
|
||||||
"Fire Flicker",
|
|
||||||
"Gradient",
|
|
||||||
"Loading",
|
|
||||||
"Police@!,Width;;0",
|
|
||||||
"Fairy",
|
|
||||||
"Two Dots@!,Dot size;1,2,Bg;!",
|
|
||||||
"Fairy Twinkle",
|
|
||||||
"Running Dual",
|
|
||||||
"Halloween",
|
|
||||||
"Chase 3@!,Size;1,2,3;0",
|
|
||||||
"Tri Wipe@!,Width;1,2,3;0",
|
|
||||||
"Tri Fade",
|
|
||||||
"Lightning",
|
|
||||||
"ICU",
|
|
||||||
"Multi Comet",
|
|
||||||
"Scanner Dual",
|
|
||||||
"Stream 2",
|
|
||||||
"Oscillate",
|
|
||||||
"Pride 2015",
|
|
||||||
"Juggle@!=16,Trail=240;!,!,;!",
|
|
||||||
"Palette@!,;;!",
|
|
||||||
"Fire 2012@Spark rate=120,Decay=64;;!",
|
|
||||||
"Colorwaves",
|
|
||||||
"Bpm",
|
|
||||||
"Fill Noise",
|
|
||||||
"Noise 1",
|
|
||||||
"Noise 2",
|
|
||||||
"Noise 3",
|
|
||||||
"Noise 4",
|
|
||||||
"Colortwinkles",
|
|
||||||
"Lake",
|
|
||||||
"Meteor@!,Trail length;!,!,;!",
|
|
||||||
"Meteor Smooth@!,Trail length;!,!,;!",
|
|
||||||
"Railway",
|
|
||||||
"Ripple",
|
|
||||||
"Twinklefox",
|
|
||||||
"Twinklecat",
|
|
||||||
"Halloween Eyes",
|
|
||||||
"Solid Pattern@Fg size,Bg size;Fg,Bg,;0",
|
|
||||||
"Solid Pattern Tri@,Size;1,2,3;0",
|
|
||||||
"Spots@Spread,Width;!,!,;!",
|
|
||||||
"Spots Fade@Spread,Width;!,!,;!",
|
|
||||||
"Glitter",
|
|
||||||
"Candle@Flicker rate=96,Flicker intensity=224;!,!,;0",
|
|
||||||
"Fireworks Starburst",
|
|
||||||
"Fireworks 1D@Gravity,Firing side;!,!,;!",
|
|
||||||
"Bouncing Balls@Gravity,# of balls;!,!,;!",
|
|
||||||
"Sinelon",
|
|
||||||
"Sinelon Dual",
|
|
||||||
"Sinelon Rainbow",
|
|
||||||
"Popcorn@",
|
|
||||||
"Drip@Gravity,# of drips;!,!;!",
|
|
||||||
"Plasma@Phase,;1,2,3;!",
|
|
||||||
"Percent@,% of fill;!,!,;!",
|
|
||||||
"Ripple Rainbow",
|
|
||||||
"Heartbeat",
|
|
||||||
"Pacifica",
|
|
||||||
"Candle Multi@Flicker rate=96,Flicker intensity=224;!,!,;0",
|
|
||||||
"Solid Glitter@,!;!,,;0",
|
|
||||||
"Sunrise@Time [min]=60,;;0",
|
|
||||||
"Phased",
|
|
||||||
"Twinkleup@!,Intensity;!,!,;!",
|
|
||||||
"Noise Pal",
|
|
||||||
"Sine",
|
|
||||||
"Phased Noise",
|
|
||||||
"Flow",
|
|
||||||
"Chunchun@!,Gap size;!,!,;!",
|
|
||||||
"Dancing Shadows",
|
|
||||||
"Washing Machine",
|
|
||||||
"Candy Cane",
|
|
||||||
"Blends",
|
|
||||||
"TV Simulator",
|
|
||||||
"Dynamic Smooth"
|
|
||||||
])=====";
|
|
||||||
|
|
||||||
|
|
||||||
const char JSON_palette_names[] PROGMEM = R"=====([
|
|
||||||
"Default","* Random Cycle","* Color 1","* Colors 1&2","* Color Gradient","* Colors Only","Party","Cloud","Lava","Ocean",
|
|
||||||
"Forest","Rainbow","Rainbow Bands","Sunset","Rivendell","Breeze","Red & Blue","Yellowout","Analogous","Splash",
|
|
||||||
"Pastel","Sunset 2","Beech","Vintage","Departure","Landscape","Beach","Sherbet","Hult","Hult 64",
|
|
||||||
"Drywet","Jul","Grintage","Rewhi","Tertiary","Fire","Icefire","Cyane","Light Pink","Autumn",
|
|
||||||
"Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura",
|
|
||||||
"Aurora","Atlantica","C9 2","C9 New","Temperature","Aurora 2","Retro Clown","Candy","Toxy Reaf","Fairy Reaf",
|
|
||||||
"Semi Blue","Pink Candy","Red Reaf","Aqua Flash","Yelblu Hot","Lite Light","Red Flash","Blink Red","Red Shift","Red Tide",
|
|
||||||
"Candy2"
|
|
||||||
])=====";
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1313,7 +1313,7 @@ uint8_t Bus::_gAWM = 255;
|
|||||||
// Note: Effects can override default pattern behaviour
|
// Note: Effects can override default pattern behaviour
|
||||||
// - FadeToBlack can override the background setting
|
// - FadeToBlack can override the background setting
|
||||||
// - Defining SEGCOL(<i>) can override a specific palette using these values (e.g. Color Gradient)
|
// - Defining SEGCOL(<i>) can override a specific palette using these values (e.g. Color Gradient)
|
||||||
const char JSON_mode_names[] PROGMEM = R"=====(["Modenames have moved"])=====";
|
const char JSON_mode_names[] PROGMEM = R"=====(["Mode names have moved"])=====";
|
||||||
/*
|
/*
|
||||||
R"=====([
|
R"=====([
|
||||||
"Solid",
|
"Solid",
|
||||||
|
@ -824,8 +824,6 @@ void serializeNodes(JsonObject root)
|
|||||||
void serializeModeData(JsonArray fxdata)
|
void serializeModeData(JsonArray fxdata)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < MODE_COUNT; i++) {
|
for (size_t i = 0; i < MODE_COUNT; i++) {
|
||||||
//char buffer[256];
|
|
||||||
//strcpy_P(buffer, (const char*)pgm_read_dword(&(WS2812FX::_modeData[i])));
|
|
||||||
//String lineBuffer = (const char*)pgm_read_dword(&(WS2812FX::_modeData[i]));
|
//String lineBuffer = (const char*)pgm_read_dword(&(WS2812FX::_modeData[i]));
|
||||||
String lineBuffer = WS2812FX::_modeData[i];
|
String lineBuffer = WS2812FX::_modeData[i];
|
||||||
if (lineBuffer.length() > 0) {
|
if (lineBuffer.length() > 0) {
|
||||||
@ -834,46 +832,11 @@ void serializeModeData(JsonArray fxdata)
|
|||||||
else fxdata.add("");
|
else fxdata.add("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
//JsonArray fxdata = root.createNestedArray("fxdata");
|
|
||||||
String lineBuffer;
|
|
||||||
bool insideQuotes = false;
|
|
||||||
char singleJsonSymbol;
|
|
||||||
size_t len = strlen_P(JSON_mode_names);
|
|
||||||
|
|
||||||
// Find the mode name in JSON
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
|
||||||
singleJsonSymbol = pgm_read_byte_near(JSON_mode_names + i);
|
|
||||||
if (singleJsonSymbol == '\0') break;
|
|
||||||
switch (singleJsonSymbol) {
|
|
||||||
case '"':
|
|
||||||
insideQuotes = !insideQuotes;
|
|
||||||
break;
|
|
||||||
case '[':
|
|
||||||
if (insideQuotes) lineBuffer += singleJsonSymbol;
|
|
||||||
break;
|
|
||||||
case ']':
|
|
||||||
if (insideQuotes) {lineBuffer += singleJsonSymbol; break;}
|
|
||||||
case ',':
|
|
||||||
if (insideQuotes) {lineBuffer += singleJsonSymbol; break;}
|
|
||||||
if (lineBuffer.length() > 0) {
|
|
||||||
uint8_t endPos = lineBuffer.indexOf('@');
|
|
||||||
if (endPos>0) fxdata.add(lineBuffer.substring(endPos));
|
|
||||||
else fxdata.add("");
|
|
||||||
lineBuffer.clear();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (!insideQuotes) break;
|
|
||||||
lineBuffer += singleJsonSymbol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// deserializes mode names string into JsonArray
|
// deserializes mode names string into JsonArray
|
||||||
// also removes WLED-SR extensions (@...) from deserialised names
|
// also removes WLED-SR extensions (@...) from deserialised names
|
||||||
void serializeModeNames(JsonArray arr, const char *qstring) {
|
void serializeModeNames(JsonArray arr) {
|
||||||
for (size_t i = 0; i < MODE_COUNT; i++) {
|
for (size_t i = 0; i < MODE_COUNT; i++) {
|
||||||
//String lineBuffer = (const char*)pgm_read_dword(&(WS2812FX::_modeData[i]));
|
//String lineBuffer = (const char*)pgm_read_dword(&(WS2812FX::_modeData[i]));
|
||||||
String lineBuffer = WS2812FX::_modeData[i];
|
String lineBuffer = WS2812FX::_modeData[i];
|
||||||
@ -883,38 +846,6 @@ void serializeModeNames(JsonArray arr, const char *qstring) {
|
|||||||
else arr.add(lineBuffer);
|
else arr.add(lineBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
String lineBuffer;
|
|
||||||
bool insideQuotes = false;
|
|
||||||
char singleJsonSymbol;
|
|
||||||
size_t len = strlen_P(qstring);
|
|
||||||
|
|
||||||
// Find the mode name in JSON
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
|
||||||
singleJsonSymbol = pgm_read_byte_near(qstring + i);
|
|
||||||
if (singleJsonSymbol == '\0') break;
|
|
||||||
switch (singleJsonSymbol) {
|
|
||||||
case '"':
|
|
||||||
insideQuotes = !insideQuotes;
|
|
||||||
break;
|
|
||||||
case '[':
|
|
||||||
break;
|
|
||||||
case ']':
|
|
||||||
case ',':
|
|
||||||
if (insideQuotes) break;
|
|
||||||
if (lineBuffer.length() > 0) {
|
|
||||||
uint8_t endPos = lineBuffer.indexOf('@');
|
|
||||||
if (endPos>0) arr.add(lineBuffer.substring(0,endPos));
|
|
||||||
else arr.add(lineBuffer);
|
|
||||||
lineBuffer.clear();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (!insideQuotes) break;
|
|
||||||
lineBuffer += singleJsonSymbol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void serveJson(AsyncWebServerRequest* request)
|
void serveJson(AsyncWebServerRequest* request)
|
||||||
@ -938,7 +869,7 @@ void serveJson(AsyncWebServerRequest* request)
|
|||||||
if (requestJSONBufferLock(19)) {
|
if (requestJSONBufferLock(19)) {
|
||||||
AsyncJsonResponse* response = new AsyncJsonResponse(&doc, true); // array document
|
AsyncJsonResponse* response = new AsyncJsonResponse(&doc, true); // array document
|
||||||
JsonArray lDoc = response->getRoot();
|
JsonArray lDoc = response->getRoot();
|
||||||
serializeModeNames(lDoc, JSON_mode_names); // remove WLED-SR extensions from effect names
|
serializeModeNames(lDoc); // remove WLED-SR extensions from effect names
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
releaseJSONBufferLock();
|
releaseJSONBufferLock();
|
||||||
@ -985,7 +916,7 @@ void serveJson(AsyncWebServerRequest* request)
|
|||||||
{
|
{
|
||||||
//lDoc[F("effects")] = serialized((const __FlashStringHelper*)JSON_mode_names);
|
//lDoc[F("effects")] = serialized((const __FlashStringHelper*)JSON_mode_names);
|
||||||
JsonArray effects = lDoc.createNestedArray(F("effects"));
|
JsonArray effects = lDoc.createNestedArray(F("effects"));
|
||||||
serializeModeNames(effects, JSON_mode_names); // remove WLED-SR extensions from effect names
|
serializeModeNames(effects); // remove WLED-SR extensions from effect names
|
||||||
lDoc[F("palettes")] = serialized((const __FlashStringHelper*)JSON_palette_names);
|
lDoc[F("palettes")] = serialized((const __FlashStringHelper*)JSON_palette_names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user