Basic stamp conversion help
kberck
Posts: 10
Hey everyone! I am working through Column #138: Goin' with the glow from Nuts and Volts where he displays a picture on the VFD display using a Basic stamp (trying to translate to spin). Most of it has been fairly easy to translate into spin, however I am having trouble with compiling the Serial string commands. Specifically:
His code:
Put_Crsr:
SEROUT Sout, Baud, [noparse][[/noparse]$1F, $24, col.BYTE0, col.BYTE1, row, 0]
My attempt in spin:
PUB Put_Crsr
ser.str(string($1F, $24, col[noparse][[/noparse]0], col, row, 0))
I get the error pointing directly at the col[noparse][[/noparse]0] saying :"Expecting constant, unary operator or ("
Never used Basic, just Java, python and spin mainly. I tried casting col[noparse][[/noparse]0] to a byte or string, no luck.
Also, if anyone has a sample program using that VFD with the propeller displaying a bit map I would really appreciate it!
His code:
Put_Crsr:
SEROUT Sout, Baud, [noparse][[/noparse]$1F, $24, col.BYTE0, col.BYTE1, row, 0]
My attempt in spin:
PUB Put_Crsr
ser.str(string($1F, $24, col[noparse][[/noparse]0], col, row, 0))
I get the error pointing directly at the col[noparse][[/noparse]0] saying :"Expecting constant, unary operator or ("
Never used Basic, just Java, python and spin mainly. I tried casting col[noparse][[/noparse]0] to a byte or string, no luck.
Also, if anyone has a sample program using that VFD with the propeller displaying a bit map I would really appreciate it!
Comments
the "string"-command can only handle constants. and col[noparse][[/noparse]0] is a array-VARIABLE I guess col and row are variable too.
Depending on the valuerange of your variables col[noparse][[/noparse]0], col and row you have to send it as bytes using the .tx(byte)-method directly
or divide values greater than 255 in a highbyte and a lowbyte and then send them with the .tx-method
best regards
Stefan
PUB Put_Crsr
ser.str(string($1F, $24))
ser.tx(col0)
ser.tx(col1)
ser.tx(row)
ser.tx(0)
assuming I only send bytes.
Thanks!
Here is the basic code:
DL_Graphic1:
SEROUT Sout, Baud, [noparse][[/noparse]$1F, $28, $66, $11, width.BYTE0, width.BYTE1, 1, 0, 1]
For idx = 0 TO width-1
READ (addr + idx), tmpLo
SEROUT Sout, Baud, [noparse][[/noparse]tmpLo]
NEXT
RETURN
Now my spin code:
ser.tx($1F)
ser.tx($28)
ser.tx($66)
ser.tx($11)
ser.tx(0)
ser.tx(4)
ser.tx(1)
ser.tx(0)
ser.tx(1)
ser.tx($FF)
ser.tx($FF)
ser.tx($FF)
ser.tx($FF)
$FF just to turn all bits on for those rows.
please attach the whole program by using the "Post Reply" button and the attachment manager
Also attach a picture of the circuit how it is connected to the basic-stamp and how to the propeller.
F.e. the propeller is a 3.3V device. The basic-stamp is a 5V device this matters to
Theoretical there could be so many different things wrong. It would take a 100 lines post to cover them all.
I think it is something easy but I don't want to guess through the fog of unknown code
best regards
Stefan
setup set picture width and height
SEROUT Sout, Baud, [noparse][[/noparse]$1F, $28, $66, $11, width.BYTE0, width.BYTE1, 1, 0, 1] ' command the VFD to display the bit map image you are about to send.
For idx = 0 TO width-1 ' width is 22 since that is how many words of data that are in bat.
READ (addr + idx), tmpLo ' read in the binary from our bit map file
SEROUT Sout, Baud, [noparse][[/noparse]tmpLo] ' send the binary lines to the display
His binary file is set up like this and bat's address is the index addr with idx just a pointer to get to the next byte
Bat DATA %00001100 ' custom graphic (short)
DATA %00011000
DATA %00110000...
I have tried sending every conversion of tmpLo that I could think of...byte of binary, address to my bit map, string, decimal, hex...I am sure it will be something stupid I am missing. Hope this clears up the confusion.
Post Edited (Mike Green) : 4/12/2009 1:32:19 PM GMT
I'm again and again positivly impressed by your style of posting )
Some times talking clear sometimes just posting code
lot's of greetings
Stefan
Post Edited (StefanL38) : 4/12/2009 4:44:25 PM GMT