AskSin++
Alarm.h
1 //- -----------------------------------------------------------------------------------------------------------------------
2 // AskSin++
3 // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 //- -----------------------------------------------------------------------------------------------------------------------
5 
6 #ifndef __ALARM_H__
7 #define __ALARM_H__
8 
9 #include "Link.h"
10 
11 namespace as {
12 
13 class AlarmClock;
14 
15 class Alarm: public Link {
16 protected:
17  ~Alarm() {}
18 
19  bool m_Async : 4;
20  bool m_Active : 4;
21 public:
22  uint32_t tick : 24;
23 
24  virtual void trigger(AlarmClock&) = 0;
25 
26  Alarm () :
27  m_Async(false), m_Active(0), tick(0) {
28 }
29  Alarm(uint32_t t) :
30  m_Async(false), m_Active(0), tick(t) {
31  }
32  Alarm(uint32_t t,bool asynch) :
33  m_Async(asynch), m_Active(0), tick(t) {
34  }
35  void set(uint32_t t) {
36  tick = t;
37  }
38  void async(bool value) {
39  m_Async = value;
40  }
41  bool async() const {
42  return m_Async;
43  }
44  void active(bool value) {
45  m_Active = value;
46  }
47  bool active () const {
48  return m_Active;
49  }
50 };
51 
52 class RTCAlarm : public Alarm {
53 public:
54  uint16_t millis;
55 protected:
56  ~RTCAlarm() {}
57 
58  bool delayMillis ();
59 
60 public:
61  RTCAlarm() : Alarm(0), millis(0) {}
62  RTCAlarm(uint32_t t,uint16_t m) : Alarm(t), millis(m) {}
63  RTCAlarm(uint32_t t,uint16_t m,bool asynch) : Alarm(t,asynch), millis(m) {}
64 };
65 
66 }
67 
68 #endif
as::RTCAlarm
Definition: Alarm.h:52
as::Alarm
Definition: Alarm.h:15
as::AlarmClock
Definition: AlarmClock.h:32