Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
DualInputButton.cpp
1 #include <Arduino.h>
2 #include "DualInputButton.h"
3 
4 DualInputButton::DualInputButton(AbstractButton& button1, AbstractButton& button2, const MixMode mix) :
5  _button1(button1),
6  _button2(button2),
7  _mix(mix)
8 {
9 }
10 
11 void DualInputButton::begin(bool callBeginInChildren)
12 {
13  if (callBeginInChildren) {
14  _button1.begin();
15  _button2.begin();
16  }
17 }
18 
20 {
21  switch (_mix) {
22  case Or:
23  return _button1.on() || _button2.on();
24  break;
25  case Xor:
26  return _button1.on() ^ _button2.on();
27  break;
28  case And:
29  return _button1.on() && _button2.on();
30  break;
31  default:
32  return false;
33  }
34 }
35 
virtual void begin()
DualInputButton(AbstractButton &button1, AbstractButton &button2, const MixMode mix=Or)
virtual bool on()=0