Shop OBEX P1 Docs P2 Docs Learn Events
Please review my code. — Parallax Forums

Please review my code.

jdoleckijdolecki Posts: 726
edited 2009-01-23 00:00 in BASIC Stamp
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

Comments

  • Adrian SchneiderAdrian Schneider Posts: 92
    edited 2009-01-22 07:11
    you should use 'return' to return from your subroutines (called with 'gosub') 'single', 'burst' and 'automatic', not 'goto main'.
    regards
    adrian
  • jdoleckijdolecki Posts: 726
    edited 2009-01-22 23:36
    Do I have to load the whole screen each time i want to change one word on the screen?

    thanks
  • AveryAvery Posts: 9
    edited 2009-01-23 00:00
    You can just write over the old text, you don't have to write out the whole screen again.· You have to position the cursor at the beginning of the word you're overwriting and also make sure you add enough spaces to cover the whole word.· For example if you're overwriting 'automatic' with 'burst'· you'll need to add 4 spaces at the end of 'burst' or it will end up·looking like·'burstatic'.
Sign In or Register to comment.