Code:
CMCON=7 ' DISABLE ANALOG ON 628A
INCLUDE "modedefs.bas"
input 0
input 1
input 2
input 3
input 4
input 5
input 6
output 7
FIRE_PIN VAR PortB.5
RESTROOM_PIN VAR PortB.4
LAST_CALL_PIN VAR PortA.1
CLOSING_PIN VAR PortB.0
GOTO START
'-----------------------------------------
'---------- Subroutines ------------------
'-----------------------------------------
'---=== Initialize LCD LCD ===---
INIT_LCD:
serout 7,N2400,[254,1,"?c0"] 'Sets curser to off . . Anderson Backpack
pause 300
serout 7,N2400,[254,1,"?f?a"] ' special initialization for Anderson Backpack
' sets curser to beginning of row 1
pause 3500 ' give lcd time to initalize after clear
RETURN
'---=== Reports status of RESTROOM to partons on LCD ===---
RESTROOM:
serout 7,N2400,[254,1,"?f?a"]
pause 250
SEROUT 7,N2400, [254,1,"RESTROOMS ARE CLOSED"]
PAUSE 3000
serout 7,N2400,[254,1,"?f?a"]
RETURN
'---=== Reports status of FIRE to partons on LCD ===---
FIRE:
serout 7,N2400,[254,1,"?f?a"]
pause 250
SEROUT 7,N2400, [254,1,"FIRE, PLEASE EVACUATE"]
pause 3000
serout 7,N2400,[254,1,"?f?a"]
RETURN
'---=== Reports status of LAST_CALL to partons on LCD ===---
LAST_CALL:
serout 7,N2400,[254,1,"?f?a"]
pause 250
SEROUT 7,N2400, [254,1, "LAST CALL FOR ALCOHOL, SOON ONLY COFFEE SERVED!"]
'SEROUT 7,N2400,[254,192,]
pause 3000
serout 7,N2400,[254,1,"?f?a"]
RETURN
'---=== Reports status of CLOSING to partons on LCD ===---
CLOSING:
serout 7,N2400,[254,1,"?f?a"]
pause 250
serout 7,N2400,[254,1,"CLOSING TIME THANK YOU AND GOODNIGHT!"]
PAUSE 3000
serout 7,N2400,[254,1,"?f?a"]
RETURN
'---=== GREETING to partons on LCD ===---
GREETING:
serout 7,N2400,[254,1,"?f?a"]
pause 250
serout 7,N2400,[254,1,"WELCOME TO MY PUB"]
PAUSE 3000
serout 7,N2400,[254,1,"?f?a"]
RETURN
'-----------------------------------------
'---------- Main Program Code ------------
'-----------------------------------------
START:
GOSUB INIT_LCD
GOSUB GREETING
MAIN:
'CHECKS STATUS RESTROOMS AND REPORTS TO PATRONS ON LCD
IF FIRE_PIN = 1 THEN
GOSUB FIRE
ELSE
IF RESTROOM_PIN = 1 THEN
GOSUB RESTROOM
ELSE
IF LAST_CALL_PIN = 1 THEN
GOSUB LAST_CALL
ELsE
IF CLOSING_PIN = 1 THEN
GOSUB CLOSING
ELSE
GOSUB GREETING
ENDIF
ENDIF
ENDIF
ENDIF
PAUSE 1000
GOTO MAIN
END
I did not make any changes to the actual code lines you have, but did rearrange them into subroutines that could be called by nested IF...THEN...ELSE...ENDIF statements. This provides the priority levels you wanted. The first IF...THEN that is true will execute and then jump over the subsequent code in the ELSE portion of the statement. Additionally, I added a 5th option (GREETING) if none of the other conditions are true. You can change around the priority any way you want. Also note that I assigned names to the pins to make them easier to understand later on in the code. I haven't access to my compiler right now, so I haven't "run" my version, it isn't bug tested. Also, I am sure there are more ways to "skin this cat" but this is a start.
Bookmarks