alanesq / BasicOLEDMenu

A very simple menu system using an oled and rotary encoder
GNU General Public License v3.0
49 stars 10 forks source link

Error: invalid rotary encoder pin state #2

Closed andrewbpowers closed 2 years ago

andrewbpowers commented 3 years ago

Hello!

First of all, thank you for your example!

I get the following errors in the serial monitor: Error: invalid rotary encoder pin state - prev=0,0 new=0,1

However, navigating through the menu works. Any idea why this happens? I use the KY040 Rotary Encoder (https://www.ebay.co.uk/itm/274296632950). Thanks in advance for any tip and help! :-)

Take care...

andrewbpowers commented 3 years ago

...

andrewbpowers commented 3 years ago

?

alanesq commented 3 years ago

prev=0,0 new=0,1

Hi,

It is saying that the previous reading from the encoder was 0 and 0 and the current is 0 and 1 which never happens on mine but it could just be that yours is slightly different? if it is working I wouldn't worry about it just comment out the line

If you wished you could modify the line: else if (serialDebug) Serial.println("Error: invalid rotary encoder pin state - prev=" + String(encoderPrevA) + "," + String(encoderPrevB) + " new=" + String(pinA) + "," + String(pinB));" to: Serial.println(" Encoder pin state - prev=" + String(encoderPrevA) + "," + String(encoderPrevB) + " new=" + String(pinA) + "," + String(pinB)); temporarily just to see how your encoder is behaving and modify the code to suit.

andrewbpowers commented 3 years ago

Hello Alan!

Thank you very much for your feedback and the helpful informations.

I really like your menu! :-)

One more question… sorry! ;-)

How can I change the “staticMenu” to “dynamic” or better said, to a mixture of both. So, for example, a time is displayed with seconds or a measured value AND you can switch to another menu via a menu item or change the display or switch off completely!?

Stay healthy and take care!

alanesq commented 3 years ago

Hi,

If you have a look at my BasicWebserver sketch I have an oled option which uses this menu and shows how to switch between different menus (main_menu and Menu2 in this case). https://github.com/alanesq/BasicWebserver I think I have developed this menu a bit more there and have not got round to updating this one yet

You could add the time etc. just by writing direct to the display on top of the menu with commands such as: display.setCursor(0, 0); display.print("hello"); display.display();

andrewbpowers commented 3 years ago

Very big thank you! 👍 I will have a look at it and try your solutions.

The main problem I had so far was that e.g. in the "Display off" example something is displayed, but the loop does not continue to run and thus no real-time information could be displayed or a menu. I have e.g. set a value to "1" by selecting a menu item. In the loop then runs a "blink without delay", until the previous menu item was selected again. This works quite well. However, I do not know how I can then display in a "menu", how often, for example, the LED has blinked. I hope that was somehow understandable! ;-)

alanesq commented 2 years ago

You may like to have a look at the new version I have just uploaded as I have completely re-written it so that it is none blocking.
i.e. the menus can be used without it stopping other tasks from continuing

andrewbpowers commented 2 years ago

Hello Alan!

Thank you for the hint. That sounds great. I will definitely have a look at it. Thanks a lot!

Take care

alanesq commented 2 years ago

I think this error is just caused by bouncing in the switch and so I have removed the error message from the sketch

andrewbpowers commented 2 years ago

Understand! Thank you very much, for your efforts! :-)