Merge branch 'MoonModules:mdev' into mdev

This commit is contained in:
Brandon502
2024-05-24 14:11:35 -04:00
committed by GitHub
4 changed files with 18 additions and 10 deletions

View File

@@ -3696,6 +3696,7 @@ uint16_t mode_drip(void)
if (!SEGENV.allocateData(dataSize * strips)) return mode_static(); //allocation failed
Spark* drops = reinterpret_cast<Spark*>(SEGENV.data);
if (SEGENV.call == 0) SEGMENT.fill(BLACK); // WLEDMM clear LEDs at startup
if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1));
struct virtualStrip {
@@ -3703,9 +3704,9 @@ uint16_t mode_drip(void)
uint8_t numDrops = 1 + (SEGMENT.intensity >> 6); // 255>>6 = 3
float gravity = -0.0005 - (SEGMENT.speed/25000.0); //increased gravity (50000 to 25000)
gravity *= max(1, SEGLEN-1);
int sourcedrop = 12;
float gravity = -0.0005f - (float(SEGMENT.speed)/35000.0f); //increased gravity (50000 to 35000)
gravity *= min(max(1, SEGLEN-1), 255); //WLEDMM speed limit 255
const int sourcedrop = 12;
for (int j=0;j<numDrops;j++) {
if (drops[j].colIndex == 0) { //init
@@ -3724,24 +3725,26 @@ uint16_t mode_drip(void)
drops[j].col += map(SEGMENT.custom1, 0, 255, 1, 6); // swelling
if (random16() <= drops[j].col * SEGMENT.custom1 * SEGMENT.custom1 / 10 / 128) { // random drop
uint32_t fallrate = (drops[j].col * (1 + SEGMENT.custom1 * SEGMENT.custom1)) / 192; // WLEDMM specific
if (random16() <= (fallrate / 10)) { // random drop => 1% ... 20% probalibity
drops[j].colIndex=2; //fall
drops[j].col=255;
}
}
if (drops[j].colIndex > 1) { // falling
if (drops[j].pos > 0) { // fall until end of segment
if (drops[j].pos > 0.01f) { // fall until end of segment
drops[j].pos += drops[j].vel;
if (drops[j].pos < 0) drops[j].pos = 0;
drops[j].vel += gravity; // gravity is negative
for (int i=1;i<7-drops[j].colIndex;i++) { // some minor math so we don't expand bouncing droplets
uint16_t pos = constrain(uint16_t(drops[j].pos) +i, 0, SEGLEN-1); //this is BAD, returns a pos >= SEGLEN occasionally
int intPos = roundf(drops[j].pos) +i; // WLEDMM round it first
uint16_t pos = constrain(intPos, 0, SEGLEN-1); //this is BAD, returns a pos >= SEGLEN occasionally // WLEDMM bad cast to uint16_t removed
SEGMENT.setPixelColor(indexToVStrip(pos, stripNr), color_blend(BLACK,dropColor,drops[j].col/i)); //spread pixel with fade while falling
}
if (drops[j].colIndex > 2) { // during bounce, some water is on the floor
SEGMENT.setPixelColor(indexToVStrip(0, stripNr), color_blend(dropColor,BLACK,drops[j].col));
SEGMENT.setPixelColor(indexToVStrip(0, stripNr), color_blend(dropColor,BLACK, (2 * drops[j].col)/3)); // WLEDMM reduced brightness
}
} else { // we hit bottom
if (drops[j].colIndex > 2) { // already hit once, so back to forming
@@ -3768,7 +3771,7 @@ uint16_t mode_drip(void)
return FRAMETIME;
}
static const char _data_FX_MODE_DRIP[] PROGMEM = "Drip@Gravity,# of drips,,,,,Overlay;!,!;!;1.5d;m12=1"; //bar WLEDMM 1.5d
static const char _data_FX_MODE_DRIP[] PROGMEM = "Drip@Gravity,# of drips,Fall ratio,,,,Overlay;!,!;!;1.5d;c1=127,m12=1"; //bar WLEDMM 1.5d
/*