Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Menus

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
philm

Bascom Member



Joined: 14 Jul 2004
Posts: 138
Location: Australia

australia.gif
PostPosted: Wed Mar 30, 2005 7:12 am    Post subject: Menus Reply with quote

I have been trying to come up with a simple menu structure, that uses a LCD and left, right, up, down & enter button.
For example.
Main Menu
Set Time
Set Date

Set Time
Set Hour
Set min
Set Sec

Set Date
Set Year
Set Month
Set Day

I want the structure to be easy to edit, (to add more menu items) and each menu have any number of entries (more or less than the number of rows on the LCD)

Has anyone got any ideas? even better some code to share?
Thanks
Phil
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Thu Mar 31, 2005 3:53 pm    Post subject: menu's Reply with quote

Have made something simular with a GSM-like keyboard and a LCD display. With up/down, left/right you could step through all menu options. Have made it a few years back and if I see the code now I would make it a bit smaller. You can find it on my homepage, software, bascom-examples. GSM-like keyboard.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Lupe

Bascom Member



Joined: 14 Nov 2004
Posts: 26
Location: San Antonio,Tx.

blank.gif
PostPosted: Mon Apr 11, 2005 4:24 am    Post subject: Reply with quote

I too am working on a project that uses menus. My project uses an AT-kyeboard. Ben's project I believe uses Bascom DOS. If anyone has any ideas, code, etc. on using arrow keys and page up/down I would really appreciate it. Most examples out there as far as i have seen seem to be with either Bascom DOS or don't involve using the arrow keys or page keys. I am using Bascom AVR and the 90S8515 micro. Any help, comments etc. appreciated. Thanks Lupe,
Back to top
View user's profile
philm

Bascom Member



Joined: 14 Jul 2004
Posts: 138
Location: Australia

australia.gif
PostPosted: Mon Apr 11, 2005 6:22 am    Post subject: Reply with quote

When I wrote "up" button & "down" button, etc, I ment buttons connected to a port, not a whole keyboard.
I just started writing some code, as I could not find anyone elses code to steal (don't you hate that).
It uses a series of data tables that is used as a "map" to navigate around the menu system.
A small sample of the code
Code:
sub menu2lcd(byval menu)
Local Currentrow As Byte, num_of_items as byte
Cls                                    'Clear lcd
Cursor Off
For Currentrow = 1 To Lcdrows
   num_of_items = lookup(menu, menuitems)
   if Currentrow > num_of_items then exit sub
   Locate Currentrow , 1               'locate at the row, col 1
   lcd lookupstr(menu, Menustring)     'display rest of sub menu
   menu = lookup(menu, Nextmenu)        'next menu item
Next Currentrow
end sub

I will post the code when I am finished.
Back to top
View user's profile
Lupe

Bascom Member



Joined: 14 Nov 2004
Posts: 26
Location: San Antonio,Tx.

blank.gif
PostPosted: Tue Apr 12, 2005 3:56 am    Post subject: Reply with quote

Thanks for clearing that up for me, I guess I will explore my options on this one as I was hoping to use arrow keys & page up/down for my project. Who knows, I just might add buttons like you are and go from there. Code always helps around here, much appreciated. Thanks again. Lupe
Back to top
View user's profile
philm

Bascom Member



Joined: 14 Jul 2004
Posts: 138
Location: Australia

australia.gif
PostPosted: Tue Apr 12, 2005 5:32 am    Post subject: Reply with quote

Having a big keyboard or a pc terminal is OK to get the project working without too much fuss, but not for final use.
eg.
My digital camera does not have a pc keyboard, it only has a few buttons and a tft screen and a menu system.
PS the code is turing into a can of worms as usual.
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Wed Apr 13, 2005 12:51 am    Post subject: Reply with quote

One of the problems with this (why you'd be hard pressed to steal someone elses code) is that menuing items for LCD's are usually custom tailored to the writer's needs. Is the writer using a 2x16 LCD? 2x20? 4x20? Graphical? What menus is he wanting to display? Are the menu items permanently displayed at the bottom or side? Will the menu item selected be reverse contrasted? How will he shorten the words and space them on the LCD (you can never put all the information you want exactly how you'd like to). I think you will fight hard for any code that will be a "one code fits all" when it comes to LCD menuing.

Something else you'll find is that LCD menuing eats up code space like you never imagined. Every text letter is a byte and before you know it, all that text has eaten up lots of percent (and it doesn't even do anything... code wise).

