Code:
'****************************************************************
'* Name : ssd1306_DEMO.PBP *
'* Author : richard *
'* Notice : *
'* : *
'* Date : 19/11/2017 *
'* Version : *
'* Notes : *
'* :FOR pic 16F1619 SSD1306 *
'****************************************************************
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__config _CONFIG2, _WRT_OFF & _PPS1WAY_OFF & _ZCD_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_HI & _LVP_ON
__config _CONFIG3, _WDTCPS_WDTCPS6 & _WDTE_OFF & _WDTCWS_WDTCWS100 & _WDTCCS_LFINTOSC
#ENDCONFIG
define OSC 32
'define OSC 4
; --- *** Oscillator *** ---------------------------------------------------
OSCCON = %11110000 ;32 MHz,
'OSCCON = %01101000 ;4 MHz,
ANSELb = 0
ANSELA = 0
ANSELC = 0
char var byte
x var byte
y var byte
BUFF VAR BYTE[16]
;use this define for hw i2c
;#define hwi2c 1
#DEFINE PIC16 1
;set and uncomment these to use softi2c
SCL var PortB.6 ' I2C Clock PICpin 11
SDA var PortB.4 ' I2C Data PICpin 13
;set these to match display
ssdheight con 7 ; 7 = 8 PAGES 64*128 , 3 = 4 pages 32*128
ssdwidth con 127 ; 128 PIXELS WIDE
'sdd1306_addr con $78
sdd1306_addr con $3C
Include "ssd1306_I2C.INC" ' bring it in
include "font7x5_16.bas"
'========================== MAIN Routine ==============================
gosub glcd_init
BIG_TEXT = 0
looper:
GLCD_CLR
GLCDDHL 0,0,75,1 ;x,y,len,patten
GLCDDHL 0,2,75,128
GLCDDVL 0,0,3 ;x,y,height [in pages]
GLCDDVL 75,0,3
;GLCDSTR 5,1,"--SSD1306--" ;x,y, cont string PIC 18 ONLY
ARRAYWRITE BUFF,["--SSD1306--",0]
GLCDSTR 5,1,BUFF
ARRAYWRITE BUFF,["ABCDEF",0]
CHAR="!"
GLCDC 100,1,CHAR ;x,y , chr
BIG_TEXT = 1
if ssdheight > 3 then
GLCDSTR 2,4,BUFF
ARRAYWRITE BUFF,["@12456-=#",0]
BIG_TEXT = 0
GLCDSTR 2,7,BUFF ;x,y ,str buffer [null terminated]
else
pause 1000
GLCD_CLR
GLCDSTR 2,0,BUFF
ARRAYWRITE BUFF,["@12456-=#",0]
BIG_TEXT = 0
GLCDSTR 2,3,BUFF
endif
PAUSE 3000
GOTO looper
END
Bookmarks