Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
src
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
19
bool
DualInputButton::on
()
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
DualInputButton::on
bool on()
Definition:
DualInputButton.cpp:19
AbstractButton
Definition:
AbstractButton.h:10
AbstractButton::begin
virtual void begin()
Definition:
AbstractButton.h:23
DualInputButton::DualInputButton
DualInputButton(AbstractButton &button1, AbstractButton &button2, const MixMode mix=Or)
Definition:
DualInputButton.cpp:4
AbstractButton::on
virtual bool on()=0
Generated by
1.8.15