timer.h
Go to the documentation of this file.
/*
* timer.h
*
* Created on: Nov 9, 2015
* Author: Philipp Hinz
*/
#ifndef TIMER_H_
#define TIMER_H_
class timer {
public:
timer(void (*handler)(void));
timer(void *(*handler)(void *));
void setDivider(int divider);
int getDivider();
void call();
void start();
void stop();
bool isActive();
timer *next;
private:
void (*handler)(void);
void *(*thandler)(void *);
int divider;
int id = 0;
bool active;
bool asThread;
pthread_t thread;
};
void initTimers(void);
void stopTimers(void);
void *nullThread(void *threadid);
#define SIG SIGRTMIN
#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0)
#define CLOCKID CLOCK_REALTIME
#endif /* TIMER_H_ */
timer::timer
timer(void(*handler)(void))
Timer constructor Depending on the call of the constructor the handler will be called as thread or no...
Definition: timer.cpp:34
initTimers
void initTimers(void)
inits the system timer based on signals
Definition: timer.cpp:153
timer::call
void call()
Calls the timer handler if enabled.
Definition: timer.cpp:69
nullThread
void * nullThread(void *threadid)
This is a dummy thread.
Definition: timer.cpp:229
timer::next
timer * next
contains the pointer on the next timer element of the list
Definition: timer.h:27
timer::start
void start()
enables the timer
Definition: timer.cpp:93
stopTimers
void stopTimers(void)
Stops all existing timers.
Definition: timer.cpp:214
timer::isActive
bool isActive()
Returns the timers active state.
Definition: timer.cpp:128
timer::setDivider
void setDivider(int divider)
sets the divider for this timer (based on system timer)
Definition: timer.cpp:110
timer::getDivider
int getDivider()
reads the timer divider
Definition: timer.cpp:119
timer
Timer Class This class allows the creation of multiple timers that are based by a divider on a single...
Definition: timer.h:17
timer::stop
void stop()
disables the timer
Definition: timer.cpp:101