-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
add Rainbow Shimmer effect. Just like Rainbow Cycle but with a white … #4905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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] | ||
| 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++) { | ||
Charming-Lime marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // 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)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you forgot the blend
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. without the gradient, there are other effects that do almost the same.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then what exactly should the gradient be with?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as it was, plus the suggestions: cosine, sub-gradiens, perlin
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
|
||
There was a problem hiding this comment.
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.