Closed PowerBroker2 closed 2 years ago
Nvm, I got it to work with a different library.
To avoid confusion for readers who might stumble over this later:
#include "TeensyTimerTool.h"
using namespace TeensyTimerTool;
OneShotTimer timer1(TCK), timer2(TCK);
byte ledState = HIGH;
void processVideo() { if (ledState == HIGH) { ledState = LOW; timer2.trigger(2s); } else { ledState = HIGH; timer1.trigger(1s); } digitalWriteFast(LED_BUILTIN, ledState); }
void setup() { pinMode(LED_BUILTIN, OUTPUT);
timer1.begin(processVideo);
timer2.begin(processVideo);
timer1.trigger(1s);
}
void loop() { }
And here a more terse version of your code:
```c++
#include "TeensyTimerTool.h"
using namespace TeensyTimerTool;
OneShotTimer timer1(TCK);
void processVideo()
{
digitalToggleFast(LED_BUILTIN);
timer1.trigger(digitalReadFast(LED_BUILTIN) ? 1s : 2s);
}
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
timer1.begin(processVideo);
timer1.trigger(10ms);
}
void loop(){
}
Thank you! The example code works great. This is a really cool library, I just wish the documentation was better. Do you ever plan on making a sort of "read the docs" page for it?
I just wish the documentation was better. Do you ever plan on making a sort of "read the docs" page for it?
I agree that a library without documentation is quite useless. I therefore always try to document my stuff as good as possible. So, I don't know if you didn't find the documentation (https://github.com/luni64/TeensyTimerTool/wiki) or if you miss something in it?
This looks like a very promising library to help with a PAL video encoder project I'm working on, but it seems that the TeensyTimerTool isn't letting me use multiple timers or updating the timers I'm using. For example:
From my understanding of the library, the above sketch should light the Teensy 4.0's built-in LED for 1 seconds, turn off for 2 second, and repeat. However, the LED just lights and stays lit.
Can you confirm this as a bug or am I misunderstanding how the library works?