#include <mn_timer_esp32.hpp>

+ Inheritance diagram for mn::esp32::basic_esp32_timer:
+ Collaboration diagram for mn::esp32::basic_esp32_timer:

Public Member Functions

 basic_esp32_timer (const char *strName, unsigned int uiPeriod, bool bIsOneShot=true)
 
virtual ~basic_esp32_timer ()
 
virtual int create ()
 
virtual int destroy (unsigned int timeout=(unsigned int) 0xffffffffUL)
 
virtual int active (unsigned int timeout=(unsigned int) 0xffffffffUL)
 
virtual int inactive (unsigned int timeout=(unsigned int) 0xffffffffUL)
 
virtual int reset (unsigned int timeout=(unsigned int) 0xffffffffUL)
 
virtual bool set_period (unsigned int uiNewPeriod, unsigned int timeout=(unsigned int) 0xffffffffUL)
 
virtual unsigned int get_period ()
 
virtual void * get_handle ()
 
virtual void set_id (int nId)
 
virtual bool is_running ()
 
virtual operator bool ()
 

Protected Member Functions

virtual void on_timer ()=0
 
virtual void on_enter ()
 
virtual void on_exit ()
 

Static Private Member Functions

static void runtimerstub (void *xTimer)
 

Private Attributes

esp_timer_handle_t m_pHandle
 
bool m_bIsOneShot
 
unsigned int m_uiPeriod
 
const char * m_strName
 
bool m_bIsRunning
 
bool m_bIsInit
 

Detailed Description

Wrapper class around esp-idf of a timer. This is a base abstract class, all esp32_timers must be override the function on_timer()

Constructor & Destructor Documentation

◆ basic_esp32_timer()

mn::esp32::basic_esp32_timer::basic_esp32_timer ( const char *  strName,
unsigned int  uiPeriod,
bool  bIsOneShot = true 
)

Construct a timer.

Parameters
strNameName of the timer.
uiPeriodWhen does the timer expire and run your Run() method.
bIsOneShottrue if this is a one shot timer. false if the timer expires every PeriodInTicks.

◆ ~basic_esp32_timer()

virtual mn::esp32::basic_esp32_timer::~basic_esp32_timer ( )
inlinevirtual

Member Function Documentation

◆ active()

int mn::esp32::basic_esp32_timer::active ( unsigned int  timeout = (unsigned int) 0xffffffffUL)
virtual

Start the timer.

Parameters
timeoutHow long to wait - not use
Returns
ERR_TIMER_OK All okay, no error ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first ERR_TIMER_AKTIVATE if it will not (i.e. timeout).

Implements mn::ITimer.

◆ create()

int mn::esp32::basic_esp32_timer::create ( )
virtual

Create the timer

Note
Timers are not active after they are created, you need to activate them via active, reset, etc.
Returns
- ERR_TIMER_OK No error,
  • ERR_TIMER_ALREADYINIT The timer are allready created
  • ERR_TIMER_CANTCREATE on error on create the ESP Timer

Implements mn::ITimer.

◆ destroy()

int mn::esp32::basic_esp32_timer::destroy ( unsigned int  timeout = (unsigned int) 0xffffffffUL)
virtual

destroy the timer

Parameters
timeoutHow long to wait - not use
Returns
- ERR_TIMER_OK No error,
  • ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first

Implements mn::ITimer.

◆ get_handle()

void * mn::esp32::basic_esp32_timer::get_handle ( )
virtual

Get the timer handle

Returns
The timer handle

Implements mn::ITimer.

◆ get_period()

virtual unsigned int mn::esp32::basic_esp32_timer::get_period ( )
inlinevirtual

Get the timer's period

Returns
The timer's period

Implements mn::ITimer.

◆ inactive()

int mn::esp32::basic_esp32_timer::inactive ( unsigned int  timeout = (unsigned int) 0xffffffffUL)
virtual

Stop the timer

Parameters
timeoutHow long to wait - not use
Returns
ERR_TIMER_OK All okay, no error ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first ERR_TIMER_INAKTIVATE Can not stop the timer

Implements mn::ITimer.

◆ is_running()

virtual bool mn::esp32::basic_esp32_timer::is_running ( )
inlinevirtual

Queries a timer to see if it is active or dormant.

Returns
false will be returned if the timer is dormant. And true will be returned if the timer is active.

Implements mn::ITimer.

◆ on_enter()

virtual void mn::esp32::basic_esp32_timer::on_enter ( )
inlineprotectedvirtual

call befor on_timer

Implements mn::ITimer.

◆ on_exit()

virtual void mn::esp32::basic_esp32_timer::on_exit ( )
inlineprotectedvirtual

call after on_timer

Implements mn::ITimer.

◆ on_timer()

virtual void mn::esp32::basic_esp32_timer::on_timer ( )
protectedpure virtual

Implementation of your actual timer code. You must override this function.

Implements mn::ITimer.

◆ operator bool()

virtual mn::esp32::basic_esp32_timer::operator bool ( )
inlinevirtual

Reimplemented from mn::ITimer.

◆ reset()

int mn::esp32::basic_esp32_timer::reset ( unsigned int  timeout = (unsigned int) 0xffffffffUL)
virtual

Reset the timer (first inactive and then active)

Parameters
timeoutHow long to wait - not use
Returns
- ERR_TIMER_OK All okay, no error
  • ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first
  • ERR_TIMER_RESET Can not reset
  • ERR_TIMER_INAKTIVATE Can not stop the timer

Implements mn::ITimer.

◆ runtimerstub()

void mn::esp32::basic_esp32_timer::runtimerstub ( void *  xTimer)
staticprivate

Adapter function that allows you to write a class specific on_timer() function that interfaces with FreeRTOS.

◆ set_id()

virtual void mn::esp32::basic_esp32_timer::set_id ( int  nId)
inlinevirtual

Get the timer ID - not implantated

Implements mn::ITimer.

◆ set_period()

bool mn::esp32::basic_esp32_timer::set_period ( unsigned int  uiNewPeriod,
unsigned int  timeout = (unsigned int) 0xffffffffUL 
)
virtual

Change a timer's period.

Parameters
uiNewPeriodThe new period in ticks.
timeoutHow long to wait
Returns
true no error, false if it will not (i.e. timeout).

Implements mn::ITimer.

Member Data Documentation

◆ m_bIsInit

bool mn::esp32::basic_esp32_timer::m_bIsInit
private

A saved / cached copy is the timer created

◆ m_bIsOneShot

bool mn::esp32::basic_esp32_timer::m_bIsOneShot
private

A saved / cached copy of what the timers's mode is.

◆ m_bIsRunning

bool mn::esp32::basic_esp32_timer::m_bIsRunning
private

A saved / cached copy is the timer running

◆ m_pHandle

esp_timer_handle_t mn::esp32::basic_esp32_timer::m_pHandle
private

Reference to the underlying timer handle.

◆ m_strName

const char* mn::esp32::basic_esp32_timer::m_strName
private

A saved / cached copy of what the timers's name is.

◆ m_uiPeriod

unsigned int mn::esp32::basic_esp32_timer::m_uiPeriod
private

A saved / cached copy of what the timers's period is.


The documentation for this class was generated from the following files: