COSA
An Object-Oriented Platform for Arduino Programming
Alarm.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_ALARM_HH
22 #define COSA_ALARM_HH
23 
24 #include "Cosa/Types.h"
25 #include "Cosa/Clock.hh"
26 #include "Cosa/Periodic.hh"
28 
35 class Alarm : public Periodic {
36 public:
42  class Clock : public ::Clock, public ExternalInterrupt {
43  public:
54  bool pullup = false) :
55  ::Clock(),
56  ExternalInterrupt(pin, mode, pullup)
57  {}
58 
59  protected:
65  virtual void on_interrupt(uint16_t arg = 0)
66  {
67  UNUSED(arg);
68  tick(1000);
69  }
70  };
71 
78  Alarm(::Clock* clock, uint32_t period) :
79  Periodic(clock, period)
80  {}
81 };
82 #endif
83 
Alarm(::Clock *clock, uint32_t period)
Definition: Alarm.hh:78
uint8_t pin() const
Definition: Pin.hh:103
Definition: Alarm.hh:35
Mode mode() const
Definition: IOPin.hh:71
virtual void on_interrupt(uint16_t arg=0)
Definition: Alarm.hh:65
uint32_t period() const
Definition: Periodic.hh:67
ExternalInterruptPin
Definition: ATmega1284P.hh:190
#define UNUSED(x)
Definition: ATmega328P.hh:31
Clock(Board::ExternalInterruptPin pin, InterruptMode mode=ON_RISING_MODE, bool pullup=false)
Definition: Alarm.hh:52
void tick(uint16_t ms)
Definition: Clock.hh:94