GUI Interface on a 16x2 Serial display code.
Spartan001
Posts: 8
I am wondering if anyone has decent code for a GUI interface on a Bs2. I am currently building a mech and have not yet ordered a display.A 4 way keypad with selector button will be attached to the Bs2. Here is my current code, Suggestions? Will it even work?
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'Transmit CON 0
'Rf_transmitter CON 1
'Rssi CON 2
'Sonar CON 3
'Switch1 CON 4
'Switch2 CON 5
'Switch3 CON 6
'Switch4 CON 7
'Switch5 CON 8
'Display CON 10
'Relay1 CON 11
'Relay2 CON 12
'BS CON 13
UP VAR WORD '4
Down VAR WORD '5
Left VAR WORD '6
Right VAR WORD '7
Middle VAR WORD '8
Z VAR WORD
A VAR WORD
B VAR WORD
E VAR WORD
N VAR WORD
JJ VAR WORD
Time VAR WORD
indistance VAR WORD
Main:
PAUSE 10
GOSUB Weapons_Arming
GOSUB Sensor_Sweep
PAUSE 1
SEROUT 13, 16468, ["!", Up.HIGHBYTE, Up.LOWBYTE, Down.HIGHBYTE, Down.LOWBYTE, Left.HIGHBYTE, Left.LOWBYTE,
Right.HIGHBYTE, Right.LOWBYTE, Middle.HIGHBYTE, Middle.LOWBYTE]
PAUSE 100
LOW 15
SEROUT 0, © 16468, ["!", E.HIGHBYTE, E.LOWBYTE, N.HIGHBYTE, N.LOWBYTE, Z.HIGHBYTE, Z.LOWBYTE,
JJ.HIGHBYTE, JJ.LOWBYTE, A.HIGHBYTE, A.LOWBYTE]
Weapons_Arming:
DEBUG "Weapons Menu", CR, "Coilgun", CR
SEROUT 10, 84, ["Weapons Menu", 13, "Coilgun"]
IF IN4 > 0 THEN RETURN 'Up
IF IN5 > 0 THEN GOSUB Robot_menu 'Down
IF IN6 > 0 THEN GOSUB Rocket 'Left
IF IN7 > 0 THEN GOSUB LED 'Right
IF IN8 > 0 THEN GOSUB Coilgun 'Select
Rocket:
SEROUT 10, 84, ["Weapons Menu", 13, "Rocket"]
IF IN4 > 0 THEN GOTO Weapons_Arming
IF IN6 > 0 THEN GOSUB Led
IF IN7 > 0 THEN GOSUB Coilgun
IF IN8 > 0 THEN GOTO Arm_Rocket
Led:
SEROUT 10, 84, ["Weapons Menu", 13, "Led"]
IF IN4 > 0 THEN GOTO Weapons_Arming
IF IN6 > 0 THEN GOTO Coilgun
IF IN7 > 0 THEN GOTO Rocket
IF IN8 > 0 THEN GOTO Arm_led
Coilgun:
SEROUT 10, 84, ["Weapons Menu", 13, "Coilgun"]
IF IN4 > 0 THEN GOTO Weapons_Arming
IF IN6 > 0 THEN GOTO Rocket
IF IN7 > 0 THEN GOTO Led
IF IN8 > 0 THEN GOTO Arm_coilgun
Arm_Rocket:
SEROUT 10, 84, ["Weapons Menu", 13, "Arm L:Y R:N"]
IF IN4 > 0 THEN GOTO Rocket
IF IN6 > 0 THEN Up = 9
IF IN7 > 0 THEN Up = 11
Arm_Coilgun:
SEROUT 10, 84, ["Weapons Menu", 13, "Arm? L:Y R:N"]
IF IN4 > 0 THEN GOTO Coilgun
IF IN6 > 0 THEN Right = 9
IF IN7 > 0 THEN Right = 11
Arm_Led:
SEROUT 10, 84, ["Weapons Menu", 13, "Arm? L:Y R:N"]
IF IN4 > 0 THEN GOTO Led
IF IN6 > 0 THEN Left = 9
IF IN7 > 0 THEN Left = 11
Robot_Menu:
SEROUT 10, 84, ["Robot Menu", 13, "Forward"]
IF IN4 > 0 THEN
IF IN5 > 0 THEN
IF IN6 > 0 THEN
IF IN7 > 0 THEN
IF IN8 > 0 THEN
System_Menu:
SEROUT 10, 84, ["System Info", 13, "Mark J"]
IF IN4 > 0 THEN
IF IN5 > 0 THEN
IF IN6 > 0 THEN
IF IN7 > 0 THEN
IF IN8 > 0 THEN
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
Sensor_Sweep:
PULSOUT 15, 5
PULSIN 15, 1, time
inDistance = 890 ** time
RETURN
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'Transmit CON 0
'Rf_transmitter CON 1
'Rssi CON 2
'Sonar CON 3
'Switch1 CON 4
'Switch2 CON 5
'Switch3 CON 6
'Switch4 CON 7
'Switch5 CON 8
'Display CON 10
'Relay1 CON 11
'Relay2 CON 12
'BS CON 13
UP VAR WORD '4
Down VAR WORD '5
Left VAR WORD '6
Right VAR WORD '7
Middle VAR WORD '8
Z VAR WORD
A VAR WORD
B VAR WORD
E VAR WORD
N VAR WORD
JJ VAR WORD
Time VAR WORD
indistance VAR WORD
Main:
PAUSE 10
GOSUB Weapons_Arming
GOSUB Sensor_Sweep
PAUSE 1
SEROUT 13, 16468, ["!", Up.HIGHBYTE, Up.LOWBYTE, Down.HIGHBYTE, Down.LOWBYTE, Left.HIGHBYTE, Left.LOWBYTE,
Right.HIGHBYTE, Right.LOWBYTE, Middle.HIGHBYTE, Middle.LOWBYTE]
PAUSE 100
LOW 15
SEROUT 0, © 16468, ["!", E.HIGHBYTE, E.LOWBYTE, N.HIGHBYTE, N.LOWBYTE, Z.HIGHBYTE, Z.LOWBYTE,
JJ.HIGHBYTE, JJ.LOWBYTE, A.HIGHBYTE, A.LOWBYTE]
Weapons_Arming:
DEBUG "Weapons Menu", CR, "Coilgun", CR
SEROUT 10, 84, ["Weapons Menu", 13, "Coilgun"]
IF IN4 > 0 THEN RETURN 'Up
IF IN5 > 0 THEN GOSUB Robot_menu 'Down
IF IN6 > 0 THEN GOSUB Rocket 'Left
IF IN7 > 0 THEN GOSUB LED 'Right
IF IN8 > 0 THEN GOSUB Coilgun 'Select
Rocket:
SEROUT 10, 84, ["Weapons Menu", 13, "Rocket"]
IF IN4 > 0 THEN GOTO Weapons_Arming
IF IN6 > 0 THEN GOSUB Led
IF IN7 > 0 THEN GOSUB Coilgun
IF IN8 > 0 THEN GOTO Arm_Rocket
Led:
SEROUT 10, 84, ["Weapons Menu", 13, "Led"]
IF IN4 > 0 THEN GOTO Weapons_Arming
IF IN6 > 0 THEN GOTO Coilgun
IF IN7 > 0 THEN GOTO Rocket
IF IN8 > 0 THEN GOTO Arm_led
Coilgun:
SEROUT 10, 84, ["Weapons Menu", 13, "Coilgun"]
IF IN4 > 0 THEN GOTO Weapons_Arming
IF IN6 > 0 THEN GOTO Rocket
IF IN7 > 0 THEN GOTO Led
IF IN8 > 0 THEN GOTO Arm_coilgun
Arm_Rocket:
SEROUT 10, 84, ["Weapons Menu", 13, "Arm L:Y R:N"]
IF IN4 > 0 THEN GOTO Rocket
IF IN6 > 0 THEN Up = 9
IF IN7 > 0 THEN Up = 11
Arm_Coilgun:
SEROUT 10, 84, ["Weapons Menu", 13, "Arm? L:Y R:N"]
IF IN4 > 0 THEN GOTO Coilgun
IF IN6 > 0 THEN Right = 9
IF IN7 > 0 THEN Right = 11
Arm_Led:
SEROUT 10, 84, ["Weapons Menu", 13, "Arm? L:Y R:N"]
IF IN4 > 0 THEN GOTO Led
IF IN6 > 0 THEN Left = 9
IF IN7 > 0 THEN Left = 11
Robot_Menu:
SEROUT 10, 84, ["Robot Menu", 13, "Forward"]
IF IN4 > 0 THEN
IF IN5 > 0 THEN
IF IN6 > 0 THEN
IF IN7 > 0 THEN
IF IN8 > 0 THEN
System_Menu:
SEROUT 10, 84, ["System Info", 13, "Mark J"]
IF IN4 > 0 THEN
IF IN5 > 0 THEN
IF IN6 > 0 THEN
IF IN7 > 0 THEN
IF IN8 > 0 THEN
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
Sensor_Sweep:
PULSOUT 15, 5
PULSIN 15, 1, time
inDistance = 890 ** time
RETURN
Comments