davetcc / tcMenu

Menu library for Arduino, mbed and ESP with designer UI and remote control capabilities.
https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/
Apache License 2.0
271 stars 25 forks source link

Encoder callback behaviour when taken over display #468

Closed tomelgato closed 1 month ago

tomelgato commented 2 months ago

TCmenu 4.2

After taking over the display with renderer.takeOverDisplay(myDisplayCallback);

it calls

void myDisplayCallback(unsigned int encodervalue, RenderPressMode clicked) {

}

but i just get encodervalue 0-X (X=number of submenu items from where the display was taken by a ActionMenuItem callback) and clicked stays on 1 (clicked) or 2 (held) till i turn the encoder again, then clicked is 0 again.

do i miss something?

EDIT: changing the precision works

switches.getEncoder()->changePrecision(100,0,false,1);

this also sets back the clicked flag, so its working like that. The Q is ... is this the right way to do it?

tomelgato commented 2 months ago

Can i poll the encoder directly when taken over the display? I would need a quicker update frequency then 1/5 seconds.

davetcc commented 2 months ago

Can i poll the encoder directly when taken over the display? I would need a quicker update frequency then 1/5 seconds.

I've never tried it but I cannot see why not. You can even I think check if the button is pressed using polling.

davetcc commented 2 months ago

Can you please raise things like this as discussions, and not overwrite the issue template. You've done it several times now, those templates are there for a reason, to help us identify real problems from questions. It is hard enough to run a project of this size even when everyone follows the rules.

tomelgato commented 2 months ago

Ok, no problem. I did see it as a bug, cause the callback is called over and over again with the same values. I expected to get just new values/states.