lcd menu problems


Results 1 to 5 of 5

Threaded View

  1. #5
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 24/02/2009                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    
    '
    'pic defines
    '------------------------------------------------------------------------
    	@ DEVICE pic16F887, WDT_OFF        ' Watchdog Timer
    	@ DEVICE pic16F887, PWRT_ON        ' Power-On Timer
    	@ DEVICE pic16F887, MCLR_ON        ' Master Clear Options (Internal)
    	@ DEVICE pic16F887, BOD_ON         ' Brown-Out Detect
    	@ DEVICE pic16F887, LVP_OFF        ' Low-Voltage Programming
    	@ DEVICE pic16F887, CPD_OFF        ' Data Memory Code Protect
    	@ DEVICE pic16F887, PROTECT_OFF    ' Program Code Protection
    '
    'konfigurisi AN pinove kao digital I/O, portd kao I
    '------------------------------------------------------------------------
    ansel=$00
    anselh=$00
    TRISD=$00
    portd=$00
    '
    ' Definisanje hser-a (transmit-recive) i lcd-a u 4 bitnom modu
    '------------------------------------------------------------------------ 
    define OSC 4
    DEFINE HSER_SPBRG 25
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1
    DEFINE LCD_BITS 4
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_LINES 2
    '
    'definisanje varijabli
    '------------------------------------------------------------------------
    
    SYMBOL sel = PORTA.0 ' Sw 1 "select"
    SYMBOL enter = PORTA.2 ' Sw 3 "ENTER"
    
    T1 VAR BYTE
    T1=20
    
    
    
    '----------------------------------------------------------------
    ' promjenjive
    '----------------------------------------------------------------
    
    MENU VAR BYTE ' zeljeni MENU
    POSI VAR BYTE ' Pozicija na LCD
    temp Var Word			' temperatura kao word
    cr Var Byte			    ' ostatak
    cpc Var	Byte			' broji po stepenu C
    ow	Var	PORTE.2			' One-wire data pin
    i var byte              ' brojac
    posttemp var word 
    
    '----------------------------------------------------------------
    ' incijalizacija 
    '----------------------------------------------------------------
    low portc.6
    low porte.2
    PAUSE 300       ' LCD inicijalizacija
    LCDOUT $FE,1    ' ocisti LCD
    
    MENU = 1        ' Inicijalizacija variablli
    
    
    LCDOUT $FE,130," DOBRO DOSLI"
    lcdout $FE,$c0,128, "izaberite temp "
    '-------------------------------------------------------------------------------------
    ' meni switc select temp
    '-------------------------------------------------------------------------------------
    izbor:
    
    PAUSE T1
    
    IF sel = 1 THEN
    
     LCDOUT $FE,1'ocisti lcd
        MENU = MENU + 1
        gosub amenu    
        pause 200
     endif
        IF MENU = 5 THEN MENU = 1
        
       ' for i = 1 to 4
        if menu = 1 and enter=1 then gosub sc
        if menu = 2 and enter=1 then gosub sc
        if menu = 3 and enter=1 then gosub sc
        if menu = 4 and enter=1 then gosub sc
       ' next i
    GOTO izbor
    
    '----------------------------------------------------------------------
    'odabir za prikaz na displeju
    '----------------------------------------------------------------------
    AMENU:
    
    SELECT CASE MENU
    
    CASE 2
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"1."," 28.00" , " C"
    POSI = 193 : LCDOUT $FE,POSI,"2."," 30.00" , " C" 
    
    
    CASE 3
    
    
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"2."," 30.00" , " C"
    POSI = 193 : LCDOUT $FE,POSI,"3."," 32.00" , " C" 
    CASE 4
    
    
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"3."," 32.00", " C"
    POSI = 193 : LCDOUT $FE,POSI,"4."," 34.00" , " C" 
    CASE 5
    
                                                                               
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"4."," 34.00", " C"
    POSI = 193 : LCDOUT $FE,POSI,"1."," 28.00", " C"
    
    END SELECT
    RETURN
    
    
    '
    'provjera temperature
    '---------------------------------------------------------------------
    sc:
    'ovdje probati napraviti select case  
    if menu = 2 then 
    posttemp=$0AF0' postemp = 2800
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "28.00 C"
        pause 2000
    endif
    
    if menu = 3 then 
    posttemp=$0BB8
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "30.00 C"
        pause 2000
    endif
    
    if menu = 4 then 
    posttemp=$0C80
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "32.00 C"
        pause 2000
    endif
    
    if menu = 1 then 
    posttemp=$0D48
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "34.00 C"
        pause 2000
    endif
    
    goto sc1
    sc1:
    
       OWOut ow, 1, [$CC, $44]       ' pocni temp konverziju
    
    wc: 
       OWIn ow, 4, [cr]	' provjeri da'l se jos konvertuje
       If cr = 0 Then wc
       OWOut ow, 1, [$CC, $BE]		' ocitaj temp
       OWIn ow, 0, [temp.LOWBYTE, temp.HIGHBYTE, Skip 4, cr, cpc]
       ' izracunaj temp u C na 2 decimale
      temp = (((temp >> 1) * 100) - 25) + (((cpc - cr) * 100) / cpc)
       
       Lcdout $fe, 1," temp:",DEC (temp / 100), ".", DEC2 temp, " C"' prikazi temp
       
       
                if temp >= posttemp then gosub s3    ' ako je veca od izabrane salji poruku!
              
                
       pause 2000
      goto sc1
    
    s3:
    
    high portb.6
    
    pause 2000
    
    low portb.6
    
    return
    
    End
    so u have a simple lcd menu and two switch, porta.0 seleect switch and porta.2 enter switch, if temp(from ds18B20) >= posttem (selected temperature form lcd menu) take action gosub s3

    --
    www.mtskola.com
    Last edited by xxxxxx; - 2nd April 2009 at 19:16.

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. Sending menu to PC from PIC16F876A
    By joseph Degorio in forum Serial
    Replies: 2
    Last Post: - 12th November 2007, 07:03
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts