Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
DualButton.cpp
1 #include "DualButton.h"
2 
4 {
5  _b1 = b1;
6  _b2 = b2;
7 }
8 
9 void DualButton::begin(uint8_t threshold, uint8_t delay)
10 {
11  _b1->begin(threshold, delay);
12  _b2->begin(threshold, delay);
13 }
14 
16 {
17  _b1->update();
18  _b2->update();
19 }
20 
22 {
23  return _b1->on() || _b2->on();
24 }
25 
27 {
28  return _b1->pushed() || _b2->pushed();
29 }
30 
32 {
33  return _b1->tapped() || _b2->tapped();
34 }
35 
36 bool DualButton::held(uint16_t ms)
37 {
38  return _b1->held(ms) || _b2->held(ms);
39 }
40 
41 bool DualButton::repeat(uint16_t initialMs, uint16_t repeatMs)
42 {
43  return _b1->repeat(initialMs, repeatMs) || _b2->repeat(initialMs, repeatMs);
44 }
45 
46 
47 
bool repeat(uint16_t initialMs=AbstractDebouncedButton::DefaultButtonRepeatInitialMs, uint16_t repeatMs=AbstractDebouncedButton::DefaultButtonRepeatMs)
Definition: DualButton.cpp:41
bool held(uint16_t ms=DefaultHeldMs)
void update()
Definition: DualButton.cpp:15
bool repeat(uint16_t initialMs=DefaultButtonRepeatInitialMs, uint16_t repeatMs=DefaultButtonRepeatMs)
bool on()
Definition: DualButton.cpp:21
void begin(uint8_t threshold=AbstractDebouncedButton::DefaultThreshold, uint8_t delay=AbstractDebouncedButton::DefaultButtonDelay)
uint32_t tapped(bool peek=false)
DualButton(DebouncedButton *b1, DebouncedButton *b2)
Definition: DualButton.cpp:3
bool pushed()
Definition: DualButton.cpp:26
void begin(uint8_t threshold=AbstractDebouncedButton::DefaultThreshold, uint8_t delay=AbstractDebouncedButton::DefaultButtonDelay)
Definition: DualButton.cpp:9
bool tapped()
Definition: DualButton.cpp:31
bool held(uint16_t ms=AbstractDebouncedButton::DefaultHeldMs)
Definition: DualButton.cpp:36