mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-11-15 04:34:11 +00: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:
@@ -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__*/
|
||||
|
||||
Reference in New Issue
Block a user