ruiseixasm / Versatile_RotaryEncoder

Library that offers a versatile Rotary Encoder usage!
GNU General Public License v3.0
11 stars 2 forks source link

Feature Request: Invert Switch #3

Closed underwoodblog closed 2 years ago

underwoodblog commented 2 years ago

I can confirm that your Library works with Pi Pico. I have a rotary board that outputs 3V3 on switch press and I got inverted output from your library. Tried to set pin mode from PULLUP to INPUT and PULLDOWN but still reads the switch inverted. Would be nice to have a define or config to invert the switch read function. Thanks.

underwoodblog commented 2 years ago

encoderBits = !digitalRead(pin_sw) << 2 | digitalRead(pin_clk) << 1 | digitalRead(pin_dt);

ruiseixasm commented 2 years ago

I can confirm that your Library works with Pi Pico. I have a rotary board that outputs 3V3 on switch press and I got inverted output from your library. Tried to set pin mode from PULLUP to INPUT and PULLDOWN but still reads the switch inverted. Would be nice to have a define or config to invert the switch read function. Thanks.

Hi, the switch works when +vcc goes to ground. Seems that you are requesting a function to invert that behavior, meaning the switch being triggered from ground to +vcc instead. Is this what you want?

ruiseixasm commented 2 years ago

encoderBits = !digitalRead(pin_sw) << 2 | digitalRead(pin_clk) << 1 | digitalRead(pin_dt);

Hi, I just did an update (1.2.1) that has a function called setInvertedSwitch that allows the requested Invert Switch configuration.

Regards

underwoodblog commented 2 years ago

Thanks! That is what I wanted, so I don't have to edit the library and have to wonder why my code doesn't work after an update of the library. Btw. great and easy to use encoder library that does what I need! Can be closed!

Regards