COSA
An Object-Oriented Platform for Arduino Programming
Keypad.cpp
Go to the documentation of this file.
1 
21 #include "Cosa/Keypad.hh"
22 
23 void
24 Keypad::Key::on_change(uint16_t value)
25 {
26  uint8_t nr = 0;
27  while (value < (uint16_t) pgm_read_word(&m_map[nr])) nr++;
28  if (UNLIKELY(nr == m_latest)) return;
29  if (nr != 0)
30  m_keypad->on_key_down(nr);
31  else
32  m_keypad->on_key_up(m_latest);
33  m_latest = nr;
34 }
35 
36 void
38 {
39  m_key.powerup();
41 }
virtual void on_key_up(uint8_t nr)
Definition: Keypad.hh:64
Key m_key
Definition: Keypad.hh:106
static void powerup()
Definition: AnalogPin.hh:113
virtual void run()
Definition: Keypad.cpp:37
virtual void on_key_down(uint8_t nr)
Definition: Keypad.hh:53
#define UNLIKELY(x)
Definition: Types.h:153
bool sample_request(uint8_t event=Event::NULL_TYPE)
Definition: AnalogPin.hh:171