luni
Well-known member
In case somebody needs an interrupt driven delay library (e.g. for generating stepper pulses with long pulse width):
https://github.com/luni64/TeensyDelay
The library uses one of the FTM or TPM timers (selectable) and can provide up to 8 independent delay channels. Not a big thing, but might come in handy for some project.
Basic usage:
The library is compatible to T3.0, T3.1/2, T3.5, T3.6. Im working on compatibiltiy to T-LC
Have fun.
https://github.com/luni64/TeensyDelay
The library uses one of the FTM or TPM timers (selectable) and can provide up to 8 independent delay channels. Not a big thing, but might come in handy for some project.
Basic usage:
Code:
#include <TeensyDelay.h>
void callback()
{
digitalWriteFast(LED_BUILTIN,LOW);
}
void setup()
{
pinMode(LED_BUILTIN,OUTPUT);
TeensyDelay::begin();
TeensyDelay::addDelayChannel(callback); // setup a delay channel and attach the callback function to it
}
void loop()
{
digitalWriteFast(LED_BUILTIN,HIGH); // switch on LED
TeensyDelay::trigger(15); // the callback function will switch it off 15µs later
delay(500); // repeat every 500ms
}
The library is compatible to T3.0, T3.1/2, T3.5, T3.6. Im working on compatibiltiy to T-LC
Have fun.