Code:
'================== SSD1306 I2C OLED initialization ======================
INIT:
I2CWrite SDA,SCL,I2CDevice,[DC,$AE]'Display OFF
I2CWrite SDA,SCL,I2CDevice,[DC,$D3,$00]' Set offset to 0
'I2CWrite SDA,SCL,I2CDevice,[DC,$40]' Set display start line 0, usually not needed
I2CWrite SDA,SCL,I2CDevice,[DC,$8D,$14]' Set Charge Pump Internal, USUALLY needed
I2CWrite SDA,SCL,I2CDevice,[DC,$20,$10]' Adressing mode $10=Page, $00=Horizontal
I2CWrite SDA,SCL,I2CDevice,[DC,$A1]' set segment remap column 127 as start
i2cwrite sda,scl,I2CDevice,[DC,$C8]' Com Scan Direction, Flip display vertically
i2cwrite sda,scl,I2CDevice,[DC,$DA,$12]' set COM pins = 128x64=$12 128x32=$02
I2CWrite SDA,SCL,I2CDevice,[DC,$81,$7F]' Set contrast to $01 to $FF ($7F is default, $01 is faint)
I2CWrite SDA,SCL,I2CDevice,[DC,$A4]' display ON continue
I2CWrite SDA,SCL,I2CDevice,[DC,$A6]' $A6=NORMAL MODE; $A7=INVERSE MODE
I2CWrite SDA,SCL,I2CDevice,[DC,$AF]'Display ON
' longer delay here because we need to see if display shows random bytes.
' If you see random bytes - your display and INIT are probably working!
pause 500 ' remove when you like
Wait what's DC? Well it should be $00 but I have read it might be $80. Is this why they are only $4 on EBAY?
Bookmarks