Register / Login  |  Desktop view  |  Jump to bottom of page

tcMenu Arduinio library » Rotary Encoder strange behavior

Author: bitz
01/04/2020 09:22:41
Hi,

I'm working with a rotary encoder on a adafruit ItsyBitsy m0 express (SAMD21).
The Encoder is a keyes KY-040 module, display an china OLED 128x64 / i2c.
Working fine with P.Stoffregens Endocder LIB.

Using tcmenu completely generated (from one of the examples with adafruit gfx)
i get very unpredictable results, sometimes it seems te menu is reacting even if the encoder is just idle.
If i turn the encoder the menu aktivates mostly one of the following menuitems, but not allways the next.
Sometimes editing of an item gets activated and disabled again.

If i try with the buttonRotaryEndcoder example from ioabstraction the results are OK, a bit slow though.
I loaded the new 1.4.11 of ioabstractions, turned of HWACCEL, but did not help.

I enabled logging and started the programm, but did not touch the encoder,
and from there on i was lost.

I would appreciate some help, let me know if you need something (besides the log below)

Here is what i got:

11:16:27.026 -> 991478:setCurrentMenu: 1
11:16:27.026 -> 991478:valueChanged V=0
11:16:27.191 -> 991628:Textbounds (y1, w, h): 0 30 8
11:16:27.191 -> 991628:Redraw all, new item height 10
11:16:27.191 -> 991629:Render title, fontMag: men 2
11:16:27.191 -> 991629:Textbounds (y1, w, h): 0 36 16
11:16:27.191 -> 991629:titleHeight, fontYStart: 19 2
11:16:27.191 -> 991631:Item Active
11:16:27.191 -> 991631:Printing menu item (name, ypos, drawingPositionY)Hall 21 22
11:16:27.191 -> 991632:Textbounds (y1, w, h): 21 12 8
11:16:27.191 -> 991632:Value 2%
11:16:27.191 -> 991633:Item Normal
11:16:27.191 -> 991633:Printing menu item (name, ypos, drawingPositionY)Living 31 32
11:16:27.191 -> 991634:Textbounds (y1, w, h): 31 12 8
11:16:27.191 -> 991635:Value 0%
11:16:27.191 -> 991635:Item Normal
11:16:27.191 -> 991635:Printing menu item (name, ypos, drawingPositionY)Kitchen 41 42
11:16:27.191 -> 991636:Textbounds (y1, w, h): 41 12 8
11:16:27.191 -> 991637:Value 0%
11:16:27.191 -> 991637:Item Normal
11:16:27.191 -> 991638:Printing menu item (name, ypos, drawingPositionY)On Alm 51 52
11:16:27.191 -> 991638:Textbounds (y1, w, h): 51 36 8
11:16:27.191 -> 991639:Value All On
11:16:27.919 -> 992368:valueChanged V=1
11:16:27.985 -> 992417:Item Normal
11:16:27.985 -> 992417:Printing menu item (name, ypos, drawingPositionY)Hall 21 22
11:16:27.985 -> 992418:Textbounds (y1, w, h): 21 12 8
11:16:27.985 -> 992418:Value 2%
11:16:27.985 -> 992419:Item Active
11:16:27.985 -> 992419:Printing menu item (name, ypos, drawingPositionY)Living 31 32
11:16:27.985 -> 992420:Textbounds (y1, w, h): 31 12 8
11:16:27.985 -> 992420:Value 0%
11:16:28.912 -> 993349:setCurrentMenu: 1
11:16:28.912 -> 993349:valueChanged V=0
11:16:29.011 -> 993449:Textbounds (y1, w, h): 0 30 8
11:16:29.011 -> 993449:Redraw all, new item height 10
11:16:29.011 -> 993450:Render title, fontMag: men 2
11:16:29.011 -> 993450:Textbounds (y1, w, h): 0 36 16
11:16:29.011 -> 993450:titleHeight, fontYStart: 19 2
11:16:29.011 -> 993452:Item Active
11:16:29.011 -> 993452:Printing menu item (name, ypos, drawingPositionY)Hall 21 22
11:16:29.011 -> 993453:Textbounds (y1, w, h): 21 12 8
11:16:29.011 -> 993453:Value 2%
11:16:29.011 -> 993454:Item Normal
11:16:29.011 -> 993454:Printing menu item (name, ypos, drawingPositionY)Living 31 32
11:16:29.011 -> 993455:Textbounds (y1, w, h): 31 12 8
11:16:29.011 -> 993456:Value 0%
11:16:29.011 -> 993456:Item Normal
11:16:29.011 -> 993456:Printing menu item (name, ypos, drawingPositionY)Kitchen 41 42
11:16:29.011 -> 993457:Textbounds (y1, w, h): 41 12 8
11:16:29.011 -> 993458:Value 0%
11:16:29.011 -> 993458:Item Normal
11:16:29.011 -> 993459:Printing menu item (name, ypos, drawingPositionY)On Alm 51 52
11:16:29.011 -> 993459:Textbounds (y1, w, h): 51 36 8
11:16:29.011 -> 993460:Value All On
11:16:29.309 -> 993738:Item Editing
11:16:29.309 -> 993738:Printing menu item (name, ypos, drawingPositionY)Hall 21 22
11:16:29.309 -> 993739:Textbounds (y1, w, h): 21 12 8
11:16:29.309 -> 993739:Value 2%
11:16:29.309 -> 993740:Item Normal
11:16:29.309 -> 993740:Printing menu item (name, ypos, drawingPositionY)Living 31 32
11:16:29.309 -> 993741:Textbounds (y1, w, h): 31 12 8
11:16:29.309 -> 993741:Value 0%
11:16:29.309 -> 993742:Item Normal
11:16:29.309 -> 993742:Printing menu item (name, ypos, drawingPositionY)Kitchen 41 42
11:16:29.309 -> 993743:Textbounds (y1, w, h): 41 12 8
11:16:29.309 -> 993744:Value 0%
11:16:29.309 -> 993744:Item Normal
11:16:29.309 -> 993744:Printing menu item (name, ypos, drawingPositionY)On Alm 51 52
11:16:29.309 -> 993745:Textbounds (y1, w, h): 51 36 8
11:16:29.309 -> 993746:Value All On
11:16:30.500 -> 994934:valueChanged V=0
11:16:30.566 -> 995024:Item Active
11:16:30.566 -> 995024:Printing menu item (name, ypos, drawingPositionY)Hall 21 22
11:16:30.566 -> 995025:Textbounds (y1, w, h): 21 12 8
11:16:30.566 -> 995025:Value 2%
11:16:30.566 -> 995026:Item Normal
11:16:30.566 -> 995026:Printing menu item (name, ypos, drawingPositionY)Living 31 32
11:16:30.566 -> 995027:Textbounds (y1, w, h): 31 12 8
11:16:30.566 -> 995027:Value 0%
11:16:30.566 -> 995028:Item Normal
11:16:30.566 -> 995028:Printing menu item (name, ypos, drawingPositionY)Kitchen 41 42
11:16:30.599 -> 995029:Textbounds (y1, w, h): 41 12 8
11:16:30.599 -> 995030:Value 0%
11:16:30.599 -> 995030:Item Normal
11:16:30.599 -> 995030:Printing menu item (name, ypos, drawingPositionY)On Alm 51 52
11:16:30.599 -> 995031:Textbounds (y1, w, h): 51 36 8
11:16:30.599 -> 995032:Value All On
11:16:30.864 -> 995310:Item Editing
11:16:30.864 -> 995310:Printing menu item (name, ypos, drawingPositionY)Hall 21 22
11:16:30.864 -> 995311:Textbounds (y1, w, h): 21 12 8
11:16:30.864 -> 995311:Value 2%
11:16:30.864 -> 995312:Item Normal
11:16:30.864 -> 995312:Printing menu item (name, ypos, drawingPositionY)Living 31 32
11:16:30.864 -> 995313:Textbounds (y1, w, h): 31 12 8
11:16:30.864 -> 995313:Value 0%
11:16:30.864 -> 995314:Item Normal
11:16:30.864 -> 995314:Printing menu item (name, ypos, drawingPositionY)Kitchen 41 42
11:16:30.864 -> 995315:Textbounds (y1, w, h): 41 12 8
11:16:30.864 -> 995316:Value 0%
11:16:30.864 -> 995316:Item Normal
11:16:30.864 -> 995316:Printing menu item (name, ypos, drawingPositionY)On Alm 51 52
11:16:30.864 -> 995317:Textbounds (y1, w, h): 51 36 8
11:16:30.864 -> 995318:Value All On



Author: davetcc
01/04/2020 12:38:22
This is odd behaviour. We have a SAMD board but we are using the rotary encoder connected via an IO expander due to a lack of pins available.

It seems to be like the encoder or button is unstable for some reason, but I will try connecting an encoder directly to the MKR board I have and reply once I've managed to test it. It's not the Adafruit board you mentioned, but is a SAMD based Arduino MKR board.

Could you let me know what pins you've wired the encoder and button to and I'll try and recreate something as close as I can?

Could you check that the pins you've used for the switch and encoder don't conflict with any hardware serial devices such as your display, or anything else that may be inbuilt? We've seen this cause major instability a few times now.

Author: bitz
01/04/2020 15:09:43
Encoder button is on 10
Encoder PinA on 7 and Encoder PinB on 9

Adafriut is giving hints on how to port code.
There are issues with pin in/output config (have to use INPUT_PULLUP) and the timers.
https://forums.adafruit.com/viewtopic.php?f=62&t=163006

Giving the pullups a thought, i played around with an external pullup on the "button" pin (No 10).
And stumbled across the power supply for the encoder which i connected to 5v (which is unregulated).
The logic on the pins is 3.3...

I corrected that and with a pullup on the button (10k on 3.3v) the performance was much better, nearly usable.
I have a Teensy LC which is a SAMD21 too, will try that later today.

Still one problem: clicking on the submenus just leads to the first menu item...

Regards & thank you for the great help !
bitz

Author: davetcc
02/04/2020 07:59:55
 
Still one problem: clicking on the submenus just leads to the first menu item...


We did recently fix an issue in 1.3.6 where if the first item in a menu was a submenu, it presented that submenu rather than the main menu. Is that the issue you have? If so, this is already fixed on master, and you could try that to see if it works for you. It will be released soon.

Otherwise, if that is not the issue, please could you share your designer project structure, so we can take a look. If you could create the simplest structure that recreates the issue, that would be great.

Author: bitz
06/04/2020 11:23:37
Hi,

just a little feedback :

Submenus are OK.

The k-040 encoder module was rather not-so-good.
When I use a solo encoder (no external pull-ups and only 0.1uF kerkos to gnd) the results are very good.

...and I will leave the teensy LC in its package, the itsybitsy is much better equipped with memory of all sorts...

Regards,
bitz

Author: davetcc
07/04/2020 10:23:31
Many thanks for the feedback. Glad that's sorted.

If you do get hit by the submenu in the initial position problem, there's a fix on master of the library.

Dave.




Register / Login  |  Desktop view  |  Jump to top of page