COSA
An Object-Oriented Platform for Arduino Programming
LED.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_LED_HH
22 #define COSA_LED_HH
23 
24 #include "Cosa/Types.h"
25 #include "Cosa/OutputPin.hh"
26 #include "Cosa/Periodic.hh"
27 
32 class LED : private Periodic {
33 public:
39  Periodic(scheduler, 512),
40  m_pin(pin)
41  {}
42 
46  void on()
47  __attribute__((always_inline))
48  {
49  stop();
50  m_pin.on();
51  }
52 
56  void off()
57  __attribute__((always_inline))
58  {
59  stop();
60  m_pin.off();
61  }
62 
66  void normal_mode()
67  __attribute__((always_inline))
68  {
69  stop();
70  period(512);
71  start();
72  }
73 
77  void alert_mode()
78  __attribute__((always_inline))
79  {
80  stop();
81  period(128);
82  start();
83  }
84 
85 private:
87  OutputPin m_pin;
88 
93  virtual void run()
94  {
95  m_pin.toggle();
96  }
97 };
98 
99 #endif
void alert_mode()
Definition: LED.hh:77
Definition: LED.hh:32
void off() const
Definition: OutputPin.hh:144
uint32_t period() const
Definition: Periodic.hh:67
void toggle() const
Definition: OutputPin.hh:163
LED(Job::Scheduler *scheduler, Board::DigitalPin pin=Board::LED)
Definition: LED.hh:38
bool stop()
Definition: Job.hh:169
void on()
Definition: LED.hh:46
void normal_mode()
Definition: LED.hh:66
void on() const
Definition: OutputPin.hh:105
bool start()
Definition: Job.hh:159
void off()
Definition: LED.hh:56