| Author |
Message |
niket_304
Joined: 21 Dec 2005 Posts: 74
|
01 Mar 2006 20:39 rashby054 |
|
|
|
|
Hello,
I have 89c51/89c668 based hardware in which I have interfaced a PC AT Keyboard and 16X2 LCD. I have LCD driver as well as Keyboard software in C. But I need a C code to display Menu Structure on LCD and I can manage menu by keyboard.So please give me the C code for menu structure for LCD and Keyboard. I will be vey greatful to you.
|
|
| Back to top |
|
 |
coshkun
Joined: 27 Aug 2005 Posts: 150 Helped: 8
|
01 Mar 2006 21:31 lcd menu state machine |
|
|
|
|
| I asked the same question but nobody answered yet...
|
|
| Back to top |
|
 |
Code Warrior
Joined: 30 Dec 2004 Posts: 224 Helped: 7
|
01 Mar 2006 21:43 menu c code |
|
|
|
|
| niket can you give us info about which C compiler you are using and which development board you are using. Where are you from.
|
|
| Back to top |
|
 |
silvio
Joined: 31 Dec 2001 Posts: 801 Helped: 90
|
02 Mar 2006 2:15 Re: Need C code to display/Manage Menu on LCD by Keyboard |
|
|
|
|
Don't you think Robert is a smart guy ?
Quote from World of Robert Ashby
| Quote: |
You can tell someone's a geek if they first describe a menu using the words file, edit, and view instead of breakfast, lunch, and dinner. One of the great things about the World of Robert is that I get to dip my fingers in lots of different projects that give me enough variety to make me somewhat of a Jack-of-all-trades and master-of-none. I've learned, almost invariably, that I need to listen to everyone (they probably know something you can learn), and there's probably a better way (if you spend enough time). Unfortunately, you usually need to complete designs without a complete knowledge or adequate research, and you can usually get a design 80% of the way to perfect in 20% of the time, and spend the rest of forever fine-tuning those last undesirables out of the design.
You can save yourself a lot of heartache when your design is based around concepts and structures that already exist in other products, even if those products don't directly relate to what you are doing
|
Read more about it :
http://archive.chipcenter.com/eexpert/rashby/rashby054.html
and responses to above article
http://archive.chipcenter.com/eexpert/rashby/rashby056.html
especially responses from Aubrey Kagan, Kenneth W. Reighard and Bill Burton .
It worths reading.
According to Robert's thoughts, the "C" chalenge :
http://www.bytecraft.com/cop8flash.html
Try deciphering meanings and purpose of:
const char far * menu_strings[]
const char ok_menu_selection_table[]
const char cancel_menu_selection_table[]
void handle_menu_request(char far * table_ptr)
As you can see it's not right on the shelf.
Or you can wait until samples codes will be posted at the bottom of page : www.eagleairaust.com.au/sampcode.htm
|
|
| Back to top |
|
 |
sn_burki
Joined: 18 Feb 2003 Posts: 220 Helped: 4
|
02 Mar 2006 7:32 Re: Need C code to display/Manage Menu on LCD by Keyboard |
|
|
|
|
Its a very good Question even I also want to study Keyboard working so I can interface with ATmel controller with my projects even I want to know how Usb port work and how i can interface my projects to this port? If any one has any idea plz do upload details.
regards
|
|
| Back to top |
|
 |
coshkun
Joined: 27 Aug 2005 Posts: 150 Helped: 8
|
02 Mar 2006 9:40 Re: Need C code to display/Manage Menu on LCD by Keyboard |
|
|
|
|
| I tried something for my project.My menu have 4 submenus and a associated parameter.It works fine in ISIS simulation but it doesn't on the board.After a few fast pushes it gets stuck.What can be the problem? I put some delays after button pushes but still it doesnt work properly.
|
|
| Back to top |
|
 |
Google AdSense

|
02 Mar 2006 9:40 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
maxer
Joined: 18 May 2001 Posts: 124 Helped: 3
|
02 Mar 2006 11:17 Re: Need C code to display/Manage Menu on LCD by Keyboard |
|
|
|
|
all precedent are not the right way to do what you want!
i reccomend you to study carefully a simple state machine with as many states as submenues you have to switch to.
this machine can be coded in c easily as you construct a diagram for what you want to do.
Start imaginating how would you code this machine in paper with states: A,B,C,D etc. and then how should the current state change under external condition (button pressing etc...) from A to B or from A to C, D etc.
Code in C and run it in a loop making attention to include a delay in it so you can control the speed at which the State machine runs. Each state has to perform operations as your project in detail requests.
regards
maXer
Added after 5 minutes:
oh i forgot :)
proteus runs the project at a certain frequency and assumes some real errors not as theorytical errors so for the simulator your project is OK.
These problems may be tied to : bad clock selection in reality, wrong delay routines etc.
the best thing to do in all your cases is to lower the crystal frequency and to modificate the code for such a clock so critical problems due to delays can be eliminated.Start at clk= 1Mhz. That would be standard and not create problems.
maXer
Added after 2 minutes:
and ciao a silvio !
|
|
| Back to top |
|
 |
coshkun
Joined: 27 Aug 2005 Posts: 150 Helped: 8
|
02 Mar 2006 15:24 Re: Need C code to display/Manage Menu on LCD by Keyboard |
|
|
|
|
Actually i used the similar state machine logic.That's what i came up with:
| Code: |
void main(void)
{
menu=0;
//Forever loop
while(1){
if(menu==1) menu1();
if(menu==2) menu2();
if(menu==3) menu3();
if(menu==4) menu4();
if(RD4==0) //menu button
{
while(RD4==0);
DelayMs(sometime);
menu=1;
}
}//end of while loop
}
void menu1(void){
lcd_clear();
lcd_puts(m1);
lcd_goto(71);
lcd_puts(m2);
while(1) { //submenu forever loop
if(RD0==0){ //increment
while(RD0==0);
DelayMs(sometime);
// do something
}
if(RD1==0){ //artır
while(RD1==0);
DelayMs(sometime);
//do something
}
if(RD4==0){ //next submenu
while(RD4==0);
DelayMs(sometime);
menu=2;
break;
}
}
//end while
return;
}//end menu1
|
other menu2(),menu3() ... are similar
am i doing something wrong? Can't we use forever loops in our functions?
|
|
| Back to top |
|
 |
maxer
Joined: 18 May 2001 Posts: 124 Helped: 3
|
03 Mar 2006 12:07 Re: Need C code to display/Manage Menu on LCD by Keyboard |
|
|
|
|
no i would reccomend to you using case instruction instead of IF == etc etc...
use a while (forever loop ) and then use the case instruction for each menu0,1...
maXer
Added after 2 minutes:
and avoid delay routines internal to each IF...
try replacing IFs with Case and instead of using too many DELAY routines which may have an unpredictable total delay use only one at the end of the main While statement.
maxer
Added after 2 minutes:
and use only one WHILE forever loop from which you execute the function that manages the states,as i see you have 2 of them,i don't think this is very good...
hope to have been of help to you
maxer
|
|
| Back to top |
|
 |