mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-02 19:46:45 -04:00
Improved Debounce for Encoders (#1837)
* Fix variable type declaration * Fix typo * Two-bit encoder debouncing * Slight optimization * Comment change
This commit is contained in:
parent
f59f5dfaa3
commit
a2a5fb166e
5 changed files with 41 additions and 19 deletions
|
@ -64,4 +64,16 @@ class Debounce {
|
|||
bool long_press_occurred_{false}; // TRUE when button is being held down and LONG_PRESS_DELAY has been reached (only when long_press_enabled)
|
||||
};
|
||||
|
||||
class EncoderDebounce {
|
||||
public:
|
||||
bool feed(const uint8_t phase_bits); // returns TRUE if state changed after debouncing
|
||||
|
||||
uint8_t state(); // returns debounced phase bits from encoder
|
||||
|
||||
private:
|
||||
uint8_t history_{0}; // shift register of previous reads from encoder
|
||||
|
||||
uint8_t state_{0}; // actual encoder output state (after debounce logic)
|
||||
};
|
||||
|
||||
#endif /*__DEBOUNCE_H__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue