Skip to content

Clickencoder and new EPS32 api timers... #447

@DrTron

Description

@DrTron

All,
I've used ArduinoMenu on an ESP32 with an encoder successfully with a monochrome display, but am now upgrading to a color TFT.
As some time has passed, some ESP32 has changed.
I am able to get the example here working in that it displays the menu and I can control it via serial console. But ultimately I need my encoder back.
Now ArduinoMenu seems to prefer Clickencoder, which requires a hardware interrupt and a timer to read the encoder.
This is where I'm stuck. The "old code" in the above example for the timer is this:

timer = timerBegin(0, 80, true);
  timerAttachInterrupt(timer, &onTimer, true);
  timerAlarmWrite(timer, 1000, true);
  timerAlarmEnable(timer);

That doesn't compile with the new (3.x) ESP32 api anymore, apparently the replacement is something like this:

timer = timerBegin(1000);
timerAttachInterrupt(timer, &onTimer);
timerAlarm(timer, 1000, true, 0);  

But I get no response from the encoder.
As an alternative there is an apparently good library named Ai Encoder, which includes it's own interrupts for reading the encoder and works well. However, I'm not entirely sure how to envoke and control the menu with that library...even the example for ArduinoMenu contains some code I don't fully understand...

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions