-
Notifications
You must be signed in to change notification settings - Fork 0
/
PeriodicEvent.h
52 lines (42 loc) · 948 Bytes
/
PeriodicEvent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Periodic Event Class
* Nathan Reichenberger
*
* Allows the main program to perform periodic events
* without blocking
*
*/
#ifndef __PERIODIC_EVENT_H__
#define __PERIODIC_EVENT_H__
#include <Arduino.h>
#include "stdint.h"
typedef struct
{
uint16_t timeval_hour;
uint16_t timeval_min;
uint16_t timeval_sec;
uint16_t timeval_ms;
} periodic_timeval;
class PeriodicEvent
{
public:
//constructors
PeriodicEvent( periodic_timeval Delay, void( *Funct )( void * data ), void* UserData );
//destructor
~PeriodicEvent();
//functions
bool Check();
void Enable();
void Disable();
void UpdateDelay( periodic_timeval Delay );
void Kick();
unsigned long Get_Delay_ms();
private:
bool enabled;
unsigned long temp_Time;
unsigned long start_Time;
unsigned long delay_Time;
void(*user_CB )( void * data );
void * user_Data;
};
#endif