diff --git a/libraries/Ticker/Ticker.cpp b/libraries/Ticker/Ticker.cpp index b348798c66..dee3a6363d 100644 --- a/libraries/Ticker/Ticker.cpp +++ b/libraries/Ticker/Ticker.cpp @@ -22,20 +22,18 @@ #include #include -extern "C" { #include "c_types.h" #include "eagle_soc.h" #include "ets_sys.h" #include "osapi.h" -} -const int ONCE = 0; -const int REPEAT = 1; +static const int ONCE = 0; +static const int REPEAT = 1; #include "Ticker.h" Ticker::Ticker() -: _timer(0) +: _timer(nullptr) { } @@ -66,5 +64,10 @@ void Ticker::detach() os_timer_disarm(_timer); delete _timer; - _timer = 0; + _timer = nullptr; +} + +bool Ticker::active() +{ + return (bool)_timer; } diff --git a/libraries/Ticker/Ticker.h b/libraries/Ticker/Ticker.h index ea3f59f1cc..74725fb76d 100644 --- a/libraries/Ticker/Ticker.h +++ b/libraries/Ticker/Ticker.h @@ -23,6 +23,7 @@ #define TICKER_H #include +#include #include extern "C" { @@ -93,6 +94,7 @@ class Ticker } void detach(); + bool active(); protected: void _attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, uint32_t arg); diff --git a/libraries/Ticker/keywords.txt b/libraries/Ticker/keywords.txt index 89cca9a0cf..b5701b5be9 100644 --- a/libraries/Ticker/keywords.txt +++ b/libraries/Ticker/keywords.txt @@ -15,6 +15,7 @@ attach_ms KEYWORD2 once KEYWORD2 once_ms KEYWORD2 detach KEYWORD2 +active KEYWORD2 ####################################### # Instances (KEYWORD2)