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

Ticker library update

This commit is contained in:
Ivan Grokhotkov
2014-12-22 18:42:57 +03:00
parent 9ba2fcd29f
commit 687e472b4b
5 changed files with 54 additions and 22 deletions

View File

@ -29,6 +29,9 @@ extern "C" {
#include "osapi.h"
}
const int ONCE = 0;
const int REPEAT = 1;
#include "Ticker.h"
Ticker::Ticker()
@ -41,10 +44,8 @@ Ticker::~Ticker()
detach();
}
void Ticker::_attach_ms(callback_with_arg_t callback, uint32_t milliseconds, void* arg)
void Ticker::_attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, uint32_t arg)
{
const int REPEAT = 1;
if (_timer)
{
os_timer_disarm(_timer);
@ -54,8 +55,8 @@ void Ticker::_attach_ms(callback_with_arg_t callback, uint32_t milliseconds, voi
_timer = new ETSTimer;
}
os_timer_setfn(_timer, reinterpret_cast<ETSTimerFunc*>(callback), arg);
os_timer_arm(_timer, milliseconds, REPEAT);
os_timer_setfn(_timer, reinterpret_cast<ETSTimerFunc*>(callback), reinterpret_cast<void*>(arg));
os_timer_arm(_timer, milliseconds, (repeat)?REPEAT:ONCE);
}
void Ticker::detach()