View previous topic :: View next topic |
Author |
Message |
noisepic
Joined: 24 Jul 2005 Posts: 20
|
menu on LCD |
Posted: Thu Aug 18, 2005 11:56 pm |
|
|
I want to make menu and select for LCD with 5 keys.
UP
DOWN
LEFT
RIGHT
SELECT
I don't know how to do! anyone can make a guide.
thanks |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Fri Aug 19, 2005 8:06 am |
|
|
You have to write a function to scan the keys. And you have to sort thru the keypresses. With each button press, you have to check for bounds (min and max values). It's all implementation-specific.
Code: |
// scan_keys() will return
// BUTTON_NONE, BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT
button_pressed = scan_keys();
switch (button_pressed)
{
case BUTTON_NONE:
break;
case BUTTON_UP:
// do something
break;
case BUTTON_DOWN:
// do something
break;
case BUTTON_RIGHT:
// do something
break;
case BUTTON_LEFT:
// do something
break;
default:
break;
}
|
Is the above skeleton enough? Or do you need more code written? |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: menu on LCD |
Posted: Fri Aug 19, 2005 8:56 am |
|
|
noisepic wrote: | I want to make menu and select for LCD with 5 keys.
UP
DOWN
LEFT
RIGHT
SELECT
I don't know how to do! anyone can make a guide.
thanks |
I suggest a multitasking friendly approach. You should do this with a few functions.
1) Read, debounce and rate limit the keys.
The keys should be read by a function that will perform a debounce function as well as limiting the rate of impulses from the keys. For example when you press a key it should cause a bit to be set indicating the key is pressed. The next pass through the loop the bit should be cleared and then set again after some number of times through the loop. This means when you hold the up button to change some value it will be changed at a rate that you can control and monitor.
2) A state machine that uses left right to change menu items and up down to change menu values. |
|
|
valemike Guest
|
Re: menu on LCD |
Posted: Fri Aug 19, 2005 9:38 am |
|
|
Neutone wrote: |
2) A state machine that uses left right to change menu items and up down to change menu values. |
Oh yeah, i forgot to mention that the code snippet above will be present in each state of the state machine. |
|
|
J1M
Joined: 15 Feb 2005 Posts: 21
|
|
|
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Mon Apr 06, 2009 5:49 am |
|
|
invalid link to arhive |
|
|
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Sat Jun 20, 2009 3:19 am |
|
|
Any news about the archive? I still don't know how to make a menu system. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jun 20, 2009 10:59 am |
|
|
Just click on his 2nd "Index" link above, which goes to Hobbypic.com.
You'll see a list of his archive files. Download the one called "menu.rar"
from Megaupload.
But his code doesn't look that great. In his menu.h file, he is re-enabling
global interrupts inside the #int_ext routine. Nested interrupts are not
supported. After I saw that, I stopped looking at the code. |
|
|
|