CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

menu on LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
noisepic



Joined: 24 Jul 2005
Posts: 20

View user's profile Send private message

menu on LCD
PostPosted: Thu Aug 18, 2005 11:56 pm     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Fri Aug 19, 2005 8:06 am     Reply with quote

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

View user's profile Send private message

Re: menu on LCD
PostPosted: Fri Aug 19, 2005 8:56 am     Reply with quote

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
PostPosted: Fri Aug 19, 2005 9:38 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Aug 19, 2005 8:06 pm     Reply with quote

ive a menu with 3 buttons, i hope that you havent any problem to adapt it for five buttons.

http://perso.wanadoo.es/j1m/proyectos/ejemplos/menu.zip


http://perso.wanadoo.es/j1m/index.htm

regards!
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Mon Apr 06, 2009 5:49 am     Reply with quote

invalid link to arhive
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Sat Jun 20, 2009 3:19 am     Reply with quote

Any news about the archive? I still don't know how to make a menu system.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jun 20, 2009 10:59 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group