Making a menu


Closed Thread
Results 1 to 37 of 37

Thread: Making a menu

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    51

    Default Making a menu

    Hi there, im currently trying to create a menu on a LCD display which im having some troubles with. Ill post m code further down but the code seems to be running straight through and then freezing with "game length" on the top and the minutes on the bottom. I guess ive missed somthing but for all the time ive spent looking i can't see the problem!
    Cheers


    Also i forgot to mention it is possible to change one of the values on the timer if you rapidly press the button as it turns on then after this i get no responce!

    Code:
    ' Hardware Defines
    ' ================
    
    CMCON=%00000111
    CVRCON=%00000000 
    '
    ' LCD Display
    ' -----------
    ' Adjust these to suit your chosen LCD pinout
    '
    DEFINE LCD_DREG PORTB 			'Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT 4 			'Define first pin of portb connected to LCD DB4
    DEFINE LCD_RSREG PORTB 			'Define PIC port used for RS line of LCD
    DEFINE LCD_RSBIT 3 			'Define Portb pin used for RS connection
    DEFINE LCD_EREG PORTB 			'Define PIC prot used for E line of LCD
    DEFINE LCD_EBIT 0 			'Define PortB pin used for E connection
    DEFINE LCD_BITS 4 			'Define the 4 bit communication mode to LCD
    DEFINE LCD_LINES 2 			'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000 		'Define delay between sending LCD commands
    DEFINE LCD_DATAUS 50 			'Define delay time between data sent.
    
    ' Control Buttons/Lines
    ' ---------------------
    ButStart var Portc.0 	' Take this pin low momentarily to START timing
    ButStop var Portc.1 	' Take this pin low momentarily to STOP timing
    ButReset var Portc.2 	' Take this pin low momentarily to RESET clock
    Butup var portc.3	' Take this pin low momentarily to increase clock time
    Butdwn var portc.4	' Take this pin low momentarily to decrease clock time
    '
    ' Software Defines
    ' ----------------
    BannerOffset var BYTE ' Variable holding start address of Banner Display
    CounterA var BYTE ' Just a Counter
    CounterB var BYTE ' Just a Counter
    CounterC var BYTE
    DataA var BYTE
    Hours var BYTE
    Hundredths var BYTE
    Minutes var BYTE
    OverflowError var BIT
    RunningFlag var BIT
    Seconds var BYTE
    SetupTimeOut var WORD ' Timeout counter for Calibration/Set-Up Mode
    TMR1Cal var BYTE ' Calibration Value
    IHOURS VAR BYTE
    IMINUTES VAR BYTE
    
    TMR1CalAR var Byte ' Calibration 0=ADVANCE, 1=RETARD
    TMR1RunOn var WORD ' variable holding TMR1 Run-On value
    '
    ' EEPROM Presets
    ' --------------
    'Data @0,0 ' Advance/Retard Indicator
    'Data 0 ' Calibration Value
    'Data "Spec-ops.nl Tactical Game Aid - Enter Game Length"
    '
    ' Software Constants
    ' ------------------
    
    ' Initialise Processor
    ' --------------------
    TRISA=%00000000
    TRISB=%00000000
    TRISC=%00011111
    ADCON0=%11000000
    ADCON1=%00000111
    
    ' INITIAL Time Setup
    '----------------------------
    start:
    
    IHOURS=0
    IMINUTES=3
    
    
    
    HOURSI:
    If Butup=0 then 
    IHOURS=IHOURS+1
    IF BUTDWN=0 THEN
    IHOURS=IHOURS-1
    IF BUTSTART=0 THEN
    GOTO MINSI
    ENDIF
    ENDIF
    ENDIF
    GOSUB TIMESETUP
    
    MINSI:
    If Butup=0 then 
    IMINUTES=IMINUTES+1
    IF BUTDWN=0 THEN
    IMINUTES=IMINUTES-1
    IF BUTSTART=0 THEN
    GOTO CONTINUE
    IF BUTRESET=0 THEN
    GOTO HOURSI
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    GOSUB TIMESETUP
    
    
    timesetup:
    
    LCDOUT $FE, 1, "GAME LENGTH"
    LCDOut $FE,$C0,DEC2 IHours,":",DEC2 IMinutes,":00.00"	
    PAUSE 200
    REturn
    
    'butup and butdwn
    
    
    Continue:
    
    LCDOUT $FE, 1, "Settings Saved"
    pause 1000
    goto continue
    end

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    MINSI:
    If Butup=0 then 
    IMINUTES=IMINUTES+1
    IF BUTDWN=0 THEN
    IMINUTES=IMINUTES-1
    IF BUTSTART=0 THEN
    GOTO CONTINUE
    IF BUTRESET=0 THEN
    GOTO HOURSI
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    GOSUB TIMESETUP
    
    timesetup:
    LCDOUT $FE, 1, "GAME LENGTH"
    LCDOut $FE,$C0,DEC2 IHours,":",DEC2 IMinutes,":00.00"	
    PAUSE 200
    REturn
    Codes falls thru after the GOSUB, goes to timesetup, then tries to RETURN from which there was no GOSUB...therefore, the PIC dies a horrible death not knowing where to RETURN to.
    Ok, not that horrible, and not a death, but it probably does stop dead in it's tracks.

  3. #3
    Join Date
    Oct 2008
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Ok so if i tried somthing like:
    Code:
    MINSI:
    If Butup=0 then 
    IMINUTES=IMINUTES+1
    IF BUTDWN=0 THEN
    IMINUTES=IMINUTES-1
    IF BUTSTART=0 THEN
    GOTO CONTINUE
    IF BUTRESET=0 THEN
    GOTO HOURSI
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    GOSUB TIMESETUP
    goto minsi
    
    timesetup:
    LCDOUT $FE, 1, "GAME LENGTH"
    LCDOut $FE,$C0,DEC2 IHours,":",DEC2 IMinutes,":00.00"	
    PAUSE 200
    Return
    That should get that working?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by chrisshortys View Post
    That should get that working?
    Have you tried it yet?

  5. #5
    Join Date
    Oct 2008
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    I gave it a quick go and it appears to step through on +1 but does not on the -1 or the goto the next section of coding.
    I was going to put it down to being up for 20 hours and not looking forward to the 7:30 start at work tommorow for it not working right now unless you have any ideas?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by chrisshortys View Post
    I was going to put it down to being up for 20 hours and not looking forward to the 7:30 start at work tommorow for it not working right now unless you have any ideas?
    If you're going to program a PIC, you almost want to think like a PIC.
    Go thru your program in your head, step by step, follow it thru and you'll see why it does what it does.
    Don't assume it'll work because you want it to. A CPU follows instructions in an explicit order. It doesn't go off on it's own because it thinks it's the thing to do at the moment.

Similar Threads

  1. interactive menu with hyperterminal
    By jamied in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 5th January 2009, 11:13
  2. Sending menu to PC from PIC16F876A
    By joseph Degorio in forum Serial
    Replies: 2
    Last Post: - 12th November 2007, 07:03
  3. Interrupt/timer not really interrupting...
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd May 2005, 22:05
  4. Interrupt Menu System Example and Help Needed
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 1st April 2005, 17:05
  5. Lcd Menu
    By eliecer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 19:29

Members who have read this thread : 1

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