EncoderButton icon indicating copy to clipboard operation
EncoderButton copied to clipboard

HW interrupts or polling?

Open clytle374 opened this issue 10 months ago • 1 comments

I'm using this on a ATmega644P processor using the MightCore board and board manager. Here is my used pins and how they are set up.

`*** rotary encoder setup ***************** #define ROTARY_PIN1 10 //D16 PC0 PCINIT16 SCA

#define ROTARY_PIN2 11 //D17 PC1 PCINIT17 SCL

#define BUTTON_PIN A1 //D25 PA1 PCINIT1 ADC1 `

This setup works great except for I seem to lose a button press randomly. I do not understand if this is being used interrupt or polling. Nor do I understand the code enough figure it out. Does the library somewhere look at assigned pins and decided if they are a HW interrupt? Or how is that handled?

clytle374 avatar Apr 12 '24 05:04 clytle374

The button press is handled via polling, not interrupts. It uses Thomas Fredericks' Bounce2 library for button debouncing. This works great for most buttons but you may need to play with setDebounceInterval() to suit your hardware. It might also be that specifying the analogue pin A1 invokes some internal ADC magic that does not play well with a digital input. You could try specifying pin 25 instead of A1.

Stutchbury avatar Apr 12 '24 12:04 Stutchbury

Thanks for the response. Somehow I missed the notification of your reply. I later found it was an issue with my code.

clytle374 avatar May 19 '24 18:05 clytle374