Shop OBEX P1 Docs P2 Docs Learn Events
Help with connecting uLCD-32PTU to Propeller — Parallax Forums

Help with connecting uLCD-32PTU to Propeller

RobertWRobertW Posts: 66
edited 2014-03-19 05:26 in Propeller 1
Hello,

I received a uLCD-32PTU display a few days ago and am a little gun shy (all right, a little puzzled) as to how to connect it to my Propeller. I have watched Beau Schwabe's Youtube videos about setting the display up for serial communication and that seems to make sense but I am not certain about the wiring connection. The display I purchased from Parallax included the programming cable and the USB adapter. If I understand things correctly, I plug the USB adapter, and 5-pin cable, into the 5-pin programming socket/pins and plug the USB cable into my computer. After I have used the 4D Workshop software to setup the display for serial communication, do I simply disconnect the USB adapter and plug the 5-pin cable into the breadboard on my PPDB (with correct wiring to the breadboard)? Or, do I need to connect the PPDB to the TX0 / RX0 pins in the "I/O expansion header" (H1 in the datasheet).

I would rather not mis-wire something and fry the display right off the bat. Any assistance would be appreciated. Thank you.

Sincerely,
Rob

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-03-17 18:32
    RobertW,

    "After I have used the 4D Workshop software to setup the display for serial communication, do I simply disconnect the USB adapter and plug the 5-pin cable into the breadboard on my PPDB" - Essentially yes. For proper communication, the RX,TX and Reset need to be connected from the display to the Propeller. There is an OBEX demo that has connection data within it.

    OBEX Reference:
    http://obex.parallax.com/object/718
  • RobertWRobertW Posts: 66
    edited 2014-03-17 18:55
    Hi Beau,

    Thank you for your reply. I already downloaded your OBEX demo and saw the 3 pin connection (RX, TX, and Reset). I will give it a try.

    Also, since you replied, I have been meaning to ask, in the demo, how did you convert the .bmp file type logo and picture into the Data section?

    Thank you,
    -Rob
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-03-17 19:01
    "I have been meaning to ask, in the demo, how did you convert the .bmp file type logo and picture into the Data section" - I wrote a program in Visual Basic... I will see if I can dig it up and make it available.
  • RobertWRobertW Posts: 66
    edited 2014-03-17 19:03
    Ok. Thank you.

    -Rob
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-03-18 10:22
    Here is the Visual Basic code that I used to convert the images. It's basically just a raw data dump of the entire file with output formatting that works with SPIN so that the output file can be directly copied and pasted into SPIN. The "pub image" routine within Spin is able to read the raw BMP file. Although the information is contained within the raw BMP file, you do however need to specify the Length and Width as well as the starting X,Y location when calling the "pub image" routine.


    Note: The very last value printed in the output file indicates the size of the image file in BYTES and can be removed, it's just there for debug and should match the original file size.

    VB4 - Code snip BMP2SPIN
    Sub readBMP()
    
    file = "c:/Parallax Inc LOGO.bmp"               'File must not exceed uOLED display dimensions
                                                    'and must be a 256 color BMP.  To conserve space
                                                    'the image should not exceed 64x64 and use a Mode
                                                    'value of "1" when calling the 'image' function
                                                    'from Spin.
    
    outfile = "c:/Parallax Inc LOGO.spin"
    
    ByteWidth = 24
    
    Open outfile For Output As 2
    Open file For Binary As 1
        Seek #1, &H12 + 1
        W1DTH = Asc(Input$(1, 1#))
        Seek #1, &H16 + 1
        HE1GHT = Asc(Input$(1, 1#))
    
        Seek #1, &HD + 1
        BMPdata = Asc(Input$(1, 1#))
        Seek #1, &HC + 1
        BMPdata = BMPdata * 256 + Asc(Input$(1, 1#))
        Seek #1, &HB + 1
        BMPdata = BMPdata * 256 + Asc(Input$(1, 1#))
        Seek #1, &HA + 1
        BMPdata = BMPdata * 256 + Asc(Input$(1, 1#))
      
    Debug.Print "'------------------------ 256 color BMP Image Data below ---------------------------"
    Print #2, "'------------------------ 256 color BMP Image Data below ---------------------------"
    
    Seek #1, 1
    
        Index = 0
        Cnt = 0
        For dd = 0 To BMPdata - 1
            Cnt = Cnt + 1
            ddata = Asc(Input$(1, 1#))
            If Index = 0 Then
               Debug.Print "byte ";
               Print #2, "byte ";
            End If
                
            msg = Hex$(ddata)
            If Len(msg) = 1 Then msg = "0" + msg
            Debug.Print "$"; msg;
            Print #2, "$"; msg;
            
            Index = Index + 1
            If Index = ByteWidth Then
               Index = 0
               Debug.Print ""
               Print #2, ""
            Else
               Debug.Print ", ";
               Print #2, ", ";
            End If
        
        Next dd
        
        
        For yy = 0 To HE1GHT - 1
            For xx = 0 To W1DTH - 1
                Cnt = Cnt + 1
                pixel = Asc(Input$(1, 1#))
                    
                If Index = 0 Then
                   Debug.Print "byte ";
                   Print #2, "byte ";
                End If
                    
                msg = Hex$(pixel)
                If Len(msg) = 1 Then msg = "0" + msg
                Debug.Print "$"; msg;
                Print #2, "$"; msg;
                    
                Index = Index + 1
                If Index = ByteWidth Then
                    Index = 0
                    Debug.Print ""
                    Print #2, ""
                Else
                    Debug.Print ", ";
                    Print #2, ", ";
                End If
                
            Next xx
        Next yy
        Debug.Print Cnt
        Print #2, Cnt
        Close #1
        Close #2
        End
        
    End Sub
    
    128 x 28 - 5K
  • RobertWRobertW Posts: 66
    edited 2014-03-19 05:26
    Thank you Beau. I will have to give this a try.
  • CelticLordCelticLord Posts: 50
    edited 2016-06-28 22:28
    Modified code for VB2010 Express.
  • This will work for VB2010 Express
    Private Sub readBMP()
     
        File = "c:\Users\Celticlord\Desktop\LghtOff.bmp"               'File must not exceed uOLED display dimensions
        '                                                              'and must be a 256 color BMP.  To conserve space
        '                                                              'the image should not exceed 64x64 and use a Mode
        '                                                              'value of "1" when calling the 'image' function
        '                                                              'from Spin.
     
        outFile = "c:\Users\Celticlord\Desktop\LghtOff.txt"
     
        Dim byteWidth As Integer = 24
     
        Dim bytes() As Byte = IO.File.ReadAllBytes(File)
        Dim bytesCount As Integer = bytes.Length
     
        Using writer As New IO.StreamWriter(IO.File.Create(outFile))
            Debug.WriteLine("'------------------------ 256 color BMP Image Data below ---------------------------")
            writer.WriteLine("'------------------------ 256 color BMP Image Data below ---------------------------")
     
            For offset As Integer = 0 To bytesCount - 1 Step byteWidth
                Dim bytesRemaining As Integer = bytesCount - offset
     
                Dim line As String = "byte $" & BitConverter.ToString(bytes, offset, Math.Min(ByteWidth, bytesRemaining)).Replace("-", ", $")
     
                If bytesRemaining > byteWidth Then
                    Debug.WriteLine(line)
                    writer.WriteLine(line)
                Else
                    Debug.WriteLine(line & ",  " & bytesCount.ToString & " ")
                    writer.WriteLine(line & ",  " & bytesCount.ToString & " ")
                End If
            Next
        End Using
     
    End Sub
    
Sign In or Register to comment.