I think perhaps you are on the right track with the data tables but I would suggest maybe storing them in EEPROM to limit your code useage to actual code instead of text. What I've done in the past is create and store "pages" of text that represent an LCD screen worth of data. This data would comprise what I consider the "background" of that particular LCD page (basically text that doesn't change... like the words "Time:" or "Date:"). I would grab that LCD page from EEPROM and spit it out to the LCD... painting the background for that page. Then I would locate to blank areas of that page and paint foreground items (things that do change like current time and date, etc). I would also keep track of those variables and only do an LCD write if the variable had changed in value (no sense painting "4:20 PM" 300 times per second... it makes the text flicker and is just plain silly to do).

The following may be more complicated then your needs but I'll describe some other techniques I've used. I've forced variables that I was going to display on the LCD at pre-defined memory locations. Then I would embed these memory addresses into the background page I've stored in EEPROM. When spitting data to the LCD from EEPROM, I would test the bytes for some non-displayable character (in my case, I chose &HA0). Once I hit an &HA0, I knew the next byte was a memory location to grab a variable from. It might seem a bit complex but it actually made the LCD display code pretty simple and I didn't eat up code space with a bunch of text.

Just throwing out some ideas you might ponder....
Back to top
View user's profile Yahoo Messenger
philm

Bascom Member



Joined: 14 Jul 2004
Posts: 138
Location: Australia

australia.gif
PostPosted: Thu Apr 14, 2005 1:51 am    Post subject: Reply with quote

Thanks for the ideas.
Quote:
Is the writer using a 2x16 LCD? 2x20? 4x20? Graphical?
At this stage only text displays & the max columns will determin how much text can be displayed.
Quote:
Will the menu item selected be reverse contrasted?

Cannot do on a character LCD, I plan on having the selected menu item on the top row. Then scroll the menu items up or down.
Quote:
How will he shorten the words and space them on the LCD
No can do, the text must fit. I do not want to create an auto justifying LCD display driver.
Having a special character, which indicates that the next word is an address to get the data from is a good idea. But how the the parser know what type the data is? ( byte, or word, or string) Another special charater?
I have got something up and running just using "up", "down", & "enter" (sort of), but I don't like it.
Phil
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Thu Apr 14, 2005 3:52 am    Post subject: Reply with quote

After an &HA0, the next two bytes were the word address of the variable followed by one byte for variable type (I used &H01=bit, &H02=Byte, &H03=Word, &H04=String). Then I used case statements for the variable type. If case=1 then the next byte was bit position. If case=4 then the next byte was string length. For all cases, the following two bytes were column and row to display the variable. The variable list for the page was done when I reached null (&H00). In concept, it was as simple as this...

WHILE theLCDdatafromEEPROM <> &HA0
'spit the raw data to the lcd... it already has the hex code in it to clear screen, blink or block cursor, text, placement, etc.
WEND

'we have reached &HA0 (start of a variable list)
WHILE theLCDdatafromEEPROM <>&H00
'get two bytes for the word address of the variable
'get one byte for variable type

SELECT CASE variabletype

CASE 1 'bit
'get another byte from EEPROM for bit position
'retrieve the byte from memory and look at the bit
'get two bytes from EEPROM for display column and row for this bit
CASE 2 'byte
'get the byte from memory
'get two bytes from EEPROM for display column and row
CASE 3 'word
'get two bytes from memory
'get two bytes from EEPROM for display column and row
CASE 4 'string
'get another byte from EEPROM for string length
'retrieve that many bytes from memory
'get two bytes from EEPROM for display column and row for this string
END SELECT

WEND

'we've reached a null character denoting end of variable list
'spit the variables to the LCD in the places I've been told
Back to top
View user's profile Yahoo Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum