Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fastled example prompts
- one day
- =======
- "I'd like to add the 2nd order smoothstep function to a few places in the SousaVFX.ino cpp file.\r\rHere is the function:\r\r```cpp\rfloat smootherstep(float edge0, float edge1, float x) {\r // Scale, and clamp x to 0..1 range\r x = clamp((x - edge0) / (edge1 - edge0));\r\r return x * x * x * (x * (6.0f * x - 15.0f) + 10.0f);\r}\r\rfloat clamp(float x, float lowerlimit = 0.0f, float upperlimit = 1.0f) {\r if (x < lowerlimit) return lowerlimit;\r if (x > upperlimit) return upperlimit;\r return x;\r}\r```\r\rAnd I'd like it to be utilized in a couple places where there are linear fades, to smooth the linearity. Namely, here on line 189\r\r```SousaVFX.ino\r // Calculate fade out above certain radius\r float radiiFade;\r if (radHiRez >= (radiusCutoffEnd)) {\r radiiFade = 0.0f;\r } else if (radHiRez > radiusCutoff) {\r radiiFade = (radiusCutoffSlope * ((radHiRez * radiiNorm) - radiusCutoffNorm) + 1.0f);\r } else {\r radiiFade = 1.0f;\r }\r```\r\rand here on line 183:\r\r```SousaVFX.ino\r // Calculate pinwheel division's fade ins and outs\r int32_t deltaFixed = static_cast<int32_t>(normalizedPos16) - static_cast<int32_t>(peakPosFixed);\r float currentSlope = (normalizedPos16 < peakPosFixed) ? adjSlopeIn : adjSlopeOut;\r float fade = (deltaFixed * currentSlope) + 255.0f;\r float dimmermask = (normalizedPos16 < divisionWidthFixed && fade > 0.0f) ? fade : 0.0f;\r```",
- "Rename the clamp helper to avoid the FastLED clamp template collision",
- "Apply smootherstep to the palette nblend transition for smoother color crossfades",
- "This works, but the teensy seems to be struggling processing-wise. Is there something that could be done to make it less computationally expensive?",
- "This is a Teensy 3.2, so let's add a LUT",
- "Well, I've updated my libraries just for the heck of it, and now I see this error when compiling:\n\nMultiple libraries were found for \"FastLED.h\"\r Used: /Users/jbaylies/Documents/Arduino/libraries/FastLED\r Not used: /Users/jbaylies/Library/Arduino15/packages/teensy/hardware/avr/1.62.0/libraries/FastLED\rexit status 1\r\rCompilation error: 'FASTLED_USING_NAMESPACE' does not name a type",
- "this compiled successfully and seems to be working well on the teensy 3.2, thanks! There are the errors that appeared in the console, but they may be ignorable:",
- "For the sake of me learning new things, could you explain where lerp8 comes from and how it works?",
- "I believe you mentioned at some point that there was a possible division by 0 somewhere that would skip the calculation. Where was that?",
- "Since we're using a lookup table now, let's try the 7th order smoothstep function, shown here: https://en.wikipedia.org/wiki/Smoothstep#7th-order_equation",
- "Beautiful, thanks! Out of curiosity, how does doing this improve performance? \n\n float t2 = t * t;\r float t4 = t2 * t2;\n\nin this function\n\nfloat smootherstep01(float t) {\r t = clampFloat(t);\r\r float t2 = t * t;\r float t4 = t2 * t2;\r // -20t^7 + 70t^6 - 84t^5 + 35t^4 = t^4 * (35 - 84t + 70t^2 - 20t^3)\r float inner = 35.0f - t * (84.0f - t * (70.0f - 20.0f * t));\r return t4 * inner;\r}",
Advertisement
Add Comment
Please, Sign In to add comment