RGB LCD Shield #772 menu question
Moderators: adafruit_support_bill, adafruit

RGB LCD Shield #772 menu question

by 99Valkyrie on Sun Jan 13, 2013 5:04 pm

Hello,

I recently purchased the Adafruit shield (Blue/White monochrome) noted in the subject above. Got it all put together and it displays the Hello world sketch just fine. I can change the buttons so they act/report differently (only slightly modifying the existing code. I purchased this particular kit because it only uses the two pins which leaves me many more for other things.

My question is this. Is there a tutorial or example of a simple menu system? By this I mean, my Uno would start with a "splash" screen then present the top level choice, let's say "TEST 1" first with one or two more choices below accessed by hitting the down button. If TEST 1 is chosen 2 "children" would be available, RUN and STOP. I envision pressing the LEFT button would exit back to the top level. Secondary levels (below TEST 1) could be reached by pressing the down buttons to continue through the menu system choosing different items/functions.

Like I said, just looking for either a few tutorials or some examples so that I can learn to use this shield effectively.

I would appreciate any advice and/or suggestions. Thanks.
99Valkyrie
 
Posts: 2
Joined: Sun Jan 13, 2013 4:48 pm

Re: RGB LCD Shield #772 menu question

by adafruit_support_rick on Sun Jan 13, 2013 6:36 pm

The main loop of the 'Hello world" example code is an example of a menu system. What it does is to continually read the button status, and it modifies the display according to which buttons are pressed. One thing that's a little different about it, though, is that it allows multiple buttons to be pressed at once. For a regular menu system, you would probably want to use a switch statement, instead of a series of if statements, like so:
Code: Select all | TOGGLE FULL SIZE
 uint8_t buttons = lcd.readButtons();
 switch (buttons) {
    case (BUTTON_DOWN):
      <scroll menu down one selection>
      break;
    case (BUTTON_UP):
      <scroll menu up one selection>
      break;
    case (BUTTON_LEFT):
      <move menu up one level>
      break;
    case (BUTTON_RIGHT):
      <move menu down one level>
      break;
    case (BUTTON_SELECT):
      <execute the currently displayed menu item>
      break;
    default:
      break;
 }


So, it's up to you to design the menu. Things to do when you move up, down, right or left are to figure out what menu state you're moving to, display the new menu text, and keep track of where you are in the menu. On a select, you're going to call some function to preform the desired action.
User avatar
adafruit_support_rick
 
Posts: 11689
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: RGB LCD Shield #772 menu question

by 99Valkyrie on Mon Jan 14, 2013 5:43 am

Thank you for your time, explanation and an example. I'm still rather new at this so I did not "see" a menu in the "Hello world" example. I'm going to go back, take another loo0k at it and try to grasp what is going on in that code.

In your example of the switch statement, I'll need to do some more reading to try to understand how that functions. At face value it seems relatively easy but I need to gain more understanding. I prefer to "see" what is happening in the coding of these neat machines.

Again, many thanks.
99Valkyrie
 
Posts: 2
Joined: Sun Jan 13, 2013 4:48 pm

Re: RGB LCD Shield #772 menu question

by alpha2 on Sat Feb 02, 2013 8:51 pm

I'm a total nube to Arduino and I purchased an Arduino Mega 2560 R3 and Adafruit shield with a 2x16 blue and white display.

Where can I find the "Hello world" to get started?

Thanks in advance
alpha2
 
Posts: 3
Joined: Thu Jan 31, 2013 5:32 pm

Re: RGB LCD Shield #772 menu question

by adafruit_support_rick on Sun Feb 03, 2013 10:22 am

The example code is included with the library download. See this page of our Tutorial.

If you've already downloaded and installed the library, open the File menu in the Arduino IDE, and select Examples. In the popup, select Adafruit_RGBLCD, and then select HelloWorld.
User avatar
adafruit_support_rick
 
Posts: 11689
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: RGB LCD Shield #772 menu question

by alpha2 on Mon Feb 04, 2013 5:53 pm

Thanks for the link and info.
I've read through the FAQs for the location of the library and I'm wondering if there's a compatibility issue with Arduino side version 1.0.3. The instructions say to place the library in the sketch folder via the "Show Sketch Folder" function. I can create the folder and copy the files to the new location but they don't seem to be saved or at least not visible if I look for them after closing and restarting the IDE.
Where am I going wrong here?
alpha2
 
Posts: 3
Joined: Thu Jan 31, 2013 5:32 pm

Re: RGB LCD Shield #772 menu question

by alpha2 on Mon Feb 04, 2013 6:38 pm

Please disregard the previous post.
I re-installed the libraries in the correct location and the display is now working properly.

Thanks for your help and patience.
Maybe now I can start moving forward.

Jim
alpha2
 
Posts: 3
Joined: Thu Jan 31, 2013 5:32 pm

Re: RGB LCD Shield #772 menu question

by adafruit_support_rick on Mon Feb 04, 2013 6:49 pm

Did you rename the library folder you downloaded?
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_RGBLCDShield. Check that the Adafruit_RGBLCDShield folder contains Adafruit_RGBLCDShield.cpp and Adafruit_RGBLCDShield.h


I'm not sure where you saw the instruction to place the library in the sketch folder via the "Show Sketch Folder" function? That isn't going to show you the right place.
The library folder should go into the /libraries folder inside the sketchbook folder. Open the preferences window of the IDE (File:Preferences in Windows, Arduino:Preferences on MacOSX). You'll see the path to the 'Sketchbook location'.

Don't change the path. Close the IDE and go to the sketchbook folder. There should already be a folder in there called 'libraries'. Your LCD library folder goes inside of there.
User avatar
adafruit_support_rick
 
Posts: 11689
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: RGB LCD Shield #772 menu question

by adafruit_support_rick on Mon Feb 04, 2013 6:50 pm

alpha2 wrote:I re-installed the libraries in the correct location and the display is now working properly.


Great!
User avatar
adafruit_support_rick
 
Posts: 11689
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: RGB LCD Shield #772 programming question

by del618 on Mon Aug 05, 2013 11:56 am

I downloaded the Adafruit_RGBLShield and renamed it as described. When I try to compile the program it gives me the following line; "Adafruit_RGBLShield::Adafruit_RGBLShield(){
Adafruit_RGBLShield has not been declared.
How do I overcome this error? It is very frustrating for me to download something that does not work correctly.

Thanks D.
del618
 
Posts: 5
Joined: Thu Jun 27, 2013 6:27 pm

Re: RGB LCD Shield #772 menu question

by adafruit_support_bill on Mon Aug 05, 2013 12:24 pm

Did you install it as described here? : http://learn.adafruit.com/adafruit-all- ... nstall-use
User avatar
adafruit_support_bill
 
Posts: 29218
Joined: Sat Feb 07, 2009 9:11 am

Re: RGB LCD Shield #772 menu question

by adafruit_support_rick on Mon Aug 05, 2013 4:07 pm

del618 wrote:"Adafruit_RGBLShield::Adafruit_RGBLShield(){
Adafruit_RGBLShield has not been declared.

The library should be named "Adafruit_RGBLCDShield", not "Adafruit_RGBLShield"
User avatar
adafruit_support_rick
 
Posts: 11689
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: RGB LCD Shield #772 menu question

by del618 on Sat Aug 10, 2013 3:29 pm

I reloaded it and it Works now.

Thanks

del618
del618
 
Posts: 5
Joined: Thu Jun 27, 2013 6:27 pm

Re: RGB LCD Shield #772 menu question

by cekuz on Mon Nov 11, 2013 4:40 am

adafruit_support_rick wrote:The main loop of the 'Hello world" example code is an example of a menu system. What it does is to continually read the button status, and it modifies the display according to which buttons are pressed. One thing that's a little different about it, though, is that it allows multiple buttons to be pressed at once. For a regular menu system, you would probably want to use a switch statement, instead of a series of if statements, like so:
Code: Select all | TOGGLE FULL SIZE
 uint8_t buttons = lcd.readButtons();
 switch (buttons) {
    case (BUTTON_DOWN):
      <scroll menu down one selection>
      break;
    case (BUTTON_UP):
      <scroll menu up one selection>
      break;
    case (BUTTON_LEFT):
      <move menu up one level>
      break;
    case (BUTTON_RIGHT):
      <move menu down one level>
      break;
    case (BUTTON_SELECT):
      <execute the currently displayed menu item>
      break;
    default:
      break;
 }


So, it's up to you to design the menu. Things to do when you move up, down, right or left are to figure out what menu state you're moving to, display the new menu text, and keep track of where you are in the menu. On a select, you're going to call some function to preform the desired action.


Hi all! I'm new and I need some help with the code to manage a menu and execute commands for a time lapse dolly.
Where does the code you suggest should be written? In the void setup? And moreover, how can I add the command line (i.e. "motor go forward") and manage input variables using the LCD shield such us direction, speed and delay of execution?

Thank you very much
cekuz
 
Posts: 6
Joined: Sat Nov 09, 2013 4:57 pm

Re: RGB LCD Shield #772 menu question

by adafruit_support_bill on Mon Nov 11, 2013 7:19 am

Where does the code you suggest should be written? In the void setup?

No. setup() only gets executed once on startup. If you need to process many commands, you should do it in the loop() function which gets executed over and over again.

how can I add the command line (i.e. "motor go forward") and manage input variables using the LCD shield such us direction, speed and delay of execution?

This tutorial might be a better example to look at. It uses the LCD shield to enter control parameters: http://learn.adafruit.com/sous-vide-pow ... o/software
User avatar
adafruit_support_bill
 
Posts: 29218
Joined: Sat Feb 07, 2009 9:11 am