Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

GamePad vs adafruit_debouncer
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

GamePad vs adafruit_debouncer

by kevinjwalters on Wed Sep 02, 2020 11:47 am

I've just noticed GamePad in the gamepad library (not to be confused with Gamepad from adafruit_hid.gamepad). This appears to offer debounce functionality? How does it compare to adafruit_debouncer? Is one recommended over the other?

kevinjwalters
 
Posts: 735
Joined: Sun Oct 01, 2017 3:15 pm

Re: GamePad vs adafruit_debouncer

by dastels on Wed Sep 02, 2020 4:02 pm

One of the CircuitPython core team can feel free to elaborate or correct me, but from what I see looking through the gamepad code in https://github.com/adafruit/circuitpython it seem that it polls every so often. The debounce module wait for state to settle. The downside to that is that your code has to call update on the debouncer object(s) frequently in order to get a good response time. E.g. at the top of your main loop, assuming the main loop executes quickly. It has the advantage that it does edge detection for you which is often what you want to do.

Gamepad has the advantage that it works with multiple inputs together whereas you need a Debouncer object for each thing being debounced.

I say "things being debounced" as the debouncer module can be used to debounce more than just digital inputs e.g. the result of a lambda.

So they're quite different. Which one to pick really depends on what you need to do.

Dave

dastels
 
Posts: 3430
Joined: Tue Oct 20, 2015 3:22 pm

Re: GamePad vs adafruit_debouncer

by kevinjwalters on Wed Sep 16, 2020 5:50 pm

Thanks for the info. I've mentioned adafruit_bouncer in one of my guides but GamePad is new to me. I see latter in use for implementation of the newish clue.were_pressed and cp.were_pressed.

kevinjwalters
 
Posts: 735
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.