Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 13, 2024, 10:17:28 10:17


Login with username, password and session length


Pages: [1]
Print
Author Topic: LCD Menu system for CCS Compiler  (Read 8177 times)
0 Members and 1 Guest are viewing this topic.
who
Guest
« on: August 31, 2007, 01:44:56 13:44 »

I am looking for a good, working LCD Menu system for a Pic processors, using only two buttons
and 4x20 LCD display.
Thanks for help.
Logged
J1M
Guest
« Reply #1 on: August 31, 2007, 02:00:53 14:00 »

hi, a long time ago I publish on my website a menu with 3 buttons, check it, and you probably be able to adapt it to your needs.

http://www.hobbypic.com/index.php?option=com_content&task=view&id=17&Itemid=27

Best regards
Logged
Future
Guest
« Reply #2 on: August 31, 2007, 04:37:26 16:37 »

Take a look at this file, it can give you many ideas about how to handle things.
http://www.booyaka.com/~tymm/avr/tinymenu.tgz
Logged
pama
Junior Member
**
Offline Offline

Posts: 74

Thank You
-Given: 10
-Receive: 28


« Reply #3 on: September 07, 2007, 03:49:26 15:49 »

hi,

i also was involved in menu system, but i never complete it. But i considered usefull the posted articles.
good luck
pama

http://rapidshare.com/files/54023796/gui.rar
Logged
suresh13
Guest
« Reply #4 on: September 13, 2007, 07:15:08 19:15 »

Erm, i dont use CCS, but i think menu systems are one of the easiest thing that can be done on a PIC. Its all conditional statements. Could be if...else, case, or anything.

For example(sorry im using basic), but the principle is the same for C as well. I needed to develop a menu system for a automated drinks maker very urgently, so i whipped up this code in a fairly short time, so its not the best out there, but it works.

program drinks_maker
'DECLARE VARIABLES

dim hotchoc as byte
dim hotchoc_str as string[3]
dim coff as byte
dim coff_str as string[3]
dim sug as byte
dim sug_str as string[3]
dim mil as byte
dim mil_str as string[3]

'END OF DECLARATION OF VARIABLES


''''The sub-procedures below are used because its function is used''''
''''repetitvely in the main coding, and reduces the code size     ''''

'SUB PROCEDURES

sub procedure delay
  delay_ms(600)
end sub

sub procedure delaysmall
  delay_ms(80)
end sub

sub procedure hot_chocolate
  PORTC.0 = 1
  delay delay
  PORTC.0 = 0
  PORTC.1 = 1
  delay delay
  PORTC.1 = 0
end sub

sub procedure milk
  PORTC.2 = 1
  delay delay
  PORTC.2 = 0
  PORTC.3 = 1
  delay delay
  PORTC.3 = 0
end sub

sub procedure sugar
  PORTC.4 = 1
  delay delay
  PORTC.4 = 0
  PORTC.5 = 1
  delay delay
  PORTC.5 = 0
end sub

sub procedure coffee
  PORTC.6 = 1
  delay delay
  PORTC.6 = 0
  PORTC.7 = 1
  delay delay
  PORTC.7 = 0
end sub

sub procedure hotwater
  PORTD.0 = 1
  delay delay delay
  delay delay delay
  delay delay
  PORTD.0 = 0
end sub

sub procedure makehotchoc
while hotchoc > 0
  hot_chocolate
  dec(hotchoc)
wend
end sub

sub procedure makecoff
while coff > 0
  coffee
  dec(coff)
wend
end sub

sub procedure makesugar
while sug > 0
  sugar
  dec(sug)
wend
end sub

sub procedure makemil
while mil > 0
  milk
  dec(mil)
wend
end sub

''LCD OUTPUT SUBPROCEDURES

sub procedure clearlcd
  Lcd_Cmd(LCD_CLEAR)       'clear the LCD
end sub

sub procedure display
  clearlcd
  Lcd_Out(1,4,"Enjoy Your")
  Lcd_Out(2,5,"Drink!!!")
  delay delay delay delay
  Lcd_Cmd(LCD_CLEAR)
end sub

sub procedure select_go
  Lcd_Out(2,1,">Press select/go")
end sub

sub procedure lcdhot
  Lcd_Out(1,2,"Hot Chocolate")
end sub

sub procedure lcdcoff
  Lcd_Out(1,6,"Coffee")
end sub

sub procedure lcdtbs
  Lcd_Out(2,1,"Tablespoons:")
end sub

sub procedure lcdback
  Lcd_Out(1,3,"<<GO BACK<<")
end sub

sub procedure lcdsave
  Lcd_Out(1,5,"Saved!")
end sub

sub procedure lcdcup
  clearlcd
  Lcd_Out(1,3,"Please Place")
  Lcd_Out(2,2,"Cup in Holder!")
end sub

sub procedure lcdheat
  clearlcd
  Lcd_Out(1,4,"Heating Up")
  Lcd_Out(2,2,"Please Wait...")
end sub

sub procedure lcdinit
  clearlcd
  Lcd_Out(1,1,"Initializing.")
  delay
  Lcd_Out(1,1,"Initializing..")
  delay
  Lcd_Out(1,1,"Initializing...")
  delay
  Lcd_Out(1,1,"Initializing....")
end sub
 

''END OF LCD OUTPUT SUBPROCEDURES

sub procedure hotchoc1
  hotchoc = 0
  clearlcd
  lcdhot
  lcdtbs
  delay
end sub

sub procedure coff1
  coff = 0
  clearlcd
  lcdcoff
  lcdtbs
  delay
end sub

sub procedure mil1
  mil = 0
  clearlcd
  Lcd_Out(1,7,"Milk")
  lcdtbs
  delay
end sub

sub procedure sug1
  sug = 0
  clearlcd
  Lcd_Out(1,6,"Sugar")
  lcdtbs
  delay
end sub



'END OF SUBPROCEDURES

sub procedure hotchoc2
     inc(hotchoc)
     delay
     ByteToStr(hotchoc, hotchoc_str) ' Byte -> String[3]
     Lcd_Out(2,13,hotchoc_str)
end sub

sub procedure coff2
     inc(coff)
     delay
     ByteToStr(coff, coff_str) ' Byte -> String[3]
     Lcd_Out(2,13,coff_str)
end sub

sub procedure mil2
     inc(mil)
     delay
     ByteToStr(mil, mil_str) ' Byte -> String[3]
     Lcd_Out(2,13,mil_str)
end sub

sub procedure sug2
     inc(sug)
     delay
     ByteToStr(sug, sug_str) ' Byte -> String[3]
     Lcd_Out(2,13,sug_str)
end sub


'START OF MAIN PROGRAM

main:
  ADCON1 = $07             'use portA as digital
  PORTA  = $00             'clear portA
  TRISA  = $FF             'designate portA as input
  PORTB  = $00             'clear portB
  TRISB  = $00             'designate portB as output (LCD to portb)
  PORTC  = $00             'clear portC
  TRISC  = $00             'designate portC as output
  PORTD  = $00             'clear portD
  TRISD  = $FC             'set portD.0,1 as output and 2,3,4,5,6,7,as input
  INTCON = $00             'disable all interrupts
  Lcd_Init(PORTB)          'initialize portB as LCD output(default 4-bit con)
  Lcd_Cmd(LCD_CURSOR_OFF)  'turn the LCD cursor off
  lcdinit

cup:
  clearlcd
  lcdcup
  while 1=1
  if PORTA.3 = 0 then
      goto heat
  end if
  wend

heat:
  delay
  clearlcd
  lcdheat
  while 1=1
  if PORTA.2 = 1 then
      goto welcome
  end if
  wend

welcome:
  clearlcd
  Lcd_Out(1,5,"Welcome.")
  delay
  Lcd_Out(2,1,"Please Press Go!") 'welcome screen
  while 1=1
  if PORTA.0 = 1 then
      goto presetmode
  end if
  wend    'the program enters the menu if go(portA.0) is pressed

