ok, then this should be pretty close
Code:
#CONFIG __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOD_ON & _IESO_ON & _FCMEN_ON
#ENDCONFIG
define OSC 8
OSCCON = %01110000 'Internal RC set to 8MHZ
' ====== VARIABLES ================================================== ===============================
I2CDevice var byte
SDA VAR PORTB.6 ' I2C Data
SCL VAR PORTB.4 ' I2C Clock
LCD_DATA VAR BYTE
COM VAR BYTE ' COMMAND
I VAR BYTE
J VAR BYTE
X VAR BYTE 'LCD POSITION X(0 TO 127)
Y VAR BYTE 'LCD POSITION Y(0 TO 7)
hshift con 28
' ====== INITIALIZE VARIABLES ================================================== ====================
I2CDevice = $78
'======= SSD1306 I2C OLED initialization ================================================== =========
COM = $AE : GOSUB SEND_COMMAND ' turn off oled panel
COM = $D5 : GOSUB SEND_COMMAND ' set display clock divide ratio/oscillator frequency
COM = $80 : GOSUB SEND_COMMAND ' set divide ratio
COM = $A8 : GOSUB SEND_COMMAND ' set multiplex ratio
COM = $3F : GOSUB SEND_COMMAND ' 1/40 duty
COM = $D3 : GOSUB SEND_COMMAND ' set display offset
COM = $0 : GOSUB SEND_COMMAND
COM = $20 : GOSUB SEND_COMMAND
COM = $0 : GOSUB SEND_COMMAND
COM = $AD : GOSUB SEND_COMMAND ' Internal IREF Setting
COM = $30 : GOSUB SEND_COMMAND ' --
COM = $8D : GOSUB SEND_COMMAND ' set Charge Pump enable/disable
COM = $14 : GOSUB SEND_COMMAND ' set(0x10) disable
COM = $68 : GOSUB SEND_COMMAND ' set start line address
COM = $A6 : GOSUB SEND_COMMAND ' set normal display
COM = $A4 : GOSUB SEND_COMMAND ' Disable Entire Display On
COM = $A1 : GOSUB SEND_COMMAND ' set segment re-map 128 to 0
COM = $C8 : GOSUB SEND_COMMAND ' Set COM Output Scan Direction 64 to 0
COM = $DA : GOSUB SEND_COMMAND ' set com pins hardware configuration
COM = $12 : GOSUB SEND_COMMAND '
COM = $81 : GOSUB SEND_COMMAND ' set contrast control register
COM = $7F : GOSUB SEND_COMMAND '
COM = $D9 : GOSUB SEND_COMMAND ' set pre-charge period
COM = $22 : GOSUB SEND_COMMAND '
COM = $DB : GOSUB SEND_COMMAND ' set vcomh
COM = $40 : GOSUB SEND_COMMAND '
COM = $AF : GOSUB SEND_COMMAND ' turn on oled panel
' ====== PROGRAM ================================================== =================================
GOSUB CLEAR_LCD
MAIN:
;7x5 "A"
X = 15 : Y = 0 : GOSUB SET_7
I2CWrite SDA,SCL,I2CDevice,[$40,$fc,$12,$12,$12,$fc]
;14x10 "A"
X = 15 : Y = 2 : GOSUB SET_14
I2CWrite SDA,SCL,I2CDevice,[$40,$f0,$f8,12,12,14,14,12,12,$f8,$f0_
,$ff,$ff,6,6,6,6,6,6,$ff,$ff]
PAUSE 1000
GOTO MAIN
END
' ====== CLEAR LCD ================================================== ===============================
CLEAR_LCD:
COM = $21 : GOSUB SEND_COMMAND
COM = hshift : GOSUB SEND_COMMAND
COM = 71 + hshift : GOSUB SEND_COMMAND
COM = $22 : GOSUB SEND_COMMAND
COM = 0 : GOSUB SEND_COMMAND
COM = 4 : GOSUB SEND_COMMAND
LCD_DATA = 0
FOR J = 0 TO 4
FOR I = 0 TO 71
I2CWrite SDA,SCL,I2CDevice,[$40,LCD_DATA]
NEXT I
NEXT J
RETURN
' ====== SEND COMMAND ================================================== ============================
SEND_COMMAND:
I2CWrite SDA,SCL,I2CDevice,[0,COM]
RETURN
'======= SET_XY ================================================== ==================================
SET_7: '7x5
COM = $21 : GOSUB SEND_COMMAND
COM = X+hshift : GOSUB SEND_COMMAND
COM = x+hshift+4 : GOSUB SEND_COMMAND
COM = $22 : GOSUB SEND_COMMAND
COM = Y : GOSUB SEND_COMMAND
COM = y : GOSUB SEND_COMMAND
RETURN
SET_14: ;14x10
COM = $21 : GOSUB SEND_COMMAND
COM = X+hshift: GOSUB SEND_COMMAND
COM = x+hshift+9 : GOSUB SEND_COMMAND
COM = $22 : GOSUB SEND_COMMAND
COM = Y : GOSUB SEND_COMMAND
COM = y+1 : GOSUB SEND_COMMAND
RETURN
Bookmarks