Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
Timer functions

Provides timer functions. More...

 Timer::Timer ()
 Timer class. More...
 
Timer &IRAM_ATTR Timer::initializeMs (uint32_t milliseconds, InterruptCallback callback=NULL)
 Initialise millisecond timer. More...
 
Timer &IRAM_ATTR Timer::initializeUs (uint32_t microseconds, InterruptCallback callback=NULL)
 Initialise microsecond timer. More...
 
Timer &IRAM_ATTR Timer::initializeMs (uint32_t milliseconds, TimerDelegate delegateFunction=NULL)
 Initialise millisecond timer. More...
 
Timer &IRAM_ATTR Timer::initializeUs (uint32_t microseconds, TimerDelegate delegateFunction=NULL)
 Initialise microsecond timer. More...
 
void IRAM_ATTR Timer::start (bool repeating=true)
 Start timer running. More...
 
void __forceinline IRAM_ATTR Timer::startOnce ()
 Start one-shot timer running. More...
 
void IRAM_ATTR Timer::stop ()
 Stop timer. More...
 
void IRAM_ATTR Timer::restart ()
 Restarts timer. More...
 
bool Timer::isStarted ()
 Check if timer is started. More...
 
uint64_t Timer::getIntervalUs ()
 Get timer interval. More...
 
uint32_t Timer::getIntervalMs ()
 Get timer interval. More...
 
void IRAM_ATTR Timer::setIntervalUs (uint64_t microseconds=1000000)
 Set timer interval. More...
 
void IRAM_ATTR Timer::setIntervalMs (uint32_t milliseconds=1000000)
 Set timer interval. More...
 
void IRAM_ATTR Timer::setCallback (InterruptCallback interrupt=NULL)
 Set timer trigger function. More...
 
void IRAM_ATTR Timer::setCallback (TimerDelegate delegateFunction)
 Set timer trigger function. More...
 

Detailed Description

Provides timer functions.

Function Documentation

uint32_t Timer::getIntervalMs ( )

Get timer interval.

Return values
uint32_tTimer interval in milliseconds
uint64_t Timer::getIntervalUs ( )

Get timer interval.

Return values
uint64_tTimer interval in microseconds
Timer& IRAM_ATTR Timer::initializeMs ( uint32_t  milliseconds,
InterruptCallback  callback = NULL 
)

Initialise millisecond timer.

Parameters
millisecondsDuration of timer in milliseconds
callbackFunction to call when timer triggers
Note
Classic c-style callback method
Timer& IRAM_ATTR Timer::initializeMs ( uint32_t  milliseconds,
TimerDelegate  delegateFunction = NULL 
)

Initialise millisecond timer.

Parameters
millisecondsDuration of timer in milliseconds
delegateFunctionFunction to call when timer triggers
Note
Delegate callback method
Timer& IRAM_ATTR Timer::initializeUs ( uint32_t  microseconds,
InterruptCallback  callback = NULL 
)

Initialise microsecond timer.

Parameters
microsecondsDuration of timer in milliseconds
callbackFunction to call when timer triggers
Note
Classic c-style callback method
Timer& IRAM_ATTR Timer::initializeUs ( uint32_t  microseconds,
TimerDelegate  delegateFunction = NULL 
)

Initialise microsecond timer.

Parameters
microsecondsDuration of timer in milliseconds
delegateFunctionFunction to call when timer triggers
Note
Delegate callback method
bool Timer::isStarted ( )

Check if timer is started.

Return values
boolTrue if timer is running
void IRAM_ATTR Timer::restart ( )

Restarts timer.

Note
Restarts the timer from zero, extending duration.
void IRAM_ATTR Timer::setCallback ( InterruptCallback  interrupt = NULL)

Set timer trigger function.

Parameters
interruptFunction to be called on timer trigger
Note
Classic c-type callback method
void IRAM_ATTR Timer::setCallback ( TimerDelegate  delegateFunction)

Set timer trigger function.

Parameters
delegateFunctionFunction to be called on timer trigger
Note
Delegate callback method
void IRAM_ATTR Timer::setIntervalMs ( uint32_t  milliseconds = 1000000)

Set timer interval.

Parameters
millisecondsInterval in milliseconds. (Default: 1s)
void IRAM_ATTR Timer::setIntervalUs ( uint64_t  microseconds = 1000000)

Set timer interval.

Parameters
microsecondsInterval in microseconds. (Default: 1ms)
void IRAM_ATTR Timer::start ( bool  repeating = true)

Start timer running.

Parameters
repeatingSet to true for repeating timer. Set to false for one-shot.
void __forceinline IRAM_ATTR Timer::startOnce ( )
inline

Start one-shot timer running.

Note
Will start timer and trigger once after configured duration.
void IRAM_ATTR Timer::stop ( )

Stop timer.

Note
Stops a running timer. Has no effect on stopped timer.
Timer::Timer ( )

Timer class.