11 #ifndef __BUTTON_HEADER
12 #define __BUTTON_HEADER
17 #include "../ustd/type_traits.hpp"
34 template<
typename pin_concept,
bool pressed_state = HIGH, u
int16_t _auto_rate = state::auto_rate, u
int16_t _auto_delay = state::auto_delay>
36 typedef uint8_t state_type;
43 pin_.mode(INPUT_PULLUP);
50 pin_.mode(INPUT_PULLUP);
52 operator bool()
const {
57 void update_impl(
bool const & read) {
67 if((
tool::clock.micros() - start_press_) > (1000000.0 / _auto_rate)) {
73 if(read != old_read_) {
79 start_press_ =
tool::clock.
micros() + _auto_delay * 1000.0 - (1000000.0 / _auto_rate);
88 template<
typename T =
void>
90 update_impl(pin_.read());
92 template<
typename T =
void>
115 #endif //__BUTTON_HEADER
uint16_t const auto_delay
Definition: button.hpp:30
Definition: button.hpp:25
Definition: type_traits.hpp:228
Definition: button.hpp:26
Definition: button.hpp:24
Definition: button.hpp:22
uint8_t const auto_rate
Definition: button.hpp:29
button_enum
Definition: button.hpp:21
Definition: button.hpp:23
Definition: button.hpp:27