Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,40 +545,45 @@ uint16_t mode_rainbow_cycle(void) {
static const char _data_FX_MODE_RAINBOW_CYCLE[] PROGMEM = "Rainbow@!,Size;;!";

/*
* Cycles a rainbow over the entire string of LEDs, with a white flash that goes across it.
* adds a predictable white flash across the segment
*/
uint16_t mode_shimmer() {

uint32_t shimmerSpeed = 100 + (255 - SEGMENT.speed) * 40; // [100,10260ms]
uint32_t shimmerSize = (SEGMENT.custom1 * SEGLEN >> 9) + 1; // [1,SEGLEN/2+1]
uint32_t cycleTime = (255 - SEGMENT.intensity) * 150 + shimmerSpeed; // [100, 48510]

uint32_t segmentSize;
//gaurd against buffer overflow, should never exceed this based
//on 1000 pixles per GPIO and 10 strips
if(SEGLEN>10000) {
segmentSize = 10000;
} else {
segmentSize=SEGLEN;
}

uint32_t shimmerSpeed = 100 + (255 - SEGMENT.speed) * 40; // [100,10300]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you change 100 to 200 in this line, no overflow and you do not have to limit the length.

uint32_t shimmerSize = (SEGMENT.custom1 * segmentSize >> 9) + 1; // [1,(SEGLEN/2)+1] capped at 5001.
uint32_t cycleTime = (255 - SEGMENT.intensity) * 150 + shimmerSpeed; // [100, 48550]
uint32_t percCycle = strip.now % cycleTime;
uint64_t shimmerIndex = ((uint64_t)percCycle<<8) / shimmerSpeed * (SEGLEN + 2*shimmerSize);
int32_t shimmerIndex = (percCycle<<8) / shimmerSpeed * (segmentSize + 2*shimmerSize); // maxamum >124285

shimmerIndex -= shimmerSize << 8;

//change direction unless reverse is checked
if(!SEGMENT.check1) {
shimmerIndex = (((uint64_t) SEGLEN) << 8) - shimmerIndex;
shimmerIndex = ((segmentSize) << 8) - shimmerIndex;
}

for (unsigned i = 0; i < SEGLEN; i++) {
//shimmer logic
uint64_t distFromShimmerCenter = abs((int32_t)shimmerIndex - ((int64_t)i << 8));

// Only process pixels that are within the shimmer's range.
for (uint32_t i = 0; i < segmentSize; i++) {

// slightly dangerous, but shimmer index is bounded to be safe
uint32_t distFromShimmerCenter = abs((int32_t)shimmerIndex - ((int32_t)i << 8));
if (distFromShimmerCenter < (shimmerSize<<8)) {
SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGCOLOR(0), 255-(distFromShimmerCenter / shimmerSize)));
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(255-(distFromShimmerCenter / shimmerSize),false,PALETTE_SOLID_WRAP,0));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you forgot the blend

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I didn't. It is up to the user to select a color palette that blends (or contrasts if desired) with the selected background color. Any additional blending between layers will happen using #4658 Enhanced Layering facilities. Adding additional blending into the loop could limit the number of ways the effect could be used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the gradient, there are other effects that do almost the same.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then what exactly should the gradient be with?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as it was, plus the suggestions: cosine, sub-gradiens, perlin

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this effect to be a simple, lite occasional flair to a relatively plain and simple back round, as every other effect had too much noise, randomness, and was always visible. Adding all of those gradients are well outside the scope of what I want my effect to be. I think we have very different ideas of what this effect should be so I am going to close this and just maintain my own fork. I'm happy to adapt to make my effect more versatile and flexible, but I am not going to make something I don't want.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you misunderstood.

}
else {
SEGMENT.setPixelColor(i,SEGCOLOR(1));
}
}

return FRAMETIME;
}
static const char _data_FX_MODE_SHIMMER[] PROGMEM = "Shimmer@Speed,Frequancy,Size,,,Reverse;!!;sx=231,ix=221";
static const char _data_FX_MODE_SHIMMER[] PROGMEM = "Shimmer@Speed,Frequency,Size,,,Reverse;Fx,Bg,Cx;!;m12;sx=231,ix=221,pal=4";

/*
* Alternating pixels running function.
Expand Down
Loading