Please review my code.
This is for a paintball gun controller. I have 2x16 Lcd hooked up to display data.
My Questions are?
1: I want Mode and Weapon displayed all the time. the only thing that changes are the "Mode" condition and the Weapon type the Mode conditions·"Single,Burst, Automatic"·starts at line 1 character 7 (L1_C7). I now write·all the data everytime i move to a new subroutine. Am i doing this correctlly? I seem like a lot.
Thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
pb···· PIN 0
trig·· PIN 1
sol··· PIN 14
pbvar· VAR Word
mode·· VAR Word
n9600· CON $4054
I····· CON 254
CLR··· CON 1
Line2· CON 192
L1_C7· CON 134
Main:
PAUSE 125
BUTTON pb, 0, 255, 0, pbvar, 0, mode_select
mode = mode + 1 //· 3
mode_select:
ON mode GOSUB single, burst, automatic
GOTO main
single:
PAUSE 125
SEROUT 15,n9600, [noparse][[/noparse]I,CLR]
PAUSE 1
SEROUT 15,n9600, [noparse][[/noparse]"MODE:"]
SEROUT 15,N9600, [noparse][[/noparse]I,L1_C7]
SEROUT 15,N9600, [noparse][[/noparse]"SINGLE"]
SEROUT 15,N9600, [noparse][[/noparse]I,LINE2]
SEROUT 15,N9600, [noparse][[/noparse]"WEAPON:"]
GOTO main
burst:
PAUSE 125
SEROUT 15,n9600, [noparse][[/noparse]I,CLR]
PAUSE 1
SEROUT 15,n9600, [noparse][[/noparse]"MODE:"]
SEROUT 15,N9600, [noparse][[/noparse]I,L1_C7]
SEROUT 15,N9600, [noparse][[/noparse]"BURST"]
SEROUT 15,N9600, [noparse][[/noparse]I,LINE2]
SEROUT 15,N9600, [noparse][[/noparse]"WEAPON:"]
GOTO main:
automatic:
PAUSE 125
SEROUT 15,n9600, [noparse][[/noparse]I,CLR]
PAUSE 1
SEROUT 15,n9600, [noparse][[/noparse]"MODE:"]
SEROUT 15,N9600, [noparse][[/noparse]I,L1_C7]
SEROUT 15,N9600, [noparse][[/noparse]"AUTOMATIC"]
SEROUT 15,N9600, [noparse][[/noparse]I,LINE2]
SEROUT 15,N9600, [noparse][[/noparse]"WEAPON:"]
GOTO main
My Questions are?
1: I want Mode and Weapon displayed all the time. the only thing that changes are the "Mode" condition and the Weapon type the Mode conditions·"Single,Burst, Automatic"·starts at line 1 character 7 (L1_C7). I now write·all the data everytime i move to a new subroutine. Am i doing this correctlly? I seem like a lot.
Thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
pb···· PIN 0
trig·· PIN 1
sol··· PIN 14
pbvar· VAR Word
mode·· VAR Word
n9600· CON $4054
I····· CON 254
CLR··· CON 1
Line2· CON 192
L1_C7· CON 134
Main:
PAUSE 125
BUTTON pb, 0, 255, 0, pbvar, 0, mode_select
mode = mode + 1 //· 3
mode_select:
ON mode GOSUB single, burst, automatic
GOTO main
single:
PAUSE 125
SEROUT 15,n9600, [noparse][[/noparse]I,CLR]
PAUSE 1
SEROUT 15,n9600, [noparse][[/noparse]"MODE:"]
SEROUT 15,N9600, [noparse][[/noparse]I,L1_C7]
SEROUT 15,N9600, [noparse][[/noparse]"SINGLE"]
SEROUT 15,N9600, [noparse][[/noparse]I,LINE2]
SEROUT 15,N9600, [noparse][[/noparse]"WEAPON:"]
GOTO main
burst:
PAUSE 125
SEROUT 15,n9600, [noparse][[/noparse]I,CLR]
PAUSE 1
SEROUT 15,n9600, [noparse][[/noparse]"MODE:"]
SEROUT 15,N9600, [noparse][[/noparse]I,L1_C7]
SEROUT 15,N9600, [noparse][[/noparse]"BURST"]
SEROUT 15,N9600, [noparse][[/noparse]I,LINE2]
SEROUT 15,N9600, [noparse][[/noparse]"WEAPON:"]
GOTO main:
automatic:
PAUSE 125
SEROUT 15,n9600, [noparse][[/noparse]I,CLR]
PAUSE 1
SEROUT 15,n9600, [noparse][[/noparse]"MODE:"]
SEROUT 15,N9600, [noparse][[/noparse]I,L1_C7]
SEROUT 15,N9600, [noparse][[/noparse]"AUTOMATIC"]
SEROUT 15,N9600, [noparse][[/noparse]I,LINE2]
SEROUT 15,N9600, [noparse][[/noparse]"WEAPON:"]
GOTO main
Comments
regards
adrian
thanks