Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
src
ToggleButton.cpp
1
#include "ToggleButton.h"
2
3
ToggleButton::ToggleButton
(uint8_t pin,
bool
pullup) :
4
_button(pin, pullup)
5
{
6
}
7
8
void
ToggleButton::begin
(
bool
startState, uint8_t threshold, uint8_t delay)
9
{
10
_toggled = startState;
11
_button.
begin
(threshold, delay);
12
}
13
14
void
ToggleButton::update
()
15
{
16
_button.
update
();
17
if
(_button.
pushed
()) {
18
_toggled = !_toggled;
19
}
20
}
21
22
bool
ToggleButton::on
()
23
{
24
return
_toggled;
25
}
26
27
ToggleButton::ToggleButton
ToggleButton(uint8_t pin, bool pullup=true)
Definition:
ToggleButton.cpp:3
AbstractDebouncedButton::pushed
bool pushed(bool peek=false)
Definition:
AbstractDebouncedButton.cpp:20
ToggleButton::begin
void begin(bool startState=false, uint8_t threshold=AbstractDebouncedButton::DefaultThreshold, uint8_t delay=AbstractDebouncedButton::DefaultButtonDelay)
Definition:
ToggleButton.cpp:8
ToggleButton::update
void update()
Definition:
ToggleButton.cpp:14
DebouncedButton::begin
void begin(uint8_t threshold=AbstractDebouncedButton::DefaultThreshold, uint8_t delay=AbstractDebouncedButton::DefaultButtonDelay)
Definition:
DebouncedButton.cpp:11
ToggleButton::on
bool on()
Definition:
ToggleButton.cpp:22
DebouncedButton::update
void update()
Definition:
DebouncedButton.cpp:17
Generated by
1.8.15