igorantolic / ai-esp32-rotary-encoder

Easy implement rotary encoder to your application using microcontroler like ESP32
GNU General Public License v2.0
284 stars 70 forks source link

encoder_VccPin must be int8_t, not unsigned integer #50

Closed korianv closed 1 year ago

korianv commented 1 year ago

When calling AiEsp32RotaryEncoder(uint8_t encoder_APin, uint8_t encoder_BPin, uint8_t encoder_ButtonPin, uint8_t encoder_VccPin, uint8_t encoderSteps) with encoder_VccPin = -1 (no Vcc pin), the variable gets the value of 255 instead. This means that in the "begin" function it will try to set to HIGH the pin number 255, generating an error in the serial monitor:

[ 32][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected E (28) gpio: gpio_set_level(226): GPIO output gpio_num error)

The type for this variable should be int8_t (or int16_t) to accommodate the -1.

igorantolic commented 1 year ago

Resolved