fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
818d962
gram
1#ifndef _INPUT_DEBOUNCEDGPIOBUTTONINPUT_HPP 2#define _INPUT_DEBOUNCEDGPIOBUTTONINPUT_HPP 3 4#include "core/state.hpp" 5#include "input/GpioButtonInput.hpp" 6#include "input/debounce.hpp" 7#include "util/state_util.hpp" 8 9template < size_t button_count > class DebouncedGpioButtonInput :public GpioButtonInput { 10public : 11DebouncedGpioButtonInput ( 12const GpioButtonMapping button_mappings [button_count ], 13uint32_t debounce_period_ms = 5 14 ) 15 :GpioButtonInput (button_mappings ,button_count ) { 16_debounce_period_ms = debounce_period_ms ; 17 } 18 19private : 20DebounceState _debounce_state [button_count ]; 21uint32_t _debounce_period_ms ; 22 23void UpdateButtonState (InputState & inputs ,size_t button_mapping_index ,bool pressed ) { 24bool state_changed = update_debounce_state ( 25_debounce_state [button_mapping_index ], 26pressed , 27_debounce_period_ms 28 ); 29if (state_changed ) { 30set_button (inputs .buttons ,_button_mappings [button_mapping_index ].button ,pressed ); 31 } 32 } 33}; 34 35#endif