About 0.96" 128x64 SSD1306



THE BOOK of DT's INTERRUPTS is an organization of interrupt service routines and other works written by Darrel Taylor, RIP.

Interrupt routines are arranged per Darrel's original list. Darrel Taylor's Instant Interrupts are an extension of the work of Tim Box whom in October of 2002 wrote INT_CTRL.pbp

Many of the forum members felt this is a long overdue project.

THE BOOK of DT's INTERRUPTS
will be a valuable resource and a tribute to Darrel Taylor the "Fanatical Contributor".

THE BOOK of DT's INTERRUPTS is located at http://dt.picbasic.co.uk/

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Posts
    80

    Default About 0.96" 128x64 SSD1306

    Hi
    About 0.96" 128x64 SSD1306 display
    Someone to help me with this code that was posted there for some time it only works when it starts the first time.
    Any help and welcome on this code
    It seems all right to me, isn't it.
    Code:
    #CONFIG
        __config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF & _PWRTE_OFF & _LVP_OFF & _WRT_OFF   
    #ENDCONFIG 
    
    ;----[Oscillator Setup]---------------------------------------------------------    
    DEFINE OSC 20
    
    ;----[Initialize Hardware]------------------------------------------------------
    TRISA=%11111111:PORTA=%00000000
    TRISC=%10000000:PORTC=%00000000 
    TRISB=%11111111:PORTB=%00000000
    OPTION_REG.7=0
     
    I2CDevice var byte
    SCL var PortC.3          ' I2C Clock  PortB.4
    SDA var PortC.4          ' I2C Data   PortB.1
    TEXT VAR BYTE[20]
    LENGTH VAR BYTE[2]
    DC VAR Byte              ' "DATA OR COMMAND", $40=DATA; $0=COMMAND --> changed from bit to byte
    LCD_DATA VAR BYTE
    COM VAR BYTE             'COMMAND
                             'PAGE VAR BYTE'LCD PAGE(B0 TO B7)
    
    I VAR BYTE
    J VAR BYTE
    X VAR BYTE  'LCD POSITION X(0 TO 127)
    Y VAR BYTE  'LCD POSITION Y(0 TO 7)
    CLEAR
    '=============================================================================
    'PAGE = $B0
    
    I2CDevice = $78      ' X/Y/Z = $3C, Display = $78,
    PAUSE 20
    GOSUB INIT
    GOSUB CLEAR_LCD
    GOSUB TITLE
    
    
    MAIN:
    
        COM=$A6:GOSUB SEND_COMMAND '$A6=NORMAL MODE;$A7=INVERSE MODE
        'PAUSE 100
        COM=$2E:GOSUB SEND_COMMAND
        COM=$27:GOSUB SEND_COMMAND
        COM=$00:GOSUB SEND_COMMAND
        COM=$03:GOSUB SEND_COMMAND
        COM=$04:GOSUB SEND_COMMAND
        COM=$06:GOSUB SEND_COMMAND
        COM=$00:GOSUB SEND_COMMAND
        COM=$FF:GOSUB SEND_COMMAND
        COM=$2F:GOSUB SEND_COMMAND
        PAUSE 10000
        End
        GOTO MAIN
    
    
    '=========================lcd initialization====================================
    INIT:
    
        COM=$AE:GOSUB SEND_COMMAND' DISPALY OFF
        COM=$20:GOSUB SEND_COMMAND' HORIZONTAL MODE
        COM=$00:GOSUB SEND_COMMAND
        COM=$40:GOSUB SEND_COMMAND' DISPLAY START AT 0
        COM=$A1:GOSUB SEND_COMMAND' REMAP 0-127 ----> Mirror display
        COM=$C8:GOSUB SEND_COMMAND' SCAN DIRECTION
        COM=$DA:GOSUB SEND_COMMAND' COM PINS ------> Not Sure what this does
        COM=$10:GOSUB SEND_COMMAND' COM PINS ------> Not Sure what this does
        COM=$A4:GOSUB SEND_COMMAND' DISPLAY ON
        COM=$A7:GOSUB SEND_COMMAND' $A6=NORMAL MODE;$A7=INVERSE MODE
        COM=$AF:GOSUB SEND_COMMAND' DISPLAY ON
        return
    '===============================================================================
    '==============================clear lcd========================================
    CLEAR_LCD:
        FOR J=0 TO 7 
        FOR I=0 TO 127
        LCD_DATA=$00:GOSUB SEND_DATA  ' was $00
        NEXT I
        NEXT J                             
        RETURN 
    
    '****************SEND COMMAND************************************************
    SEND_COMMAND:
        dc=$0
        I2CWrite SDA,SCL,I2CDevice,DC,[COM]
        dc=$40
        RETURN 
    '======================Send data===============================================
    SEND_DATA:
        DC=$40
        I2CWrite SDA,SCL,I2CDevice,DC,[LCD_DATA]
        RETURN
    '=============================FILL=============================================
    FILL:
        FOR J=0 TO 7
        FOR I=0 TO 127
        LCD_DATA=$FF:GOSUB SEND_DATA
        NEXT I
        NEXT J
        RETURN
    '=========================TITLE=================================================
    TITLE:
        X=0:Y=0 :GOSUB SET_XY
        FOR I=0 TO 127
        LOOKUP I,[$00,$40,$60,$50,$7E,$50,$60,$40,$02,$06,$0E,$1E,$3E,$00,$00,$00,_
        $00,$00,$00,$00,$00,$1F,$3F,$60,$60,$60,$60,$60,$60,$3C,$1C,$00,_
        $00,$7F,$7F,$61,$61,$61,$61,$61,$61,$3F,$1E,$00,$00,$1E,$3F,$61,_
        $61,$61,$61,$61,$61,$38,$18,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
        $00,$00,$00,$00,$00,$00,$00,$1F,$3F,$60,$60,$60,$60,$60,$60,$3C,_
        $1C,$00,$00,$1E,$3F,$61,$61,$61,$61,$61,$61,$38,$18,$00,$00,$3F,_
        $7F,$60,$18,$06,$06,$18,$60,$7F,$3F,$00,$00,$00,$00,$00,$00,$00,_
        $00,$00,$00,$1C,$63,$41,$5D,$41,$5D,$41,$5D,$41,$5D,$41,$7F,$00],LCD_DATA
        lcd_data=lcd_data rev 8
        GOSUB SEND_DATA
        NEXT I
    
        X=0:Y=1 :GOSUB SET_XY
        for i=0 to 127
        lookup i,[$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
        $00,$00,$00,$00,$00,$F8,$FC,$06,$06,$06,$C6,$C6,$C6,$FC,$F8,$00,_
        $00,$FE,$FE,$80,$80,$80,$80,$80,$80,$00,$00,$00,$00,$18,$1C,$86,_
        $86,$86,$86,$86,$86,$FC,$78,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
        $00,$00,$00,$00,$00,$00,$00,$F8,$FC,$06,$06,$06,$C6,$C6,$C6,$FC,_
        $F8,$00,$00,$18,$1C,$86,$86,$86,$86,$86,$86,$FC,$78,$00,$00,$FE,_
        $FE,$00,$00,$00,$00,$00,$00,$FE,$FE,$00,$00,$00,$00,$00,$00,$00,_
        $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00],lcd_data
        lcd_data=lcd_data rev 8
        GOSUB SEND_DATA
        NEXT I
    
        X=0:Y=3:GOSUB SET_XY
        for i=0 to 127
        lookup i,[$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$3C,$7E,$C3,$C3,$C3,$C3,_
        $C3,$C3,$71,$30,$00,$00,$7F,$FF,$C3,$C3,$C3,$C3,$C3,$C3,$C3,$C3,_
        $00,$00,$7F,$FF,$C1,$C1,$C1,$C1,$C1,$C1,$FF,$7F,$00,$00,$7F,$FF,_
        $C3,$C3,$C3,$C3,$C3,$C3,$7E,$3C,$00,$00,$3F,$7F,$C0,$C0,$C0,$C0,_
        $C0,$C0,$70,$30,$00,$00,$FF,$FF,$03,$03,$03,$03,$03,$03,$FF,$FF,_
        $00,$00,$C0,$C0,$C0,$C0,$FF,$FF,$C0,$C0,$C0,$C0,$00,$00,$FF,$FF,_
        $0C,$0C,$03,$03,$00,$00,$FF,$FF,$00,$00,$3F,$7F,$C0,$C0,$C0,$C1,_
        $C1,$C1,$79,$39,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00],lcd_data
        lcd_data=lcd_data rev 8
        GOSUB SEND_DATA
        NEXT I
    
        X=0:Y=4:GOSUB SET_XY
        for i=0 to 127
        lookup i,[$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$30,$38,$0C,$0C,$0C,$0C,_
        $0C,$0C,$F8,$F0,$00,$00,$F8,$FC,$0C,$0C,$0C,$0C,$0C,$0C,$0C,$0C,_
        $00,$00,$FC,$FC,$80,$80,$80,$80,$80,$80,$FC,$FC,$00,$00,$FC,$FC,_
        $80,$C0,$60,$30,$18,$0C,$04,$00,$00,$00,$F0,$F8,$0C,$0C,$0C,$0C,_
        $0C,$0C,$38,$30,$00,$00,$FC,$FC,$00,$00,$00,$00,$00,$00,$FC,$FC,_
        $00,$00,$0C,$0C,$0C,$0C,$FC,$FC,$0C,$0C,$0C,$0C,$00,$00,$FC,$FC,_
        $00,$00,$00,$00,$C0,$C0,$FC,$FC,$00,$00,$F0,$F8,$0C,$0C,$0C,$8C,_
        $8C,$8C,$F8,$F0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00],lcd_data
        lcd_data=lcd_data rev 8
        GOSUB SEND_DATA
        NEXT I
    
        X=0:Y=5:GOSUB SET_XY
        for i=0 to 127
        lookup i,[$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$1F,$3F,$30,$30,$30,$30,_
        $30,$30,$30,$30,$00,$00,$0F,$1F,$30,$30,$30,$30,$30,$30,$1F,$0F,_
        $00,$00,$1F,$3F,$30,$30,$30,$30,$30,$30,$1F,$0F,$00,$00,$00,$00,_
        $00,$00,$00,$0F,$1F,$30,$30,$30,$30,$30,$30,$1C,$0C,$00,$00,$30,_
        $30,$30,$30,$3F,$3F,$30,$30,$30,$30,$00,$00,$0F,$1F,$30,$30,$30,_
        $30,$30,$30,$1E,$0E,$00,$00,$3F,$3F,$03,$03,$00,$00,$00,$00,$3F,_
        $3F,$00,$00,$1F,$3F,$30,$30,$30,$30,$30,$30,$3F,$1F,$00,$00,$3F,_
        $3F,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00],lcd_data
        lcd_data=lcd_data rev 8
        GOSUB SEND_DATA
        NEXT I
    
        X=0:Y=6:GOSUB SET_XY
        for i=0 to 127
        lookup i,[$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$FF,$FF,$C0,$C0,$C0,$C0,_
        $C0,$C0,$00,$00,$00,$00,$FC,$FE,$03,$03,$03,$03,$03,$03,$FE,$FC,_
        $00,$00,$FF,$FF,$E0,$F0,$D8,$CC,$C6,$C3,$81,$00,$00,$00,$00,$00,_
        $00,$00,$00,$0C,$8E,$C3,$C3,$C3,$C3,$C3,$C3,$7E,$3C,$00,$00,$03,_
        $03,$03,$03,$FF,$FF,$03,$03,$03,$03,$00,$00,$FC,$FE,$03,$03,$03,_
        $63,$63,$63,$7E,$7C,$00,$00,$FF,$FF,$00,$00,$C0,$C0,$30,$30,$FF,_
        $FF,$00,$00,$FF,$FF,$60,$60,$60,$60,$60,$60,$FF,$FF,$00,$00,$FF,_
        $FF,$03,$03,$03,$03,$03,$03,$03,$03,$00,$00,$00,$00,$00,$00,$00],lcd_data
        lcd_data=lcd_data rev 8
        GOSUB SEND_DATA
        NEXT I
        RETURN
    '===========================================SET X AND Y=========================
    SET_XY:
        COM=$21:GOSUB SEND_COMMAND
        COM=X:GOSUB SEND_COMMAND
        COM=127:GOSUB SEND_COMMAND
        COM=$22:GOSUB SEND_COMMAND
        COM=Y:GOSUB SEND_COMMAND
        COM=Y:GOSUB SEND_COMMAND
        RETURN
    '===============================================================================
    END

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,278


    Did you find this post helpful? Yes | No

    Default Re: About 0.96" 128x64 SSD1306

    Your main loop is this:

    Code:
    MAIN:
    
        COM=$A6:GOSUB SEND_COMMAND '$A6=NORMAL MODE;$A7=INVERSE MODE
        'PAUSE 100
        COM=$2E:GOSUB SEND_COMMAND
        COM=$27:GOSUB SEND_COMMAND
        COM=$00:GOSUB SEND_COMMAND
        COM=$03:GOSUB SEND_COMMAND
        COM=$04:GOSUB SEND_COMMAND
        COM=$06:GOSUB SEND_COMMAND
        COM=$00:GOSUB SEND_COMMAND
        COM=$FF:GOSUB SEND_COMMAND
        COM=$2F:GOSUB SEND_COMMAND
        PAUSE 10000
        End
        GOTO MAIN
    According to this lines, it should send the commands, wait 10sec and then ... END! Meaning the PIC enters an endless loop for ever. So, it realy does what you wanted to do!

    Maybe you wanted to do the above of MAIN series of GOSUB's?

    Ioannis.

  3. #3
    Join Date
    Aug 2008
    Posts
    80


    Did you find this post helpful? Yes | No

    Default Re: About 0.96" 128x64 SSD1306

    Thanks
    Ioannis.
    It is already running
    Thank you for your answer
    peace

Similar Threads

  1. SSD1306 INCLUDE for PBP3
    By richard in forum PBP3
    Replies: 119
    Last Post: - 12th April 2022, 15:27
  2. SSD1306 Include example
    By timc in forum Code Examples
    Replies: 11
    Last Post: - 28th November 2017, 08:53
  3. SSD1306 start display problem
    By harryweb in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2016, 19:16
  4. Replies: 0
    Last Post: - 14th November 2013, 03:32
  5. Help With OLED Display / 128X64 SSD1306
    By Denner in forum General
    Replies: 6
    Last Post: - 25th May 2013, 15:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts