Using MenuBackend with a Rotary Encoder

Hi,
I am trying to use a menu system with a rotary encoder.

The idea is to select an item from the menu (by pressing the rotary encoder button) and then dial in a value for that item and then press the button again to set that value. At that point the menu should should return to the root.

Heres what’s happening: I can traverse the menu, I can dial in a value (I’m just doing “Pulse Duration” for the moment) but when I click the button to set the value, it goes back to the root of the menu (as it should) and then selects the first item “Extraction” (which it shouldn’t).

I have been going over this for hours and can’t see where I’m going wrong.

I am doing debouncing in hardware (see attached schematic).

I got the menu code from HERE

I have attached my code because it is too large to post.

Stripped_Down_Menu.ino (8.81 KB)

I don't know a lot about that library, but here is one that was built specifically for rotary encoder and a button and an LCD.

Hi Delta_G, thanks for your reply.

I placed the REBL_UI headers and the LiquidCrystal_SPI_8Bit headers in the Arduino installation’s “libraries” folder and restarted the IDE.

Were your libraries written for pre Arduino 1.0 versions? I ask because I’m getting the error:

/usr/local/arduino-1.8.3/arduino-builder -dump-prefs -logger=machine -hardware /usr/local/arduino-1.8.3/hardware -tools /usr/local/arduino-1.8.3/tools-builder -tools /usr/local/arduino-1.8.3/hardware/tools/avr -built-in-libraries /usr/local/arduino-1.8.3/libraries -libraries /home/rsatchel/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10803 -build-path /tmp/arduino_build_443931 -warnings=none -build-cache /tmp/arduino_cache_735458 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/usr/local/arduino-1.8.3/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/usr/local/arduino-1.8.3/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/usr/local/arduino-1.8.3/hardware/tools/avr -verbose /home/rsatchel/Arduino/REBL_Menu_Example/REBL_Menu_Example.ino
open /usr/local/arduino-1.8.3/libraries/LiquidCrystal_SPI_8Bit/library.properties: permission denied

If I run the Arduino IDE using sudo (I realise this is a no-no), I get:

In file included from /usr/local/arduino-1.8.3/libraries/REBL_UI/REBL_UI.h:16:0,
                 from /home/rsatchel/Arduino/REBL_Menu_Example/REBL_Menu_Example.ino:2:
/usr/local/arduino-1.8.3/libraries/REBL_UI/REBL_Functions.h:26:18: error: variable or field 'displayTime' declared void
 void displayTime(time_t aTime);
                  ^
/usr/local/arduino-1.8.3/libraries/REBL_UI/REBL_Functions.h:26:18: error: 'time_t' was not declared in this scope
/usr/local/arduino-1.8.3/libraries/REBL_UI/REBL_Functions.h:27:19: error: 'time_t' was not declared in this scope
 boolean inputTime(time_t& var);
                   ^
/usr/local/arduino-1.8.3/libraries/REBL_UI/REBL_Functions.h:27:27: error: 'var' was not declared in this scope
 boolean inputTime(time_t& var);
                           ^
REBL_Menu_Example:19: error: 'fun1' was not declared in this scope
   { "display", fun1   }  ,
                ^
REBL_Menu_Example:20: error: 'pressToExit' was not declared in this scope
   {"press", pressToExit   }  ,
             ^
REBL_Menu_Example:21: error: 'pickNumber' was not declared in this scope
   {"enter number", pickNumber   }  ,
                    ^
REBL_Menu_Example:22: error: 'fourLetterWord' was not declared in this scope
   {"enter string", fourLetterWord   }  ,
                    ^
REBL_Menu_Example:23: error: 'enterTime' was not declared in this scope
   {"set time", enterTime   }  ,
                ^
REBL_Menu_Example:24: error: 'showTime' was not declared in this scope
   {"show time", showTime   }
                 ^
/home/rsatchel/Arduino/REBL_Menu_Example/REBL_Menu_Example.ino: In function 'boolean enterTime()':
REBL_Menu_Example:157: error: 'inputTime' cannot be used as a function
       if (inputTime(timeSetTime)) {
                                ^
REBL_Menu_Example:165: error: 'displayTime' was not declared in this scope
       displayTime(now());
                        ^
/home/rsatchel/Arduino/REBL_Menu_Example/REBL_Menu_Example.ino: In function 'boolean showTime()':
REBL_Menu_Example:182: error: 'displayTime' was not declared in this scope
   displayTime(now());  // display the running time
                    ^
exit status 1
'fun1' was not declared in this scope

I used the Time library that was linked to from the Arduino Playground: Time Library

Could you please suggest how to proceed?

Oh I guess I need to do some updating. The Time library has changed. You have to include TimeLib.h now instead of Time.h

You should change out the LCD library for whatever flavor you happen to use. Most of them will use the same set of commands so the code shouldn’t have to change much.

I don’t know. I’ll pull down the newest IDE sometime soon and have a look at it. No time right now. If you fix it then I’d appreciate a pull request or at least a copy of what you did.

You might also look at the TFT color displays, as they are now about the same price as a 2x16 LCD display. The display shown here is a 2.4" display

and costs under $5 (eBay #192163706724).

econjack:
You might also look at the TFT color displays, as they are now about the same price as a 2x16 LCD display. The display shown here is a 2.4" display

and costs under $5 (eBay #192163706724).

Hi EconJack, the image has not come through. The Ebay item number didn't produe anything on Ebay.
Do you have a link for the screen?

Delta_G:
Oh I guess I need to do some updating. The Time library has changed. You have to include TimeLib.h now instead of Time.h

You should change out the LCD library for whatever flavor you happen to use. Most of them will use the same set of commands so the code shouldn't have to change much.

I don't know. I'll pull down the newest IDE sometime soon and have a look at it. No time right now. If you fix it then I'd appreciate a pull request or at least a copy of what you did.

I will have a try today. Thanks for the tips :slight_smile: