Merge remote-tracking branch 'upstream/main' into mdev

This commit is contained in:
Ewoud
2023-05-11 17:39:12 +02:00
33 changed files with 4706 additions and 3339 deletions

View File

@@ -1247,10 +1247,10 @@ uint16_t mode_rain() {
if (SEGENV.call && SEGENV.step > SPEED_FORMULA_L) {
SEGENV.step = 1;
if (strip.isMatrix) {
uint32_t ctemp[width];
for (int i = 0; i<width; i++) ctemp[i] = SEGMENT.getPixelColorXY(i, height-1);
SEGMENT.move(6,1); // move all pixels down
for (int i = 0; i<width; i++) SEGMENT.setPixelColorXY(i, 0, ctemp[i]); // wrap around
//uint32_t ctemp[width];
//for (int i = 0; i<width; i++) ctemp[i] = SEGMENT.getPixelColorXY(i, height-1);
SEGMENT.move(6, 1, true); // move all pixels down
//for (int i = 0; i<width; i++) SEGMENT.setPixelColorXY(i, 0, ctemp[i]); // wrap around
SEGENV.aux0 = (SEGENV.aux0 % width) + (SEGENV.aux0 / width + 1) * width;
SEGENV.aux1 = (SEGENV.aux1 % width) + (SEGENV.aux1 / width + 1) * width;
} else {
@@ -1978,7 +1978,7 @@ uint16_t mode_fire_2012() {
if (!SEGENV.allocateData(strips * SEGLEN)) return mode_static(); //allocation failed
byte* heat = SEGENV.data;
const uint32_t it = strip.now >> 6; //div 64
const uint32_t it = strip.now >> 5; //div 32
struct virtualStrip {
static void runStrip(uint16_t stripNr, byte* heat, uint32_t it) {
@@ -1987,28 +1987,24 @@ uint16_t mode_fire_2012() {
// Step 1. Cool down every cell a little
for (int i = 0; i < SEGLEN; i++) {
uint8_t cool = (it != SEGENV.step) ? random8((((20 + SEGMENT.speed/3) * 16) / SEGLEN)+2) : random(8);
uint8_t minTemp = 0;
if (i<ignition) {
minTemp = (ignition-i)/4 + 16; // and should not become black
}
uint8_t cool = (it != SEGENV.step) ? random8((((20 + SEGMENT.speed/3) * 16) / SEGLEN)+2) : random(4);
uint8_t minTemp = (i<ignition) ? (ignition-i)/4 + 16 : 0; // should not become black in ignition area
uint8_t temp = qsub8(heat[i], cool);
heat[i] = temp<minTemp ? minTemp : temp;
}
if (it != SEGENV.step)
{
if (it != SEGENV.step) {
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for (int k = SEGLEN -1; k > 1; k--) {
heat[k] = (heat[k - 1] + (heat[k - 2]<<1) ) / 3; // heat[k-2] multiplied by 2
}
}
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
if (random8() <= SEGMENT.intensity) {
uint8_t y = random8(ignition);
uint8_t boost = (32+SEGMENT.custom3*2) * (2*ignition-y) / (2*ignition);
heat[y] = qadd8(heat[y], random8(64+boost,128+boost));
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
if (random8() <= SEGMENT.intensity) {
uint8_t y = random8(ignition);
uint8_t boost = (17+SEGMENT.custom3) * (ignition - y/2) / ignition; // integer math!
heat[y] = qadd8(heat[y], random8(96+2*boost,207+boost));
}
}
// Step 4. Map from heat cells to LED colors
@@ -2028,7 +2024,7 @@ uint16_t mode_fire_2012() {
return FRAMETIME;
}
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate,,,Boost;;!;1.5d;pal=0,sx=120,ix=64,m12=1"; // bars WLEDMM 1.5d, pal = 0
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate,,,Boost;;!;1.5d;sx=64,ix=160,m12=1"; // bars WLEDMM 1.5d,
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
@@ -2765,7 +2761,7 @@ uint16_t mode_spots()
{
return spots_base((255 - SEGMENT.speed) << 8);
}
static const char _data_FX_MODE_SPOTS[] PROGMEM = "Spots@,Width,,,,,Overlay;!,!;!";
static const char _data_FX_MODE_SPOTS[] PROGMEM = "Spots@Spread,Width,,,,,Overlay;!,!;!";
//Intensity slider sets number of "lights", LEDs per light fade in and out
@@ -4111,7 +4107,7 @@ uint16_t mode_dancing_shadows(void)
spotlights[i].type = random8(SPOT_TYPES_COUNT);
}
uint32_t color = SEGMENT.color_from_palette(spotlights[i].colorIdx, false, false, 0);
uint32_t color = SEGMENT.color_from_palette(spotlights[i].colorIdx, false, false, 255);
int start = spotlights[i].position;
if (spotlights[i].width <= 1) {
@@ -5530,22 +5526,30 @@ uint16_t mode_2Dtartan(void) { // By: Elliott Kember https://editor.so
SEGMENT.fill(BLACK);
}
uint8_t hue;
uint8_t hue, bri;
size_t intensity;
int offsetX = beatsin16(3, -360, 360);
int offsetY = beatsin16(2, -360, 360);
int sharpness = SEGMENT.custom3 / 8; // 0-3
for (int x = 0; x < cols; x++) {
for (int y = 0; y < rows; y++) {
hue = x * beatsin16(10, 1, 10) + offsetY;
SEGMENT.setPixelColorXY(x, y, ColorFromPalette(SEGPALETTE, hue, sin8(x * SEGMENT.speed + offsetX) * sin8(x * SEGMENT.speed + offsetX) / 255, LINEARBLEND));
intensity = bri = sin8(x * SEGMENT.speed/2 + offsetX);
for (int i=0; i<sharpness; i++) intensity *= bri;
intensity >>= 8*sharpness;
SEGMENT.setPixelColorXY(x, y, ColorFromPalette(SEGPALETTE, hue, intensity, LINEARBLEND));
hue = y * 3 + offsetX;
SEGMENT.addPixelColorXY(x, y, ColorFromPalette(SEGPALETTE, hue, sin8(y * SEGMENT.intensity + offsetY) * sin8(y * SEGMENT.intensity + offsetY) / 255, LINEARBLEND));
intensity = bri = sin8(y * SEGMENT.intensity/2 + offsetY);
for (int i=0; i<sharpness; i++) intensity *= bri;
intensity >>= 8*sharpness;
SEGMENT.addPixelColorXY(x, y, ColorFromPalette(SEGPALETTE, hue, intensity, LINEARBLEND));
}
}
return FRAMETIME;
} // mode_2DTartan()
static const char _data_FX_MODE_2DTARTAN[] PROGMEM = "Tartan@X scale,Y scale;;!;2";
static const char _data_FX_MODE_2DTARTAN[] PROGMEM = "Tartan@X scale,Y scale,,,Sharpness;;!;2";
/////////////////////////
@@ -7561,7 +7565,7 @@ static const char _data_FX_MODE_2DAKEMI[] PROGMEM = "Akemi@Color speed,Dance;Hea
// Distortion waves - ldirko
// https://editor.soulmatelights.com/gallery/1089-distorsion-waves
// apated for WLD by @blazoncek
// adapted for WLED by @blazoncek
uint16_t mode_2Ddistortionwaves() {
if (!strip.isMatrix) return mode_static(); // not a 2D set-up
@@ -7610,7 +7614,116 @@ uint16_t mode_2Ddistortionwaves() {
return FRAMETIME;
}
static const char _data_FX_MODE_2DDISTORTIONWAVES[] PROGMEM = "Distortion Waves@!,Scale;;;2;";
static const char _data_FX_MODE_2DDISTORTIONWAVES[] PROGMEM = "Distortion Waves@!,Scale;;;2";
//Soap
//@Stepko
//Idea from https://www.youtube.com/watch?v=DiHBgITrZck&ab_channel=StefanPetrick
// adapted for WLED by @blazoncek
uint16_t mode_2Dsoap() {
if (!strip.isMatrix) return mode_static(); // not a 2D set-up
const uint16_t cols = SEGMENT.virtualWidth();
const uint16_t rows = SEGMENT.virtualHeight();
const size_t dataSize = SEGMENT.width() * SEGMENT.height() * sizeof(uint8_t); // prevent reallocation if mirrored or grouped
if (!SEGENV.allocateData(dataSize + sizeof(uint32_t)*3)) return mode_static(); //allocation failed
uint8_t *noise3d = reinterpret_cast<uint8_t*>(SEGENV.data);
uint32_t *noise32_x = reinterpret_cast<uint32_t*>(SEGENV.data + dataSize);
uint32_t *noise32_y = reinterpret_cast<uint32_t*>(SEGENV.data + dataSize + sizeof(uint32_t));
uint32_t *noise32_z = reinterpret_cast<uint32_t*>(SEGENV.data + dataSize + sizeof(uint32_t)*2);
uint32_t scale32_x = 160000U/cols;
uint32_t scale32_y = 160000U/rows;
// init
if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
*noise32_x = random16();
*noise32_y = random16();
*noise32_z = random16();
for (int i = 0; i < cols; i++) {
int32_t ioffset = scale32_x * (i - cols / 2);
for (int j = 0; j < rows; j++) {
int32_t joffset = scale32_y * (j - rows / 2);
uint8_t data = inoise16(*noise32_x + ioffset, *noise32_y + joffset, *noise32_z) >> 8;
noise3d[XY(i,j)] = scale8(noise3d[XY(i,j)], SEGMENT.intensity) + scale8(data, 255 - SEGMENT.intensity);
SEGMENT.setPixelColorXY(i, j, ColorFromPalette(SEGPALETTE,~noise3d[XY(i,j)]*3));
}
}
}
uint32_t mov = MAX(cols,rows)*(SEGMENT.speed+1)/2;
*noise32_x += mov;
*noise32_y += mov;
*noise32_z += mov;
for (int i = 0; i < cols; i++) {
int32_t ioffset = scale32_x * (i - cols / 2);
for (int j = 0; j < rows; j++) {
int32_t joffset = scale32_y * (j - rows / 2);
uint8_t data = inoise16(*noise32_x + ioffset, *noise32_y + joffset, *noise32_z) >> 8;
noise3d[XY(i,j)] = scale8(noise3d[XY(i,j)], SEGMENT.intensity) + scale8(data, 256 - SEGMENT.intensity);
}
}
int zD;
int zF;
int amplitude;
int8_t shiftX = 0; //(SEGMENT.custom1 - 128) / 4;
int8_t shiftY = 0; //(SEGMENT.custom2 - 128) / 4;
amplitude = (cols >= 16) ? (cols-8)/8 : 1;
for (int y = 0; y < rows; y++) {
int amount = ((int)noise3d[XY(0,y)] - 128) * 2 * amplitude + 256*shiftX;
int delta = abs(amount) >> 8;
int fraction = abs(amount) & 255;
for (int x = 0; x < cols; x++) {
if (amount < 0) {
zD = x - delta;
zF = zD - 1;
} else {
zD = x + delta;
zF = zD + 1;
}
CRGB PixelA = CRGB::Black;
if ((zD >= 0) && (zD < cols)) PixelA = SEGMENT.getPixelColorXY(zD, y);
else PixelA = ColorFromPalette(SEGPALETTE, ~noise3d[XY(abs(zD),y)]*3);
CRGB PixelB = CRGB::Black;
if ((zF >= 0) && (zF < cols)) PixelB = SEGMENT.getPixelColorXY(zF, y);
else PixelB = ColorFromPalette(SEGPALETTE, ~noise3d[XY(abs(zF),y)]*3);
CRGB pix = (PixelA.nscale8(ease8InOutApprox(255 - fraction))) + (PixelB.nscale8(ease8InOutApprox(fraction)));
SEGMENT.setPixelColorXY(x, y, pix);
}
}
amplitude = (rows >= 16) ? (rows-8)/8 : 1;
for (int x = 0; x < cols; x++) {
int amount = ((int)noise3d[XY(x,0)] - 128) * 2 * amplitude + 256*shiftY;
int delta = abs(amount) >> 8;
int fraction = abs(amount) & 255;
for (int y = 0; y < rows; y++) {
if (amount < 0) {
zD = y - delta;
zF = zD - 1;
} else {
zD = y + delta;
zF = zD + 1;
}
CRGB PixelA = CRGB::Black;
if ((zD >= 0) && (zD < rows)) PixelA = SEGMENT.getPixelColorXY(x, zD);
else PixelA = ColorFromPalette(SEGPALETTE, ~noise3d[XY(x,abs(zD))]*3);
CRGB PixelB = CRGB::Black;
if ((zF >= 0) && (zF < rows)) PixelB = SEGMENT.getPixelColorXY(x, zF);
else PixelB = ColorFromPalette(SEGPALETTE, ~noise3d[XY(x,abs(zF))]*3);
CRGB pix = (PixelA.nscale8(ease8InOutApprox(255 - fraction))) + (PixelB.nscale8(ease8InOutApprox(fraction)));
SEGMENT.setPixelColorXY(x, y, pix);
}
}
return FRAMETIME;
}
static const char _data_FX_MODE_2DSOAP[] PROGMEM = "Soap@!,Smoothness;;!;2";
#endif // WLED_DISABLE_2D
@@ -7845,6 +7958,7 @@ void WS2812FX::setupEffectData() {
addEffect(FX_MODE_2DSINDOTS, &mode_2DSindots, _data_FX_MODE_2DSINDOTS);
addEffect(FX_MODE_2DDNASPIRAL, &mode_2DDNASpiral, _data_FX_MODE_2DDNASPIRAL);
addEffect(FX_MODE_2DBLACKHOLE, &mode_2DBlackHole, _data_FX_MODE_2DBLACKHOLE);
addEffect(FX_MODE_2DSOAP, &mode_2Dsoap, _data_FX_MODE_2DSOAP);
addEffect(FX_MODE_2DAKEMI, &mode_2DAkemi, _data_FX_MODE_2DAKEMI); // audio
#endif // WLED_DISABLE_2D