You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Request for sawtooth wave to be added to FastLED. You already have a triangle wave. #565
Closing as completed — both halves of this are now done.
@atuline, you were right that a triangle wave is not a sawtooth, and @R-OLE was right that the wiki was teaching people otherwise.
The wiki fix. The "aka sawtooth" phrasing on triwave8() is gone, and the Wave Functions page now has a "Where's the sawtooth?" section pointing at the correctly-named functions — exactly the two things @R-OLE asked for.
On the sawtooth8 synonym@kriegsman offered to add: it turns out not to be worth having, for a reason that's more interesting than "nobody got to it."
Over the index domain these functions operate on, a rising sawtooth is the input:
uint8_t rising = i; // 0..255, snaps back to 0 — that's a sawtoothuint8_t falling = 255 - i; // the reverse ramp @atuline also asked for
Every other function on that page is a reshaping of that ramp — triwave8() folds it in half, quadwave8()/cubicwave8() ease it, sin8() rounds it. The ramp itself doesn't need a function; sawtooth8(i) { return i; } would add a name without adding a capability, and a second name for 255 - i alongside it.
What the request is really reaching for is the time-driven sawtooth, which already has a name — and it's the one @kriegsman pointed at:
uint8_t saw = beat8(60); // sawtooth at 60 BPMuint8_t tri = triwave8(beat8(60)); // triangle at 60 BPMuint8_t ease = quadwave8(beat8(60)); // eased, ~sine, at 60 BPM
beat8() is the generator the entire beatsin*() family is built on (src/lib8tion.h:211 describes it as exactly "8-bit repeating sawtooth wave"), with beat16()/beat88() for higher precision. That composition pattern is now written out on the wiki, since it wasn't obvious that the two halves — ramp generation and ramp shaping — were meant to be combined.
Thanks @0xD34DC0DE for the waveform diagram that made the distinction concrete, and @R-OLE for pushing on the docs rather than letting it slide.
Activity
0xD34DC0DE commentedon Feb 13, 2018
credit to the user who posted this image at this site:https://www.muffwiggler.com/forum/viewtopic.php?p=1144128
kriegsman commentedon Feb 13, 2018
Check out "beat8( BPM)", which is the sawtooth wave from 0-255 that's used to generate all the other waveforms. "beat88( BPM)" is the same, but with higher precision.
http://fastled.io/docs/3.1/group__lib8tion.html#ga12014943214a72eec31433d9682d4ebe
I can leave this ticket open as a reminder to myself to add synonyms called "sawtooth8" or something next time there's an update.
atuline commentedon Feb 14, 2018
Thanks. I'll study and play around with those more carefully.
R-OLE commentedon Sep 18, 2018
Also please remove the "aka sawtooth" phrase from the wiki entry on wave functions to:
zackees commentedon Aug 1, 2026
Closing as completed — both halves of this are now done.
@atuline, you were right that a triangle wave is not a sawtooth, and @R-OLE was right that the wiki was teaching people otherwise.
The wiki fix. The "aka sawtooth" phrasing on
triwave8()is gone, and the Wave Functions page now has a "Where's the sawtooth?" section pointing at the correctly-named functions — exactly the two things @R-OLE asked for.On the
sawtooth8synonym @kriegsman offered to add: it turns out not to be worth having, for a reason that's more interesting than "nobody got to it."Over the index domain these functions operate on, a rising sawtooth is the input:
Every other function on that page is a reshaping of that ramp —
triwave8()folds it in half,quadwave8()/cubicwave8()ease it,sin8()rounds it. The ramp itself doesn't need a function;sawtooth8(i) { return i; }would add a name without adding a capability, and a second name for255 - ialongside it.What the request is really reaching for is the time-driven sawtooth, which already has a name — and it's the one @kriegsman pointed at:
beat8()is the generator the entirebeatsin*()family is built on (src/lib8tion.h:211describes it as exactly "8-bit repeating sawtooth wave"), withbeat16()/beat88()for higher precision. That composition pattern is now written out on the wiki, since it wasn't obvious that the two halves — ramp generation and ramp shaping — were meant to be combined.Thanks @0xD34DC0DE for the waveform diagram that made the distinction concrete, and @R-OLE for pushing on the docs rather than letting it slide.