Very helpful library, thank you for making it and sharing. One issue that I ran into is that the particular pins that I attached my encoder to were configured somewhere else as outputs. It may be a good idea to explicitly configure the GPIOs for encoder input as inputs in the begin function to avoid this confusion for others.
void PioEncoder::begin(){
gpio_set_dir(pin, GPIO_IN);
gpio_set_dir(pin+1, GPIO_IN);
if (!not_first_instance){
offset = pio_add_program(pio, &quadrature_encoder_program);
}
not_first_instance=true;
if (sm==-1){
sm = pio_claim_unused_sm(pio, true);
}
sm=sm;
quadrature_encoder_program_init(pio,sm,offset,pin,max_step_rate);
}
Very helpful library, thank you for making it and sharing. One issue that I ran into is that the particular pins that I attached my encoder to were configured somewhere else as outputs. It may be a good idea to explicitly configure the GPIOs for encoder input as inputs in the begin function to avoid this confusion for others.