'MAIN MENU STRUCTURE

presetmode:
  clearlcd
  Lcd_Out(1,3,"PRESET MODE")
  select_go
  delay
  while 1=1
  if PORTA.0 = 1 then
      goto manualmode
  end if
  if PORTA.1 = 1 then
      goto preset_one
  end if
  wend

manualmode:
  clearlcd
  Lcd_Out(1,3,"MANUAL MODE")
  select_go
  delay
  while 1=1
  if PORTA.0 = 1 then
      goto memorymode
  end if
  if PORTA.1 = 1 then
  goto manual_one
  end if
  wend

memorymode:
  clearlcd
  Lcd_Out(1,3,"MEMORY MODE")
  select_go
  delay
  while 1=1
  if PORTA.0 = 1 then
      goto presetmode
  end if
  if PORTA.1 = 1 then
      goto memory_one
  end if
  wend

'END OF MAIN MENU STRUCTURE

'SUB-MENU: PRESET

preset_one:
  clearlcd
  lcdhot
  delay
  while 1=1
  if PORTA.0 = 1 then
     hot_chocolate
     hot_chocolate
     milk
     milk
     sugar
     sugar
     hotwater
     display
     goto welcome
  end if
  if PORTA.1 = 1 then
     goto preset_two
  end if
  wend

preset_two:
  clearlcd
  lcdcoff
  delay
  while 1=1
  if PORTA.0 = 1 then
     coffee
     coffee
     milk
     milk
     sugar
     sugar
     hotwater
     display
     goto welcome
  end if
  if PORTA.1 = 1 then
     goto preset_three
  end if
  wend

preset_three:
  clearlcd
  Lcd_Out(1,2,"Hot Water Only")
  delay
  while 1=1
  if PORTA.0 = 1 then
     hotwater
     display
     goto welcome
  end if
  if PORTA.1 = 1 then
     goto preset_four
  end if
  wend

preset_four:
  clearlcd
  lcdback
  delay
  while 1=1
  if PORTA.0 = 1 then
     goto presetmode
  end if
  if PORTA.1 = 1 then
     goto preset_one
  end if
  wend

'END OF SUBMENU:PRESET

'SUB MENU: MANUAL

manual_one:
  hotchoc1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
  hotchoc2
  end if
  if PORTA.1 = 1 then
     goto manual_two
  end if
  wend

manual_two:
  coff1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
  coff2
  end if
  if PORTA.1 = 1 then
     goto manual_three
  end if
  wend

manual_three:
  sug1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
  sug2
  end if
  if PORTA.1 = 1 then
     goto manual_four
  end if
  wend

manual_four:
  mil1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
  mil2
  end if
  if PORTA.1 = 1 then
     goto manual_five
  end if
  wend

manual_five:
  clearlcd
  Lcd_Out(1,2,"GO: Make Drink")
  Lcd_Out(2,2,"SELECT: Cancel")
  delay
  while 1=1
  if PORTA.0 = 1 then
  makemil
  makesugar
  makehotchoc
  makecoff
  hotwater
  display
  goto welcome
  end if
  if PORTA.1 = 1 then
  clearlcd
  Lcd_Out(1,4,"Cancelled!")
  delay delay
  goto welcome
  end if
  wend
 
'END OF SUB MENU: MANUAL

'SUB MENU: MEMORY

memory_one:
  clearlcd
  Lcd_Out(1,4,"Make Drink")
  Lcd_Out(2,3,"From Memory")
  delay
  while 1=1
  if PORTA.0 = 1 then
  delay
  goto usermem1
  end if
  if PORTA.1 = 1 then
  delay
  goto memory_two
  end if
  wend
 
memory_two:
  clearlcd
  Lcd_Out(1,4,"Save Drink")
  Lcd_Out(2,4,"To Memory")
  delay
  while 1=1
  if PORTA.0 = 1 then
  delay
  goto savemem_one
  end if
  if PORTA.1 = 1 then
  delay
  goto memory_three
  end if
  wend
 
