View unanswered posts | View active topics It is currently Fri Nov 21, 2014 8:05 pm






Reply to topic  [ 12 posts ] 
LCD Programming 
Author Message
Rookie

Joined: Tue Oct 11, 2011 3:00 pm
Posts: 4
Post LCD Programming
Would anyone like to share some of the LCD programming code? The samples provided don't do to much. I'd like to use the three buttons to select between different autonomous programs or use the panel to provide battery charge feedback.

Thanks
Jim M.


Tue Dec 06, 2011 9:42 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: LCD Programming
I don't have ROBOTC in front of me right now, so I can tell you how to find the functions that you're looking for. If you're in super user mode, then you should be able to see all the functions in the function library. The functions for reading from and writing to the LCD are (I think) under 'display' or 'buttons'.

_________________
sudo rm -rf /


Tue Dec 06, 2011 10:18 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 406
Post Re: LCD Programming
They are in the Display category.

For a better example in the Sample Programs, go to the Advanced folder and open "Cortex View Mode.c".

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Tue Dec 06, 2011 11:18 am
Profile
Rookie

Joined: Fri Jan 20, 2012 1:20 am
Posts: 6
Post Re: LCD Programming
is there any way to use and lcd displays button (left, center, right) to restart a downloaded program in a vex cortex mini controller and to restart the program to the beginning without a computer or have an open robot c programming assistant near by? (i need a program for it!)

also, is there a was to use a combination of buttons, for instance left,right,center. to allow robot c to run a program using LCD display, while keeping original program. basically, have the ability to store and run muti programs, and run them using LCD display, button combinations. Thanks! any help will be greatly appreciated


Fri Jan 20, 2012 1:26 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 406
Post Re: LCD Programming
I would recommend checking out the "Secret Code to Start" sample program, found by going to File > Open Sample Program > Natural Language > LCD Buttons > Secret Code to Start. You will also want ROBOTC to be in Natural Language mode for this code to compile.

The standard ROBOTC code can be used by right-clicking on any of the "untilButtonPress" commands and choosing to see the definition/declaration. You should be able to then borrow that code to carry out some of the program control ideas you have.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Tue Jan 24, 2012 3:34 pm
Profile
Rookie

Joined: Fri Jan 20, 2012 1:20 am
Posts: 6
Post Re: LCD Programming
can i please acquire some with a sample program in robotc the program is VEX lcd test in the advanced folder of sample programs, anyways i need some help to understand the information given, such as how can i incorporate this into my program, and also how can i use the lcd's buttons to create a button combination and will run certain sections of programs inserted in the micro controller when the combinations are processed. any help will be appreciated! thanks!!


Mon Feb 20, 2012 7:42 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: LCD Programming
We have written LCD code for the NXT but I would think it should be similar enough to be used for Cortex with minimal changes.
http://proj.titanrobotics.net/hg/Ftc/20 ... lib/menu.h


Tue Feb 21, 2012 8:17 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: LCD Programming
MHTS wrote:
We have written LCD code for the NXT but I would think it should be similar enough to be used for Cortex with minimal changes.
http://proj.titanrobotics.net/hg/Ftc/20 ... lib/menu.h

Not really, the LCD for the cortex doesn't let you do many of the things that the NXT does. You can only print and clear strings from two lines (and turn the backlight on and off). No setting pixels, no drawing lines, nada. While your background work on the menu might remain fairly unchanged, the entire user interface would have to change.

tlrmrtn, the variable nLCDButtons stores the value of which button is pressed. According to the program that jbflot directed you to:
leftButton = 1;
centerButton = 2;
rightButton = 4; //I haven't used the LCD in a while, so I don't know if this is a typo, or the value really is 4 instead of 3

Is that helpful information for you? Do you understand how to print to the LCD? We could help you a lot more if you showed us what you already have done, and what exactly you're having problems with.

_________________
sudo rm -rf /


Tue Feb 21, 2012 11:38 am
Profile
Rookie

Joined: Fri Jan 20, 2012 1:20 am
Posts: 6
Post Re: LCD Programming
Thank you both of your help


Wed Feb 22, 2012 3:07 am
Profile
Novice
User avatar

Joined: Sat Jul 10, 2010 3:06 pm
Posts: 86
Location: Roanoke, VA
Post Re: LCD Programming
I've written a blog post about this topic...
http://robodesigners.blogspot.com/2012/ ... obotc.html

If it's unclear, please let me know... ;)

//Andrew

_________________
Check out my website! www.RoboDesigners.com

VRC Team 2190

Twitter: @RoboDesigners


Sun Mar 04, 2012 3:32 pm
Profile WWW
Rookie

Joined: Fri Jan 27, 2012 6:57 pm
Posts: 40
Post Re: LCD Programming
Edit: Good tutorial RoboDesigners! Your code would do the trick just as well.

Quote:
leftButton = 1;
centerButton = 2;
rightButton = 4; //I haven't used the LCD in a while, so I don't know if this is a typo, or the value really is 4 instead of 3

Nope not a typo! This lets you detect if multiple buttons are being pressed by adding up the values from the different buttons. So:

The variable nLCDButtons, as magicode said, contains the values for the different LCD Buttons. If you read the variable and it equals 0, that means that no buttons are pressed. If you read the variable and it does not equal 0, that means that at least one of the buttons is pressed.
The other button readings are as follows:

nLCDButtons = 1 - Left Button is Pressed
nLCDButtons = 2 - Center Button is Pressed
nLCDButtons = 3 - Left and Center Buttons are Pressed
nLCDButtons = 4 - Right Button is Pressed
nLCDButtons = 5 - Right and Left Buttons are Pressed
nLCDButtons = 6 - Right and Center Buttons are Pressed
nLCDButtons = 7 - Right, Center, and Left Buttons are Pressed

The reason for this is that each button represents a certain bit. In binary, this looks like:
Code:
                   Right Button, Center Button, Left Button
                   | ,----------------'             |
                   |/,------------------------------'
nLCDButtons =      |||
nLCDButtons =    0bxxx
nLCDButtons =    0b000
nLCDButtons =    0b001
nLCDButtons =    0b010
nLCDButtons =    0b011
nLCDButtons =    0b100
nLCDButtons =    0b101
nLCDButtons =    0b110
nLCDButtons =    0b111


I have implemented a menu system using VEX in my Team's code.
It works something like this:
Code:
int LeftDisplayButton;
int CenterDisplayButton;
int RightDisplayButton;
int LeftDisplayButtonPressed;
int CenterDisplayButtonPressed;
int RightDisplayButtonPressed;
int CurrentMenuItem;
int TotalMenuItems = 7;
int DisplayNeedsRefreshing;
int ActivateMenuItem;
int ButtonBitMap;
string MainMenu[7] = {"New", "Open", "Close", "Import", "Settings", "Help", "About"};

task Menu();

task main()
{
   StartTask(Menu);
}

task Menu()
{
   while (1)
   {
      // If button isn't pressed, variable will be 0; if it is pressed, variable will be 1
      ButtonBitMap = nLCDButtons;
      LeftDisplayButton = (ButtonBitMap & 1) && 1;
      CenterDisplayButton = (ButtonBitMap & 2) && 1;
      RightDisplayButton = (ButtonBitMap & 4) && 1;

      if (LeftDisplayButton && !LeftDisplayButtonPressed && CurrentMenuItem > 0)
      {
         CurrentMenuItem--;
         DisplayNeedsRefreshing = 1;
      }
      LeftDisplayButtonPressed = LeftDisplayButton;
      if (RightDisplayButton && !RightDisplayButtonPressed && CurrentMenuItem < TotalMenuItems - 1)
      {
         CurrentMenuItem++;
         DisplayNeedsRefreshing = 1;
      }
      RightDisplayButtonPressed = RightDisplayButton;
      if (CenterDisplayButton && !CenterDisplayButtonPressed)
      {
         ActivateMenuItem = 1;
         DisplayNeedsRefreshing = 1;
      }
      CenterDisplayButtonPressed = CenterDisplayButton;
      
      if (DisplayNeedsRefreshing)
      {
         clearLCDLine(0);
         clearLCDLine(1);
         displayLCDCenteredString(0, "Main Menu");
         displayLCDCenteredString(1, MainMenu[CurrentMenuItem]);
         DisplayNeedsRefreshing = 0;
      }
      
      if (ActivateMenuItem)
      {
         ActivateMenuItem = 0;
         // Do Stuff here! Use CurrentMenuItem variable to base decision off of what the current menu item is
      }
   }
}


Sat Mar 31, 2012 12:40 pm
Profile
Novice
User avatar

Joined: Sat Jul 10, 2010 3:06 pm
Posts: 86
Location: Roanoke, VA
Post Re: LCD Programming
sumasmreq wrote:
Nope not a typo! This lets you detect if multiple buttons are being pressed by adding up the values from the different buttons. So:

The variable nLCDButtons, as magicode said, contains the values for the different LCD Buttons. If you read the variable and it equals 0, that means that no buttons are pressed. If you read the variable and it does not equal 0, that means that at least one of the buttons is pressed.
The other button readings are as follows:

nLCDButtons = 1 - Left Button is Pressed
nLCDButtons = 2 - Center Button is Pressed
nLCDButtons = 3 - Left and Center Buttons are Pressed
nLCDButtons = 4 - Right Button is Pressed
nLCDButtons = 5 - Right and Left Buttons are Pressed
nLCDButtons = 6 - Right and Center Buttons are Pressed
nLCDButtons = 7 - Right, Center, and Left Buttons are Pressed

I so should have seen this... :) Thanks!

//Andrew

_________________
Check out my website! www.RoboDesigners.com

VRC Team 2190

Twitter: @RoboDesigners


Sat Mar 31, 2012 10:30 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.