fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
818d962
gram
1#ifndef _INPUT_DEBOUNCEDSWITCHMATRIXINPUT_HPP 2#define _INPUT_DEBOUNCEDSWITCHMATRIXINPUT_HPP 3 4#include "input/SwitchMatrixInput.hpp" 5#include "input/debounce.hpp" 6 7template < size_t num_rows ,size_t num_cols > 8class DebouncedSwitchMatrixInput :public SwitchMatrixInput < num_rows ,num_cols > { 9public : 10DebouncedSwitchMatrixInput ( 11const uint row_pins [num_rows ], 12const uint col_pins [num_cols ], 13const Button (& matrix )[num_rows ][num_cols ], 14DiodeDirection direction , 15uint32_t debounce_period_ms = 5 16 ) 17 :SwitchMatrixInput < num_rows ,num_cols > (row_pins ,col_pins ,matrix ,direction ) { 18_debounce_period_ms = debounce_period_ms ; 19 } 20 21private : 22DebounceState _debounce_state [num_rows ][num_cols ]; 23uint32_t _debounce_period_ms ; 24 25void UpdateButtonState (InputState & inputs ,size_t col_index ,size_t row_index ,bool pressed ) { 26bool state_changed = update_debounce_state ( 27_debounce_state [col_index ][row_index ], 28pressed , 29_debounce_period_ms 30 ); 31if (state_changed ) { 32Button button = this -> _matrix [col_index ][row_index ]; 33set_button (inputs .buttons ,button ,pressed ); 34 } 35 }; 36}; 37 38#endif