Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/Ticker: add bool active() #2722

Merged
merged 3 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions libraries/Ticker/Ticker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -66,5 +64,10 @@ void Ticker::detach()

os_timer_disarm(_timer);
delete _timer;
_timer = 0;
_timer = nullptr;
}

bool Ticker::active()
{
return (bool)_timer;
}
2 changes: 2 additions & 0 deletions libraries/Ticker/Ticker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define TICKER_H

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

extern "C" {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions libraries/Ticker/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ attach_ms KEYWORD2
once KEYWORD2
once_ms KEYWORD2
detach KEYWORD2
active KEYWORD2

#######################################
# Instances (KEYWORD2)
Expand Down