Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
src
DigitalInputButton.cpp
1
#include <Arduino.h>
2
#include "DigitalInputButton.h"
3
4
DigitalInputButton::DigitalInputButton
(
const
uint8_t pin,
const
bool
pullup) :
5
_pin(pin),
6
_pullup(pullup)
7
{
8
}
9
10
void
DigitalInputButton::begin
()
11
{
12
if
(_pullup) {
13
pinMode(_pin, INPUT_PULLUP);
14
}
else
{
15
pinMode(_pin, INPUT);
16
}
17
}
18
19
bool
DigitalInputButton::on
()
20
{
21
if
(_pullup) {
22
return
!digitalRead(_pin);
23
}
else
{
24
return
digitalRead(_pin);
25
}
26
}
27
DigitalInputButton::begin
void begin()
Definition:
DigitalInputButton.cpp:10
DigitalInputButton::on
bool on()
Definition:
DigitalInputButton.cpp:19
DigitalInputButton::DigitalInputButton
DigitalInputButton(const uint8_t pin, const bool pullup=true)
Definition:
DigitalInputButton.cpp:4
Generated by
1.8.15