luni64 / EncoderTool

The EncoderTool is a library to manage and read out rotary encoders connected either directly or via multiplexers to ARM based boards. Encoder push buttons are supported. Callback functions can be attached to encoder changes and button presses to allow for event driven applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with TeensyLC

bimac opened this issue · comments

Hi luni64,

I have a strange issue with EncoderTool on TeensyLC.

Here's the MWE:

#include <EncoderTool.h>

using namespace EncoderTool;
PolledEncoder enc;

void setup() {
  Serial.begin(9600);
  enc.begin(5, 6, 4, CountMode::half, INPUT_PULLUP);
}

void loop() {
  enc.tick();
  if(enc.valueChanged())
    Serial.println(enc.getValue());
}

On Teensy 3.2 this works perfectly fine: each detent will increment/decrement by 1. On TeensyLC, however, it will keep incrementing like crazy (without turning the encoder) with each iteration of loop() - but only for every other detent. I'm using this encoder. Is there anything that comes to mind?

Cheers!

This looks weird. Unfortunately I'm currently not at home and don't have a LC with me. I'll have a look on Sunday.

Thanks a lot!

I can reproduce this. It looks like there is a bug in the direct read code for the T-LC. I'll have a closer look later. As a quick workaround you can do the following:

Change line 46 in the library file cores.h as shown here:
image

This disables the direct read code for the T-LC so that it falls back to a standard digitalRead/digitalWrite which works here.
Can you please check if this works for you as well?

Thanks for looking into this! I can confirm that the workaround makes the encoder perform as expected.

Great, I'll look for a permanent solution asap

Thanks for the fix Lutz! It works as expected now.

Great, let me know if you find something else