SSD1306 OLED (72x40) I2C display from scratch


+ Reply to Thread
Results 1 to 40 of 74

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 OLED (42x40) I2C display from scratch

    Thank you so much Richard!!!

    I'll give it a try to create a super big font.

    Let you know for any progress in the next days
    Roger

  2. #2
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 OLED (72x40) I2C display from scratch

    First look at what it could look like

    Name:  000.png
Views: 14955
Size:  370.0 KB
    Roger

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,161


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 OLED (42x40) I2C display from scratch

    It looks great!

    Well done Roger!

    Ioannis

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 OLED (42x40) I2C display from scratch

    ...credits are all for Richard
    Roger

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,666


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 OLED (42x40) I2C display from scratch

    something to consider about fonts
    it looks like you want 40x22 size font
    a pic16 has a flash word size of 14 bits therefore a font that size
    will take if encoded horizontally by row take 2x40 words per chr
    it will take 3x22 words if encoded vertically by column a reasonable saving.

    one of the benefits of the ssd1306 controller is that it can address its graphics ram either way with ease
    Name:  fonts.jpg
Views: 13781
Size:  197.5 KB
    Warning I'm not a teacher

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default SSD1306 OLED (72x40) I2C display from scratch

    Richard,

    I'm still trying to understand your previous post but just for now, there's a question burning my mind: how do I address the display pixel by pixel?
    Roger

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,666


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 OLED (42x40) I2C display from scratch

    you cannot, the smallest element is 1 byte ie one column[page] of 8 rows
    Warning I'm not a teacher

  8. #8
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default SSD1306 OLED starts up 10 times out of 11 or so

    For any reason, my OLED module won't start up once out of ten or twenty times.

    I have no clue why.

    I change OLED modules (I have five and do all the same), changes breadboards, changed µC... I don't know what to try next.

    Any idea?

    Code:
    ' OLED-72x40_16F18446
    
    ' ====== FUSES =====================================================================================
    ' External oscillator
    #CONFIG
        __config _CONFIG1, _FCMEN_OFF & _CSWEN_OFF & _CLKOUTEN_OFF & _RSTOSC_EXT1X & _FEXTOSC_HS
        __config _CONFIG2, _MCLRE_OFF & _PWRTS_PWRT_64 & _LPBOREN_OFF & _BOREN_OFF & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_SWDTEN & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTD_OFF & _WRTSAF_OFF & _LVP_OFF
        __config _CONFIG5, _CP_OFF
    #ENDCONFIG
    
    @ ERRORLEVEL -306
    @ ERRORLEVEL -202
    
    ' ====== REGISTERS =================================================================================
    ANSELB  = %00000000
    
    ' ====== DEFINES ===================================================================================
    DEFINE OSC 32
    DEFINE NO_CLRWDT 1   ' don't waste cycles clearing WDT  
    DEFINE HSER_CLOERR 1 ' automatic clear overrun error 
    DEFINE I2C_SLOW 1    ' if >8MHz
    
    ' ====== VARIABLES =================================================================================
    SDA         VAR PORTB.5 ' I2C Clock
    SCL         VAR PORTB.6 ' I2C Data
    
    ' SSD1306 OLED 72x40 module (has built-in 10k pull-up on SDA/SCL)
    I2CDevice   CON $78
    Page        VAR BYTE ' OLED's Pages 0..4
    
    ' ====== SSD1306 I2C OLED initialization ===========================================================
    PAUSE 500 ' let display settle
    
    ' Initializing command set
    I2CWrite SDA,SCL,I2CDevice,[$00,$AE,$D5,$80,$A8,$3F,$D3,$00,$20,$00,$AD,$30,$8D,$14,$68,$A6,$A4,_
        $A1,$C8,$DA,$12,$81,$7F,$D9,$22,$DB,$40,$2E,$AF]
    PAUSEUS 50    
    
    ' ====== PROGRAM STARTUP ===========================================================================
    STARTUP:
        Gosub CLEAR_DISPLAY_FULL
    
    ' ====== MAIN PROGRAM ==============================================================================
    MAIN:
        GOSUB SPLASH1
        PAUSE 2000
        GOSUB SPLASH2
        PAUSE 2000
        GOTO MAIN
    END
    
    ' ====== CLEAR FULL DISPLAY ROUTINE ================================================================
    CLEAR_DISPLAY_FULL:
        I2CWrite SDA,SCL,I2CDevice,[$00,$21,28,99,$22,0,4]
        FOR Page = 0 TO 4
            I2CWrite SDA,SCL,I2CDevice,[$40,_
                0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _
                0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _
                0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _
                0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        NEXT Page    
        RETURN
    
    ' ====== SPLASH SCREEN DISPLAY =====================================================================
    SPLASH1:
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,252,252,252,60,28,28,28,56,248,248,240,192,0,0,0,252,252,252,0,0,0,0,192,240,248,120,60,28,28,28,28,60,248,248,240,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,255,255,255,56,56,56,56,60,31,31,15,3,0,0,0,255,255,255,0,0,0,62,255,255,255,128,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,15,15,15,0,0,0,0,0,0,0,0,0,0,0,0,15,15,15,0,0,0,0,1,3,7,15,14,14,12,14,14,15,15,7,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,252,252,140,140,204,252,120,0,0,0,96,96,32,32,224,224,0,0,192,224,224,32,32,96,64,0,0,192,236,108,0,128,192,224,96,32,96,96,64,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,63,55,49,49,57,31,31,6,0,28,62,54,34,18,63,63,7,0,16,56,49,35,55,62,30,0,0,56,63,15,0,0,31,63,48,48,48,56,24,0,0]
        RETURN
        
    SPLASH2:
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,128,128,192,192,0,0,0,0,128,192,192,192,192,192,128,0,0,192,192,192,192,192,192,0,0,128,128,192,192,0,0,0,0,128,192,64,192,128,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,192,192,192,0,0,0,128,192,192,192,192,192,128,0,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,1,129,255,255,128,0,0,0,255,255,136,12,140,249,249,0,0,255,255,12,12,12,12,0,0,1,129,255,255,128,0,0,99,255,32,8,156,255,99,0,0,96,120,124,103,99,255,255,96,0,0,96,120,124,103,99,255,255,96,0,0,255,255,136,12,140,249,249,0,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,0,0,0]
        I2CWrite SDA,SCL,I2CDevice,[$40,_
            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        RETURN
    Roger

Similar Threads

  1. big char oled display
    By mombasa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th September 2020, 07:02
  2. SSD1306 start display problem
    By harryweb in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2016, 19:16
  3. Cannot drive I2C Oled :(
    By elcrcp in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 20th August 2016, 12:19
  4. OLED Display Noise problem
    By gunayburak in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 5th July 2016, 10:15
  5. Help With OLED Display / 128X64 SSD1306
    By Denner in forum General
    Replies: 6
    Last Post: - 25th May 2013, 15:40

Members who have read this thread : 22

You do not have permission to view the list of names.

Posting Permissions

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