memory_three:
  clearlcd
  lcdback
  delay
  while 1=1
  if PORTA.0 = 1 then
  delay
  goto welcome
  end if
  if PORTA.1 = 1 then
  delay
  goto memory_one
  end if
  wend
 
'END OF SUB MENU:MEMORY

'sub-SUB MENU MAKE DRINK:MEMORY

usermem1:
  clearlcd
  Lcd_Out(1,2,"User Memory 1")
  delay
  while 1=1
  if PORTA.0 = 1 then
  coff = EEPROM_READ(20)
  delaysmall
  hotchoc = EEPROM_READ(22)
  delaysmall
  mil = EEPROM_READ(24)
  delaysmall
  sug = EEPROM_READ(26)
  delaysmall
  makecoff
  makehotchoc
  makemil
  makesugar
  hotwater
  display
  goto welcome
  end if
  if PORTA.1 = 1 then
  goto usermem2
  end if
  wend
 
usermem2:
  Lcd_Out(1,2,"User Memory 2")
  delay
  while 1=1
  if PORTA.0 = 1 then
  coff = EEPROM_READ(30)
  delaysmall
  hotchoc = EEPROM_READ(32)
  delaysmall
  mil = EEPROM_READ(34)
  delaysmall
  sug = EEPROM_READ(36)
  delaysmall
  makecoff
  makehotchoc
  makemil
  makesugar
  hotwater
  display
  goto welcome
  end if
  if PORTA.1 = 1 then
  goto usermem3
  end if
  wend

usermem3:
  clearlcd
  lcdback
  delay
  while 1=1
  if PORTA.0 = 1 then
  goto memorymode
  end if
  if PORTA.1 = 1 then
  goto usermem1
  end if
  wend


'END OF sub-SUB MENU MAKE DRINK:MEMORY

'sub-SUB MENU SAVE DRINK:MEMORY

savemem_one:
  hotchoc1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
     hotchoc2
  end if
  if PORTA.1 = 1 then
     goto savemem_two
  end if
  wend

savemem_two:
  coff1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
     coff2
  end if
  if PORTA.1 = 1 then
     goto savemem_three
  end if
  wend

savemem_three:
  sug1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
     sug2
  end if
  if PORTA.1 = 1 then
     goto savemem_four
  end if
  wend

savemem_four:
  mil1
  while 1=1
  if Button(PORTA, 0, 50, 1)then
     mil2
  end if
  if PORTA.1 = 1 then
     goto savemem_five
  end if
  wend

savemem_five:
  clearlcd
  Lcd_Out(1,2,"GO: Save Drink")
  Lcd_Out(2,2,"SELECT: Cancel")
  delay
  while 1=1
  if PORTA.0 = 1 then
  goto savemem_six
  end if
  if PORTA.1 = 1 then
  clearlcd
  Lcd_Out(1,4,"Cancelled!")
  delay delay
  goto welcome
  end if
  wend
 
savemem_six:
  clearlcd
  Lcd_Out(1,2,"GO:     #1")
  Lcd_Out(2,2,"SELECT: #2")
  delay
  while 1=1
  if PORTA.0 = 1 then
  EEPROM_WRITE(20, coff)
  EEPROM_WRITE(22, hotchoc)
  EEPROM_WRITE(24, mil)
  EEPROM_WRITE(26, sug)
  clearlcd
  lcdsave
  delay
  goto welcome
  end if
  if PORTA.1 = 1 then
  EEPROM_WRITE(30, coff)
  EEPROM_WRITE(32, hotchoc)
  EEPROM_WRITE(34, mil)
  EEPROM_WRITE(36, sug)
  clearlcd
  lcdsave
  delay
  goto welcome
  end if
  wend

'END OF sub-SUB MENU SAVE DRINK:MEMORY

end.
'''''''''''''''END OF MAIN PROGRAM'''''''''''''''
Logged
suresh13
Guest
« Reply #5 on: September 13, 2007, 07:34:04 19:34 »

oh yeah, i forgot to mention. What are you going to use this menu system for? Might be able to narrow things down.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC