adafruit_macropad icon indicating copy to clipboard operation
adafruit_macropad copied to clipboard

Rotary encoder button issues

Open karlmiles opened this issue 2 years ago • 0 comments

I've been enjoying the project since I picked up a MacroPad last week but I'm having problems today with the rotary encoder button functioning correctly.

Pressing the rotary encoder to trigger the switch, toggles whether audio is muted but, after a short delay, this toggles rapidly until the encoder is rotated or any one of the keys tapped. I've tried this on multiple machines running Manjaro, Ubuntu & Windows and all seem to exhibit the same behaviour (though on Windows it's only apparent when using volume up/down instead of mute).

Running evtest (a kernel input device debugger), I can see initial keypress (denoted with the value = 1, followed by a string of value = 2 which occurs when a key is pressed and held.

I've spent a bit of time going over the code, tracking the events being fired and have found where my problem lives in the code and been able to remedy it.

The KeyApp.encoder_button_event() method checks if event.pressed is truthy, and if it is, ultimately sends the keycode. What I noticed was, I never see event.pressed being falsey to trigger the key release so it's staying down and repeating. Modifying the code to call self.encoder_button.undo(self) immediately after self.encoder_button.execute(self) fixes my issue completely. What I'm not sure on, is whether there would/should be times when event.pressed is falsey?

karlmiles avatar Sep 11 '22 19:09 karlmiles