Skip to content

Request for sawtooth wave to be added to FastLED. You already have a triangle wave. #565

Closed

Description

@atuline

Please see the following diagram:

http://cds.linear.com/image/WaveformShapes.png

which shows that a triangle wave is not a sawtooth wave, thus my request.

As a matter of fact, a sawtooth wave in both directions would even be better.

Thanks,

Andrew

Activity

  1. 0xD34DC0DE commented on Feb 13, 2018

    @0xD34DC0DE
  2. kriegsman commented on Feb 13, 2018

    @kriegsman
    Member

    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.

  3. self-assigned this
    on Feb 13, 2018
  4. atuline commented on Feb 14, 2018

    @atuline
    Author

    Thanks. I'll study and play around with those more carefully.

  5. R-OLE commented on Sep 18, 2018

    @R-OLE

    Also please remove the "aka sawtooth" phrase from the wiki entry on wave functions to:

    1. Not lead folks astray that are just learning these concepts
    2. Avoid confusion with the aptly named functions listed in this issue
  6. added
    type: feature
    area: core
    status: stale
    status: triage
    on Apr 16, 2026
  7. zackees commented on Aug 1, 2026

    @zackees
    Member

    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 sawtooth
    uint8_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 BPM
    uint8_t tri  = triwave8(beat8(60));    // triangle at 60 BPM
    uint8_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.

  8. moved this from Triage to Done in FastLED Trackeron Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: corestatus: stalestatus: triagetype: feature

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions