|
Page 1 of 1
|
[ 12 posts ] |
|
| Author |
Message |
|
jmuthig
Rookie
Joined: Tue Oct 11, 2011 3:00 pm Posts: 4
|
 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 |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 494
|
 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 |
|
 |
|
jbflot
Site Admin
Joined: Tue May 15, 2007 9:02 am Posts: 383
|
 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".
|
| Tue Dec 06, 2011 11:18 am |
|
 |
|
tlrmrtn
Rookie
Joined: Fri Jan 20, 2012 1:20 am Posts: 5
|
 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 |
|
 |
|
jbflot
Site Admin
Joined: Tue May 15, 2007 9:02 am Posts: 383
|
 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.
|
| Tue Jan 24, 2012 3:34 pm |
|
 |
|
tlrmrtn
Rookie
Joined: Fri Jan 20, 2012 1:20 am Posts: 5
|
 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 |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 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 |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 494
|
 Re: LCD Programming
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 |
|
 |
|
tlrmrtn
Rookie
Joined: Fri Jan 20, 2012 1:20 am Posts: 5
|
 Re: LCD Programming
Thank you both of your help
|
| Wed Feb 22, 2012 3:07 am |
|
 |
|
RoboDesigners
Novice
Joined: Sat Jul 10, 2010 3:06 pm Posts: 86 Location: Roanoke, VA
|
 Re: LCD Programming
I've written a blog post about this topic... http://robodesigners.blogspot.com/2012/ ... obotc.htmlIf it's unclear, please let me know...  //Andrew
_________________Check out my website! www.RoboDesigners.comVRC Team 2190 Twitter: @RoboDesigners
|
| Sun Mar 04, 2012 3:32 pm |
|
 |
|
sumasmreq
Rookie
Joined: Fri Jan 27, 2012 6:57 pm Posts: 40
|
 Re: LCD Programming
Edit: Good tutorial RoboDesigners! Your code would do the trick just as well. 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: 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 |
|
 |
|
RoboDesigners
Novice
Joined: Sat Jul 10, 2010 3:06 pm Posts: 86 Location: Roanoke, VA
|
 Re: LCD Programming
I so should have seen this...  Thanks! //Andrew
_________________Check out my website! www.RoboDesigners.comVRC Team 2190 Twitter: @RoboDesigners
|
| Sat Mar 31, 2012 10:30 pm |
|
|
|
Page 1 of 1
|
[ 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
|
|