LCD menu with two buttons

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone,

Working on a project which has a LCD and 2 buttons(green utton and red button)

i need to make a menu for setting up the system

the idea is to use the green button as the mode selection and red button to accept/select.

lcd_line(1);
	if (green_sw_reg==0xff)
		{
		lcd_String("Setup timings"); //menu item
		timeout =15;
		while ((green_sw_reg ==0) || (red_sw_reg==0) || (timeout > 0)) {}  // do nothing untill a button is pressed or untill 15 seconds pass. timeout variable is automatically decreased in the timer ISR
		if (red_sw_reg==0xff) 
			{
			lcd_line(2);
			lcd_String("time proc");
			}
		}

the system halts at the while statement and moves forward only after the timeout expires and both buttons are pressed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry but are you actually asking a question here? The above just seems to be a statement of what you intend to implement. Are you asking whether it's a good idea? Or are you saying you have implemented it and it does not work as you had hoped? If the latter what were you expecting, what actually happens?

BTW you posted in GCC forum - I see nothing particularly specific to GCC here - should I move this to the more general AVR Forum?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

my appologies.. please move the post to the avr forum

its an implematation which has failed. not really sure if the while statement is correct. would appriciate your help in this matter.

Rodney

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

its an implematation which has failed.

This is a bit like pulling hen's teeth. Has "failed" in what way?

Without seeing the code that changes "timeout" (and how it is defined) it is very difficult to say but could it be that it is decremented in a timer ISR() and you have forgotten to make it "volatile" perhaps?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If mode button is pressed, do you wish to wait 15 seconds before accept/select button is looked at? (while (..||.. || ..)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hmm.. i got it fixed.. thanks anyways

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the fault was in the way i handled the key regesters that were software debounced.