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
73
Helped
3
Reputation
6
Reaction score
2
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.
 

coshkun

Full Member level 2
Joined
Aug 27, 2005
Messages
126
Helped
18
Reputation
36
Reaction score
10
Trophy points
1,298
Activity points
2,214
lcd menu state machine

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

Code Warrior

Full Member level 4
Joined
Dec 30, 2004
Messages
230
Helped
10
Reputation
20
Reaction score
2
Trophy points
1,298
Activity points
1,831
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.
 

silvio

Advanced Member level 3
Joined
Dec 31, 2001
Messages
716
Helped
105
Reputation
210
Reaction score
16
Trophy points
1,298
Location
Romania
Activity points
11,471
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 :
https://archive.chipcenter.com/eexpert/rashby/rashby054.html
and responses to above article
https://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 :

https://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
 

sn_burki

Full Member level 5
Joined
Feb 18, 2003
Messages
260
Helped
16
Reputation
32
Reaction score
11
Trophy points
1,298
Location
Pakistan
Activity points
1,623
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
 

coshkun

Full Member level 2
Joined
Aug 27, 2005
Messages
126
Helped
18
Reputation
36
Reaction score
10
Trophy points
1,298
Activity points
2,214
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.
 

maxer

Member level 5
Joined
May 18, 2001
Messages
86
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Activity points
774
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 !
 

coshkun

Full Member level 2
Joined
Aug 27, 2005
Messages
126
Helped
18
Reputation
36
Reaction score
10
Trophy points
1,298
Activity points
2,214
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?
 

maxer

Member level 5
Joined
May 18, 2001
Messages
86
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Activity points
774
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

Top