Shop OBEX P1 Docs P2 Docs Learn Events
Basic stamp conversion help — Parallax Forums

Basic stamp conversion help

kberckkberck Posts: 10
edited 2009-04-13 01:03 in Propeller 1
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!

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-10 16:10
    Hello kberck,

    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
  • kberckkberck Posts: 10
    edited 2009-04-10 16:27
    Thanks for the help Stefan! I wasn't sure if you could separate the various values from a command. So, for instance, could I do this?...

    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!
  • kberckkberck Posts: 10
    edited 2009-04-10 18:43
    I have been testing for a while now with various things, but I just can't seem to get it to display properly.
    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.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-10 20:19
    hello kberck,

    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
  • kberckkberck Posts: 10
    edited 2009-04-12 13:13
    I will try to better detail my situation to eliminate unneeded concern. The display works fine. We have been using it for several months to display all types of text, so wiring is not the problem. We have Bluetooth, GPS, datalogging, A to D conversions, prox, and many other things all working properly off one propeller. The only problem is this one command to display a bit map image to the screen. Anyone who has used this display knows how horrible the instructions are, and how hard it is to even acquire a copy of these bad instructions. Nuts and Volts even mentioned it took talking to 4 different people to finally get anything. Anyway, they set up a bit map image and send it to the display using this command.
    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-12 13:26
    PRI DL_Graphic1 | i, width
      width := @endString - @theString
      ser.tx($1F)
      ser.tx($28)
      ser.tx($66)
      ser.tx($11)
      ser.tx(width & $FF)
      ser.tx(width >> 8)
      ser.tx(1)
      ser.tx(0)
      ser.tx(1)
      repeat i from 0 to width-1
        ser.tx(theString[noparse][[/noparse] i ])
    
    DAT
    theString  byte  %00001100, %00011000
                   byte  %00110000
    endString  byte
    

    Post Edited (Mike Green) : 4/12/2009 1:32:19 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-12 14:00
    Hello Mike,

    I'm again and again positivly impressed by your style of posting smile.gif)

    Some times talking clear sometimes just posting code

    lot's of greetings

    Stefan

    Post Edited (StefanL38) : 4/12/2009 4:44:25 PM GMT
  • kberckkberck Posts: 10
    edited 2009-04-13 01:03
    Thanks Mike! I will give that a shot tomorrow and let you know how it goes. Love the display, but it really isn't new user friendly!
Sign In or Register to comment.