Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need C code to display/Manage Menu on LCD by Keyboard

Status
Not open for further replies.

niket_304

Member level 4
Joined
Dec 21, 2005
Messages
72
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
2,002
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.
 

lcd menu state machine

I asked the same question but nobody answered yet...
 

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.
 

Don't you think Robert is a smart guy ?

Quote from World of Robert Ashby
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 :
**broken link removed**
and responses to above article
**broken link removed**
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
 

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
 

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.
 

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 !
 

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?
 

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
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top