1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

lib/Ticker: add bool active() (#2722)

* lib/Ticker: add bool active()

Makes it easier to self detach, and check if a timer is still operating.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>

* Code cleanup Ticker.cpp
This commit is contained in:
Karl Palsson
2018-01-05 04:04:53 +00:00
committed by Develo
parent 9cfbbc7ad3
commit 89837fcea5
3 changed files with 12 additions and 6 deletions

View File

@ -22,20 +22,18 @@
#include <stddef.h>
#include <stdint.h>
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;
}