drops:
do
gosub GetTheKeyPressed
b3 = key_value
goto DROPSn ; Probably better as a GOSUB with DROPSn terminated by RETURN
loop until key_value >0
return ; ????
DROPSn: ; The correct number of entries (Pn) are displayed on screen and the pause values ready for altering
serout C.7,N2400,(254,157,#b3)
pause 1000
serout C.7,N2400,(254,1)
pause 30
serout C.7,N2400,(254,134,"P1 -",254,139,#w7)
if b3 = 1 then goto inputdata
serout C.7,N2400,(254,192,"P2 -",254,197,#w8)
serout C.7,N2400,(254,202,"P3 -",254,207,#w9)
if b3 = 2 then goto inputdata
serout C.7,N2400,(254,148,"P4 -",254,153,#w10)
serout C.7,N2400,(254,158,"P5 -",254,163,#w11)
if b3 = 3 then goto inputdata
serout C.7,N2400,(254,212,"P6 -",254,217,#w12)
serout C.7,N2400,(254,222,"P7 -",254,227,#w13)
inputdata:
pause 30
do
gosub Get4DigitNumberIntoW7
loop until key_value > 0
if b3 = 1 then goto quit
do
gosub Get4DigitNumberIntoW8
loop until key_value > 0
do
gosub Get4DigitNumberIntoW9
loop until key_value > 0
if b3 = 2 then goto quit
do
gosub Get4DigitNumberIntoW10
loop until key_value > 0
do
gosub Get4DigitNumberIntoW11
loop until key_value > 0
if b3 = 3 then goto quit
do
gosub Get4DigitNumberIntoW12
loop until key_value > 0
do
gosub Get4DigitNumberIntoW13
loop until key_value > 0
quit:
goto mainC ; This jump probably should be in "drops"
return ; Not currently executed
GetKeyPress:
' Wait until no key pressed
Do
Gosub GetTheKeyPressed
Loop Until b1 = 0
' Wait until key pressed
Do
Gosub GetTheKeyPressed
Loop Until b1 <> 0
if key_value = 11 then : let key_value = 0 endif
Return
You want to put the code to recover zero in the 'GetKeyPressed' routine, then anything which calls that will get the right values.Anymore suggestions please guys?
GetKeyPressed:
:
If key_value = 11 Then
key_value = 0
End If
Return
Gosub GetKeyPress : w7 = b1
serout C.7,N2400,(254,139,#w7)
pause 30
Gosub GetKeyPress : w7 = w7 * 10 + b1
serout C.7,N2400,(254,139,#w7)
pause 30
Gosub GetKeyPress : w7 = w7 * 10 + b1
serout C.7,N2400,(254,139,#w7)
pause 30
Gosub GetKeyPress : w7 = w7 * 10 + b1
serout C.7,N2400,(254,139,#w7)
pause 30
Return
If you enter 0,0,0,8, either "8" or "0008" will be displayed depending on whether using #w7, which doesn't display leading zeroes, or using BINTOASCII or something else which does.If a 0 is first keyed in it will come up as a 0 as it is in b1, but then the next keypress if it is a 0 it is multiplied by 10 so it stays as a 0, then again as 0 * 0 = 0 and then the last keypress if it is a 8 will come up as 8 instead of 0008. Some math work needed to sort this conundrum out????
I'm not sure how you exactly mean but you could use a SERTXD or DEBUG to see what's in w7, whether it holds 1000 or something else. You need to determine if the error is in the values for display or simply an issue with what you are seeing on the display or how you are displaying them.but if you go 1000 for instance the last 0 goes were the 1 is and then it gets lost?
Gosub GetTheKeyPressed
Loop Until b1 = 0
' Wait until key pressed
Do
Gosub GetTheKeyPressed
Loop Until b1 <> 0
Gosub GetTheKeyPressed
Loop Until b1 = 15
' Wait until key pressed
Do
Gosub GetTheKeyPressed
Loop Until b1 <> 15
Probably, or adding code which puts out leading zeroes before using #w7 in serout which won't add them. Handling number entry and display can get quite complicated depending on what you want, so the first thing is to define exactly what you want. For example ...it is these 0's that are the problem, as you say its not taking leading 0, so would changing to BINTOASCII cure it?
Did you modify the GetTheKeyPresssed sub as well?Thanks Nick, but that didn't work............
And what do you want it show ?Press "0" : Shows "0"
Press "0" : Shows "0"
Press "1" : Shows "1"
Press "2" : Shows "12"
That's how it shows on the screen exactly.
It seems then, rather than always showing using #w7, just show the last key_value, and only show the full 'w7' number after entering the last digit, and use BINTOASCII for that to split the number into five digits, showing the four least significant.I would like to see
press '0' see '0'
press '0' see '0'
press '2' see '2'
press '0' see '0'
keyed in '0', '0', '2' and '0' see 0020
In other words any key press 0 to 9 I would like to have on screen, so it easier to tell what value you are keying in
Get4DigitNumberIntoW7: ;Coding to change the pause time via keypad
Gosub GetKeyPress : w7 = b1
serout C.7,N2400,(254,139,#b1)
pause 30
Gosub GetKeyPress : w7 = w7 * 10 + b1
serout C.7,N2400,(254,140,#b1)
pause 30
Gosub GetKeyPress : w7 = w7 * 10 + b1
serout C.7,N2400,(254,141,#b1)
pause 30
Gosub GetKeyPress : w7 = w7 * 10 + b1
inc w7
bintoascii w7,b2,b3,b4,b5,b6
debug
serout C.7,N2400,(254,139,b3,b4,b5,b6)
pause 30
Return
I have come to the conclusion that Nick has the answer. After lots of modifications and fiddling with the code it still doesn't do the zero as I want, so looking through past posts and my code, the only logical answer is the b1 = 0 as on debug although it shows on the w7 slot the zero's going in, it's not registering them and looping all the time, hence why it gets lost.Did you modify the GetTheKeyPresssed sub as well?
GetTheKeyPressed: ;Keypad scan coding
key_pos = 0
key_value = 15
High ROW1 : gosub ScanCol : low ROW1
High ROW2 : gosub ScanCol : low ROW2
High ROW3 : gosub ScanCol : low ROW3
High ROW4 : gosub ScanCol : low ROW4
Return
ScanCol:
if COL1 = 1 then : key_value = key_pos + 1 : endif
if COL2 = 1 then : key_value = key_pos + 2 : endif
if COL3 = 1 then : key_value = key_pos + 3 : endif
key_pos = key_pos + 3
return
Sorry to say Nick, but that still doesn't work, I get nothing from the keypad now..........
Do
Gosub GetTheKeyPressed
Loop Until b1 = 0
' Wait until key pressed
Do
Gosub GetTheKeyPressed
Loop Until b1 <> 0
Do
Gosub GetTheKeyPressed
Loop Until b1 = 15
' Wait until key pressed
Do
Gosub GetTheKeyPressed
Loop Until b1 <> 15
You mean like the "inc w7" before the BINTOASCII which changes 00001 to 00002 and 01000 to 01001 ?b2 - '0'
b3 - '1'
b4 - '0'
b5 - '0'
b6 - '1'
Probably a monumental mistake in this snippet!
mainA:
do
gosub GetTheKeyPressed
loop until key_value = 12 ; 12 is the # key on keypad and will start the run sequencw when pressed
goto main1
main1: ;Gives 1 drop from solenoid
high B.7 : low B.6 : low B.5 ;outputs to solenoid, camera and flash
pause w7 : pause w5 : pause w6 ;variable pause times for each output
low B.7 : high B.6 : high B.5
pause 300
low B.6 : low B.5
goto init
....
pause w7 : low B.7
pause w5 : high B.6
pause w6 : high B.5
pause 300
low...
; NB: Sequence of w5,w6 and B.6,B.5 copied from previous code, but not as in textual description
Thanks for that Alan, your 'compact' coding worked a treat.Also, if you're planning to adopt the "compact" code ideas that I posted a few days ago, you now appear to be using the b3 , b4 and b5 variables elsewhere, so you may need to ensure that there are no conflicts (multiple use) of any of those.