MEL PICBASIC Forum - Displaying Videos and Images on 4Dsystems uOLED Serially


  • Displaying Videos and Images on 4Dsystems uOLED Serially

    I have to start by saying that those guys at 4Dsystems really know what they are doing. they have made it very easy to display video, images, and even animated gifs on their Displays.

    - For my setup ill be using the µOLED-128-G1(SGC)
    Note: the (SGC) indicates that this is a serial display and has the 4Dsystems Pmmc firmware loaded.
    - My Controller board consists of a PIC16F877A , 5 Button dedicated RF interface (Key Fob), including Ports B,C,E brought out to the board edge.
    - Also in this setup is the Parallax RFID reader (serial). Radio shack has these on sale for $5. i have a few

    Ok. Lets start with Graphics Composer. Once you download your free copy of Graphics Composer Software, you must read the Graphics Composer manual. Unfortunately there are no links to the manual it is zipped with the software. It fully details how to get images onto your Micro SD card (uSD). There are 2 ways to get your images/videos to your uSD card. plugged directly into you computer as a Drive (recommended). or serially through the Display (which is very very slow).

    I chose to plug it into my computer. Very important to NOT "Quick Format" as it needs to write to the boot sector. when you get all your files loaded via the Device>Load it will give you a TXT icon that you can click on. This TXT file (Below) is the most important part. it basically just hands you the code that you just need to copy and paste into Pic Basic (Pro).

    Code:
    ===========================
    SERIAL-PLATFORM OUTPUT FILE
    ===========================
    
    ---------------------------------------------------------------------------------------
    File "Danger_Laser_Operating.gif"
    Sector Address 0x001000
    Width = 128 Height = 128 Bits = 16 (Location and size may be adjusted depending on image size
                                         and Size Mode selected)
    
    Display Image from Memory Card (Serial Command):
    Syntax:
    @, I, x, y, width, height, colourMode, SectorAdd(hi), SectorAdd(mid), SectorAdd(lo)
    Data:
    0x40, 0x49, 0x00, 0x12, 0x7F, 0x5B, 0x10, 0x00, 0x10, 0x00
    You will need to change all the "0x" to "$" in order for PBP recognize the values. This example only shows one file. the text file would grow depending on how many items you put on your micro SD Card.

    below is an example of PBP Code with the Data given from the TXT File above. This Code basically Turns on a laser and tells the display to show the file "Danger_Laser_Operating.gif" at Sector Address 0x001000.

    Code:
    DEFINE OSC 20
    
    '***************************** RF COMMUNICATION ********************
    
    ADCON1=7
    CMCON=7
    TRISA.0 = 1         ' These lines of code setup my RF Button Link
    TRISA.1 = 1
    TRISA.2 = 1
    TRISA.3 = 1
    TRISA.4 = 1
    
    Symbol Centerbtn  = PORTA.0 
    symbol UP            = PORTA.1       
    symbol Right         = PORTA.2
    Symbol Down        = PORTA.3  
    symbol Left          = PORTA.4 
    
    '*************************************************  *****************
    X               var     byte
    
    '*************************************************  *****************
    Symbol PWRLED  = PORTB.2
    symbol Laser       = PORTD.7        'Port D Output is Driven by a ULN2803 8 Channel Transistor Array
    symbol LCD         = PORTC.0
    
    pause 1000
    
    serout2 LCD,84,[$55]      ' uOLED Initialize
    low laser
    high pwrled
    
    '*************************************************  *****************
    
    Reset:
    gosub cls
    
    Main:
    If centerbtn = 1 then activate_Laser  'press center button to go to activate Laser Loop
    goto Main
    
    '****************** LASER Routine *************************
    
    
    Activate_Laser:
    if centerbtn = 1 then activate_laser        ' Release button to activate
    serout2 LCD,84,[$40, $49, $00, $12, $7F, $5B, $10, $00, $10, $00]    'The code given to us from Graphics Composer
    high laser
    
    Laser_On:
    if centerbtn = 1 then Deactivate     'Press Center button to go to Deactivate loop
    goto laser_on
    
    Deactivate:
    if center = 1 then Deactivate           'Release to Deactivate Laser
    low laser
    gosub cls
    goto main
    
    '****************** CLEAR SCREEN ************************************
    
    CLS:
    for x = 0 to 2
    serout2 lcd,84,[$45]
    next
    return
    Here is the Video of the working code above.





    You will notice that these videos also Implement my RFEFX Logo which is called in a separate routine

    Here are some other code / video examples:

    Code:
    define OSC 20
    
    
    '********************** RFID Tag Data *****************************
    
    
    Tag1 DATA  "0415146D53" '0415146D53   ' 2 cards registered...
    Tag2 DATA  "30700D48A5" '30700D48A5
     
    LastTag         CON     2
    tagNum          VAR     byte                    ' from EEPROM table
    idx             VAR     Byte                    ' tag byte index
    char            VAR     Byte                    ' character from table
    buf             var     byte(10)
    X               var     byte
    
    '*************************************************  *****************
    Symbol PWRLED  = PORTB.2
    symbol LCD     = PORTC.0
    Symbol rfidin  = PORTB.4
    Symbol RFID    = PORTB.5
    pause 1000
    
    serout2 LCD,84,[$55]      ' uOLED Initialize
    high RFID
    high pwrled                  'Software controlled Power LED (if this LED is not on at load check your code)
    
    '*************************************************  *****************
    
    Reset:
    gosub cls
    pause 100
    logo:
    gosub Logo_png             
    
    Main:
    low rfid
    serin2 rfidin,396,1000,Logo,[WAIT(10),str BUF\10]                      '2 Sec Timeout for Logo refresh
    high RFID
    
    '**************** RFID Check Tag Routine *****************
    
    Check_List:
    FOR tagNum = 1 TO lasttag
    FOR idx = 0 TO 9
    READ (((tagNum - 1) * 10) + idx), char        'The Tricky Order of Operation
    IF (char <> buf(idx)) THEN Bad_Char
    NEXT
    GOTO Tag_found
    Bad_Char:
    NEXT
    
    Bad_tag:
    serout2 LCD,84,[$40, $56, $00, $00, $80, $80, $10, $21, $00, $D4, $01, $54, $2E]  
    PAUSE 8000         ' Delay the duration of the length of the File on the uSD card, in this case 8 sec.
    GOTO reset
    
    Tag_Found:
    serout2 LCD,84,[$40, $56, $00, $00, $80, $80, $10, $21, $00, $D4, $01, $1F, $2E]
    pause 8000          ' Delay the duration of the length of the File on the uSD card, in this case 8 sec.
    GOTO reset
    
    
    
    
    '************************* LOGO Routine ********************************
    
    Logo_png:
    serout2 lcd,84,[$40, $49, $00, $30, $7F, $1F, $10, $01, $8A, $EE]
    return
    
    '************************** Clear the LCD ****************************
    
    CLS:
    for x = 0 to 2
    serout2 lcd,84,[$45]
    next
    return



    Code:
    DEFINE OSC 20
    
    '***************************** RF COMMUNICATION ********************
    
    ADCON1=7
    CMCON=7
    TRISA.0 = 1         ' These lines of code setup my RF Button Link
    TRISA.1 = 1
    TRISA.2 = 1
    TRISA.3 = 1
    TRISA.4 = 1
    
    Symbol Center  = PORTA.0 
    symbol UP      = PORTA.1       
    symbol Right   = PORTA.2
    Symbol Down    = PORTA.3  
    symbol Left    = PORTA.4 
    
    '*************************************************  ******
    
    Symbol PWRLED  = PORTB.2
    symbol LCD     = PORTC.0
    pause 1000
    
    serout2 LCD,84,[$55]      ' uOLED Initialize
    high pwrled                  'Software controlled Power LED (if this LED is not on at load check your code)
    
    '**************************************************************
    Reset:
    GOSUB CLS
    PAUSE 100
    Logo:
    GOSUB Logo_png
    
    Main: 
    If Left = 1 then Minions             ' Press Key Fob left button to start play loop
    goto Main
    
    
    '********************** Play Video Routine ********************
    
    Minions:
    if left = 1 then Minions       ' Release left button to Play Video
    serout2 lcd,84,[$40, $56, $00, $00, $80, $80, $10, $21, $04, $3C, $00, $10, $2E]    'Graphics Composer Data
    pause 38000                'Pause the duration of the loaded file (38 Sec)
    goto reset
    
    '************************* LOGO Routine ********************************
    
    
    Logo_png:
    serout2 lcd,84,[$40, $49, $00, $30, $7F, $1F, $10, $01, $8A, $EE]      'Graphics Composer Data
    return
    
    '************************** Clear the LCD ****************************
    
    CLS:
    for x = 0 to 2
    serout2 lcd,84,[$45]
    next
    return
    This article was originally published in forum thread: Displaying Videos and Images on 4Dsystems uOLED Serially started by RFEFX View original post