Announcement

Collapse
No announcement yet.

uOLED 128 G2 - Having Troubles Displaying Bitmap Data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • uOLED 128 G2 - Having Troubles Displaying Bitmap Data

    Hi guys,
    I have the uOLED 128 G2 (ordered it off Paralax website), here is the link:
    http://www.parallax.com/product/28081

    I am describing my problem from the perspective of the Propeller micro controller, but my problem is universal, I really just need to know the format of how the bitmaps are supposed to be inputted, and what tools are you guys using to convert a bitmap into the hex data so I can store it in my code file manually.

    I currently have it connected to a propeller microcontroller, and I am using the "oLED-128-G2_v2.1" library to communicate with it. So far everything is working fine, I can write text, draw lines, etc.

    I am having problems displaying bitmaps. I am wanting to define a bitmap in the "dat" section of a .spin file, similarly to the "ParallaxIncLOGO" and the "ChipGracey" found in the "oLED-128-G2_DEMO_v2.1b" library. I cannot figure out the format, and how to convert a .bmp file to the hex array. I started small, and was attempting just a 4x4 bitmap file, but I can't seem to get it right... the 4x4 area on the screen is all jumbled and looks like I don't have my format right. I attached a sample image that I'm trying to get to display on the screen "blocks.bmp". I tried using some converter programs, and I get this as the output of the bitmap file:

    Code:
      
     {0xff0000, 0xffffff, 0xffffff, 0xffffff, 0x00ff00, 0xffffff, 0xffffff, 0xff0000, 0x0000ff, 0xffffff, 0xffffff, 0x00ff00, 0xffffff,  0xffffff, 0xffffff, 0x0000ff};


    So I manually converted it to SPIN like so:
    Code:
      
     dat  TestChar '------------------------ 256 color BMP Image Data below --------------------------- byte $ff, $00, $00 byte $ff, $ff, $ff  byte $ff, $ff, $ff  byte $ff, $ff, $ff  byte $00, $ff, $00  byte $ff, $ff, $ff  byte $ff, $ff, $ff  byte $ff, $00, $00  byte $00, $00, $ff  byte $ff, $ff, $ff  byte $ff, $ff, $ff  byte $00, $ff, $00  byte $ff, $ff, $ff  byte $ff, $ff, $ff  byte $ff, $ff, $ff  byte $00, $00, $ff


    I then use this code to write to the display:
    Code:
      
     LED.image(0,0,4,4,0,@TestChar)


    However, this just looks like a bunch of random pixels on the display.


    Any help is greatly appreciated, thanks!

  • #2
    The Display is expecting 565 RGB colour, looks like you are sending it 888 RGB colour
    Mark

    Comment


    • #3
      Thanks for the response! This is the function that is sending the data to the display:
      Code:
      pub image(x, y, h, w, mode, data)|index,BMPdataTable,temp,R,G,B,Co
      '-------------------------------------------------------------------------      Note: The image should be a standard
      '--------------------------------┌───────┐--------------------------------            8-Bit 256 color BMP image and
      '--------------------------------│ image │--------------------------------            not exceed 128x128.
      '--------------------------------└───────┘--------------------------------            To save space, use a 64x64 image
      '-------------------------------------------------------------------------            with mode set to 1
      {{
      Description:
      display image based on the string of data input in the "data" parameter. starting at location x,y with height "h"
      and width "W"... 'mode' is legacy compatibility and is not used the same as before. It was used for defining an 8-bit
      color reference or 16-Bit color reference to save program space.  Which sacrificed color depth for resolution.  The
      function implemented here uses the full 16-bit color reference and instead to save space sacrifices resolution. When
      mode is equal to 0 you get the full color and full resolution.  When mode is equal to 1 you get the full color and half
      the resolution.  In other words, the image is displayed twice as big in both the X and the Y.
      
      MODE = 0  16 bit 5-6-5 color 128x128 pixel images
      MODE = 1  16 bit 5-6-5 color 64x64 pixel images (saves space)
      
      Returns:
      Ack = 255
      }}
      mode &= 1                                              
      ''       find BMP data table                            
      index := $0D                                                                        
      BMPdataTable := byte[data][index--]                        
      repeat 3                                                                                          
        BMPdataTable := BMPdataTable<<8 + byte[data][index--]
                                                              
      ''       Go to beginning of BMP color table            
      index := $36                                            
      ''color data is arranged in GBRA (Blue,Green,Red,Alpha) and there are 256 colors each of which are 8 bits.  To convert  
      ''the 8-8-8 BMP into the uOLED 5-6-5 format we need to divide the Red and Blue channel by 8 while dividing the Green      
      ''Channel by 4 and then create a composite which is only 1 WORD wide.
      
      ''      Load 256 palette table into user space
      repeat temp from 1 to 256                            
        B := byte[data][index++]>>3                           '<-- Convert colors from 8-8-8 to 5-6-5
        G := byte[data][index++]>>2
        R := byte[data][index++]>>3
                        index++                               '<-- Place holder for Alpha ; not used
        C0L0RPalette[temp] := R<<11+G<<5+B                    '<-- pack 5-6-5 colors into WORD
      
      ''       Go to beginning of BMP data table
      index := BMPdataTable
      ''The remaining BYTES define the data.  Each BYTE represents one pixel where the value
      ''points to one of the 256 colors in the color palette defined above.
      
      SendData(_BlitComtoDisplay)                              
      SendData(x)                                              
      SendData(y)                                                
      SendData(w<<mode)                                          
      SendData(h<<mode)
      
      waitcnt(clkfreq/500+cnt)                                          
                                                                
      index += (w * (h-1) )                                      
      repeat h                                                  
        repeat 1<<mode
          repeat w
            temp := index++
            repeat 1<<mode
              Co := C0L0RPalette[byte[data][temp]+1]
              SendData(Co)
              
          index -= w
        index -= w
      
      _Ack := ser.CharIn
      It looks like its converting it to the 565 format before sending it to the display.

      Comment


      • #4
        Hmm, so that little bit of extra information makes it look like it should work.

        Have you asked in the parallax forums? They wrote this library and will be more familiar with it's 'quirks'

        What baud rate are you using? At high baud rates you probably need to add a small delay, but really 'waitcnt(clkfreq/500+cnt)' is in the right place and appears to be doing that for you aleady.

        I'm note sure about the endianness of the properller, but really if it is wrong, it should have failed initial testing
        Mark

        Comment


        • #5
          I currently have a topic started in the parallax forums as well (still no luck over there either):
          http://forums.parallax.com/showthrea...ng-Bitmap-Data

          Below is a 64 x 50 pixel image of Chip Gracey, this is what is used in the demo, here is the video and data: https://www.youtube.com/watch?v=8Ou2VjV_3IE

          Code:
          ChipGracey
          '------------------------ 256 color BMP Image Data below ---------------------------
          byte $42, $4D, $B6, $10, $00, $00, $00, $00, $00, $00, $36, $04, $00, $00, $28, $00, $00, $00, $40, $00, $00, $00, $32, $00
          byte $00, $00, $01, $00, $08, $00, $00, $00, $00, $00, $80, $0C, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
          byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $06, $03, $01, $00, $06, $07, $09, $00, $07, $08, $0A, $00, $0B, $04
          byte $02, $00, $09, $0B, $0D, $00, $0B, $0E, $12, $00, $0D, $11, $15, $00, $0E, $13, $1A, $00, $14, $08, $04, $00, $11, $0E
          byte $17, $00, $11, $15, $1A, $00, $0E, $14, $24, $00, $14, $1A, $25, $00, $15, $1C, $36, $00, $1B, $23, $2C, $00, $1D, $26
          byte $35, $00, $26, $0E, $06, $00, $2C, $12, $08, $00, $34, $0F, $05, $00, $39, $13, $08, $00, $3B, $1F, $12, $00, $21, $26
          byte $2B, $00, $23, $29, $34, $00, $2B, $33, $3B, $00, $17, $1F, $43, $00, $19, $1E, $55, $00, $1B, $24, $45, $00, $1B, $26
          byte $58, $00, $23, $2A, $49, $00, $23, $2D, $5C, $00, $2E, $3A, $4D, $00, $2B, $37, $56, $00, $36, $3E, $47, $00, $34, $3B
          byte $5B, $00, $21, $2A, $65, $00, $28, $34, $69, $00, $2C, $39, $79, $00, $33, $3A, $69, $00, $32, $3D, $78, $00, $3B, $44
          byte $4C, $00, $3C, $44, $56, $00, $38, $44, $6B, $00, $39, $45, $77, $00, $48, $18, $08, $00, $58, $1A, $07, $00, $5B, $21
          byte $0B, $00, $47, $28, $22, $00, $64, $1F, $06, $00, $70, $1C, $04, $00, $68, $23, $09, $00, $68, $2E, $11, $00, $64, $35
          byte $1B, $00, $78, $26, $07, $00, $79, $32, $0B, $00, $74, $35, $13, $00, $69, $30, $2B, $00, $67, $3D, $3A, $00, $7A, $36
          byte $39, $00, $4C, $38, $41, $00, $5E, $43, $30, $00, $40, $47, $4C, $00, $45, $4D, $56, $00, $49, $56, $5F, $00, $43, $47
          byte $68, $00, $43, $4A, $77, $00, $4C, $58, $66, $00, $47, $53, $79, $00, $54, $5D, $66, $00, $54, $54, $74, $00, $59, $62
          byte $6B, $00, $5C, $68, $71, $00, $63, $6D, $78, $00, $69, $73, $7B, $00, $75, $65, $63, $00, $77, $6F, $74, $00, $76, $78
          byte $7C, $00, $37, $46, $86, $00, $3D, $4B, $92, $00, $43, $4D, $83, $00, $42, $4E, $99, $00, $4B, $57, $88, $00, $4B, $5A
          byte $98, $00, $51, $5F, $9A, $00, $49, $5A, $A6, $00, $53, $5B, $B3, $00, $4E, $62, $8D, $00, $54, $61, $87, $00, $59, $67
          byte $99, $00, $5F, $70, $9D, $00, $4F, $61, $A0, $00, $4D, $60, $B1, $00, $56, $66, $A7, $00, $59, $69, $B5, $00, $5E, $74
          byte $A4, $00, $7A, $5A, $80, $00, $64, $6B, $88, $00, $67, $66, $92, $00, $6E, $7A, $88, $00, $6C, $77, $97, $00, $78, $66
          byte $85, $00, $78, $6B, $9C, $00, $77, $7E, $84, $00, $74, $7C, $9B, $00, $61, $6D, $A8, $00, $60, $6D, $B7, $00, $67, $76
          byte $A8, $00, $67, $77, $B6, $00, $74, $7C, $A4, $00, $73, $7F, $B5, $00, $68, $6B, $C4, $00, $6B, $7A, $C5, $00, $74, $7E
          byte $CA, $00, $7A, $7D, $D0, $00, $7D, $84, $8A, $00, $7E, $8B, $96, $00, $6E, $83, $B6, $00, $78, $84, $AD, $00, $78, $87
          byte $B9, $00, $7C, $92, $BB, $00, $6E, $82, $C3, $00, $78, $88, $C8, $00, $79, $88, $D1, $00, $7D, $92, $CA, $00, $7F, $90
          byte $D6, $00, $87, $2C, $07, $00, $8C, $33, $0A, $00, $8A, $3D, $16, $00, $96, $2E, $06, $00, $99, $38, $0A, $00, $97, $3E
          byte $10, $00, $83, $3F, $29, $00, $A7, $3B, $0A, $00, $AE, $3D, $12, $00, $B3, $3E, $09, $00, $89, $43, $11, $00, $9A, $45
          byte $16, $00, $8A, $44, $27, $00, $9B, $4C, $25, $00, $9F, $4E, $37, $00, $97, $58, $39, $00, $AB, $42, $0D, $00, $A9, $48
          byte $13, $00, $A9, $51, $1C, $00, $B6, $45, $0C, $00, $B4, $4B, $12, $00, $BA, $54, $17, $00, $AA, $57, $25, $00, $A7, $5B
          byte $32, $00, $BB, $4C, $20, $00, $AC, $60, $2C, $00, $AA, $62, $35, $00, $BD, $63, $23, $00, $84, $5B, $52, $00, $99, $56
          byte $49, $00, $93, $64, $4C, $00, $9E, $6D, $57, $00, $9E, $72, $5B, $00, $8C, $6B, $7A, $00, $9A, $7F, $6D, $00, $95, $7E
          byte $74, $00, $A6, $6A, $4C, $00, $A5, $76, $5E, $00, $A5, $7C, $64, $00, $C3, $4A, $0C, $00, $C1, $4F, $13, $00, $C4, $54
          byte $0E, $00, $C3, $58, $15, $00, $C5, $64, $1F, $00, $C6, $67, $22, $00, $C4, $7B, $57, $00, $8D, $80, $7D, $00, $95, $82
          byte $7C, $00, $82, $88, $8D, $00, $84, $8D, $93, $00, $85, $8F, $99, $00, $89, $8F, $94, $00, $87, $90, $97, $00, $85, $91
          byte $9B, $00, $8A, $91, $96, $00, $8C, $94, $9B, $00, $8F, $98, $9F, $00, $99, $8A, $89, $00, $95, $93, $96, $00, $90, $96
          byte $9B, $00, $92, $99, $9E, $00, $9C, $9A, $9D, $00, $83, $8A, $A2, $00, $82, $8D, $BB, $00, $8D, $98, $A4, $00, $84, $93
          byte $BE, $00, $93, $9C, $A3, $00, $93, $9E, $A8, $00, $9A, $9E, $A2, $00, $98, $9E, $A9, $00, $95, $9C, $BE, $00, $97, $A0
          byte $A6, $00, $96, $A1, $AA, $00, $99, $A1, $A6, $00, $9B, $A5, $AB, $00, $9F, $A8, $AE, $00, $9D, $A8, $B2, $00, $B5, $95
          byte $81, $00, $A1, $A9, $AE, $00, $A3, $AC, $B3, $00, $A3, $AF, $B8, $00, $A8, $AF, $B4, $00, $A7, $B2, $BA, $00, $BE, $AF
          byte $A5, $00, $81, $8E, $CB, $00, $84, $8D, $D5, $00, $87, $97, $C8, $00, $88, $98, $D7, $00, $92, $9E, $DA, $00, $93, $9F
          byte $E1, $00, $8B, $A1, $CB, $00, $8D, $A4, $D3, $00, $96, $A6, $DB, $00, $9C, $B2, $DF, $00, $8F, $A1, $E0, $00, $9C, $A9
          byte $E2, $00, $9F, $B0, $E7, $00, $A3, $AB, $CE, $00, $A0, $AA, $DD, $00, $AB, $B8, $C1, $00, $A7, $B3, $DB, $00, $B2, $BD
          byte $C4, $00, $A3, $AD, $E4, $00, $A9, $B3, $E7, $00, $B2, $BA, $EA, $00, $BC, $C2, $EE, $00, $CE, $A4, $89, $00, $C4, $C8
          byte $C8, $00, $C5, $C8, $D7, $00, $C0, $C6, $EE, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF
          byte $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF
          byte $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF
          byte $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $FF, $FF, $FF, $00, $84, $91
          byte $8E, $84, $92, $90, $90, $A7, $90, $86, $90, $84, $90, $A7, $81, $A4, $A7, $A7, $81, $90, $A7, $A7, $91, $92, $93, $88
          byte $34, $81, $AA, $E9, $E9, $E9, $E9, $E8, $E7, $9B, $36, $37, $14, $7E, $81, $90, $A8, $31, $84, $91, $84, $7D, $8D, $90
          byte $90, $92, $86, $90, $90, $90, $90, $8E, $35, $90, $81, $84, $84, $81, $90, $91, $81, $90, $90, $92, $90, $A7, $A7, $91
          byte $91, $84, $A7, $A7, $84, $92, $A7, $A4, $81, $A4, $A7, $92, $91, $84, $89, $8C, $2F, $D0, $D9, $D3, $BC, $76, $6D, $6A
          byte $61, $CA, $8B, $13, $37, $2C, $7D, $84, $90, $35, $84, $90, $8D, $7D, $84, $90, $90, $90, $90, $90, $90, $91, $90, $92
          byte $32, $84, $90, $7D, $84, $81, $92, $81, $92, $91, $90, $90, $90, $A7, $A7, $84, $92, $84, $90, $A6, $91, $86, $A7, $A7
          byte $80, $90, $A7, $81, $80, $90, $8F, $3C, $60, $D3, $D3, $D3, $D3, $BC, $76, $6B, $58, $41, $A0, $83, $2D, $12, $32, $7D
          byte $8E, $35, $81, $91, $80, $7D, $84, $91, $90, $90, $8D, $90, $91, $86, $91, $A4, $2C, $84, $84, $84, $81, $81, $8E, $8D
          byte $90, $92, $91, $92, $90, $A4, $90, $8E, $90, $8E, $84, $A7, $86, $84, $A7, $A6, $8D, $A4, $90, $35, $A7, $A7, $90, $0A
          byte $6B, $D3, $D3, $D3, $D3, $BC, $76, $6B, $53, $4F, $26, $99, $34, $2C, $11, $7D, $81, $35, $7D, $84, $8E, $35, $8E, $91
          byte $91, $91, $84, $91, $86, $91, $90, $A7, $2D, $8D, $81, $8D, $81, $7E, $8E, $8E, $90, $92, $92, $92, $90, $A9, $84, $A6
          byte $A7, $90, $81, $A4, $92, $84, $A4, $A7, $84, $90, $98, $30, $A7, $92, $A4, $38, $6B, $D3, $D3, $D3, $D3, $BC, $76, $68
          byte $52, $2B, $24, $39, $88, $35, $09, $32, $7D, $35, $7D, $8E, $80, $35, $84, $8D, $91, $90, $91, $86, $91, $90, $91, $91
          
          EDIT: I had to truncate the data because the forum would not allow this many characters
          So this outputs just fine to the display, so I know the mechanics of everything is working properly... its just when I try to make my own it does not work.

          Comment


          • #6
            Hmm, that's only using 256 colours, so I wonder if it is an endianness issue.

            Is there a command that you can use to swap the high and low bytes of 'Co' before sending it?
            Mark

            Comment


            • #7
              I'm not sure I am following you, can you explain?

              Comment


              • #8
                http://en.wikipedia.org/wiki/Endianness

                4DGL has the ByteSwap() command to change endianness, but in this case you will need to do it on your controller, so you will need to find the appropriate function, or just do it longhand
                Mark

                Comment

                Working...
                X