/*
LED blink example from TaskScheduler.
Source: https://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example00_Blink
*/
// #define _TASK_TIMECRITICAL // Enable monitoring scheduling overruns
#define _TASK_SLEEP_ON_IDLE_RUN // Enable 1 ms SLEEP_IDLE powerdowns between tasks if no callback methods were invoked during the pass
#define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
// #define _TASK_WDT_IDS // Compile with support for wdt control points and task ids
// #define _TASK_LTS_POINTER // Compile with support for local task storage pointer
// #define _TASK_PRIORITY // Support for layered scheduling priority
// #define _TASK_MICRO_RES // Support for microsecond resolution
// #define _TASK_STD_FUNCTION // Support for std::function (ESP8266 and ESP32 ONLY)
// #define _TASK_DEBUG // Make all methods and variables public for debug purposes
// #define _TASK_INLINE // Make all methods "inline" - needed to support some multi-tab, multi-file implementations
// #define _TASK_TIMEOUT // Support for overall task timeout
// #define _TASK_OO_CALLBACKS // Support for dynamic callback method binding
#include <TaskScheduler.h>
// Debug and Test options
#define _DEBUG_
//#define _TEST_
#ifdef _DEBUG_
#define _PP(a) Serial.print(a);
#define _PL(a) Serial.println(a);
#else
#define _PP(a)
#define _PL(a)
#endif
// LED_BUILTIN 13
#if defined( ARDUINO_ARCH_ESP32 )
#define LED_BUILTIN 23 // esp32 dev2 kit does not have LED
#endif
// Scheduler
Scheduler ts;
void callback1();
Task t1(3000, TASK_ONCE, &callback1, &ts);
void setup()
{
pinMode(11, INPUT); // set pin to input
digitalWrite(11, HIGH); // turn on pullup resistors
}
void callback1()
{
LEDOn();
delay(500);
LEDOff();
}
void loop() {
ts.execute();
if (digitalRead(11) == 0)
{
//t1.enableDelayed();
t1.restartDelayed(1000)
}
delay(10);
}
inline void LEDOn() {
digitalWrite( LED_BUILTIN, HIGH );
}
inline void LEDOff() {
digitalWrite( LED_BUILTIN, LOW );
}