Code:
'****************************************************************
'* Name : ssd1306_DEMO.PBP *
'* Author : richard *
'* Notice : *
'* : *
'* Date : 19/11/2017 *
'* Version : *
'* Notes : *
'* :FOR pic 18F26K22 SSD1306 *
'****************************************************************
#CONFIG
CONFIG FOSC = INTIO67
CONFIG PLLCFG = OFF
CONFIG PRICLKEN = OFF
CONFIG FCMEN = OFF
CONFIG IESO = OFF
CONFIG PWRTEN = OFF
CONFIG BOREN = SBORDIS
CONFIG BORV = 190
CONFIG WDTEN = ON
CONFIG WDTPS = 32768
CONFIG CCP2MX = PORTC1
CONFIG PBADEN = OFF
CONFIG CCP3MX = PORTB5
CONFIG HFOFST = ON
CONFIG T3CMX = PORTC0
CONFIG P2BMX = PORTB5
CONFIG MCLRE = EXTMCLR
CONFIG STVREN = ON
CONFIG LVP = OFF
CONFIG XINST = OFF
CONFIG DEBUG = OFF
CONFIG CP0 = OFF
CONFIG CP1 = OFF
CONFIG CP2 = OFF
CONFIG CP3 = OFF
CONFIG CPB = OFF
CONFIG CPD = OFF
CONFIG WRT0 = OFF
CONFIG WRT1 = OFF
CONFIG WRT2 = OFF
CONFIG WRT3 = OFF
CONFIG WRTC = OFF
CONFIG WRTB = OFF
CONFIG WRTD = OFF
CONFIG EBTR0 = OFF
CONFIG EBTR1 = OFF
CONFIG EBTR2 = OFF
CONFIG EBTR3 = OFF
CONFIG EBTRB = OFF
#ENDCONFIG
DEFINE OSC 64
char var byte
x var byte
y var byte
BUFF VAR BYTE[16]
NCO_INT VAR WORD
OSCCON = %01110000
ANSELb = 0
ANSELA = 0
ANSELC = 0
OSCTUNE.6=1
;use this define for hw i2c
#define hwi2c 1
;set and uncomment these to use softi2c
'SCL var PortC.3 ' I2C Clock
'SDA var PortC.4 ' I2C Data
;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
Include "ssd1306_I2C.INC" ' bring it in
include "font7x5_18.bas"
gosub glcd_init
BIG_TEXT = 0
looper:
GLCD_CLR
SSDBM 30,0,64,64 ,kooka
PAUSE 1000
GLCD_CLR
SSDBM 30,0,61,64 ,surfer64
PAUSE 1000
GLCD_CLR
SSDBM 30,0,64,64 ,lizard64
PAUSE 1000
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
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 1000
GOTO looper
END
kooka:
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
@ db 224, 240, 248, 248, 248, 248, 252, 220, 220, 220, 220, 28, 28, 28, 28, 28
@ db 124, 248, 248, 248, 240, 192, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 64, 224, 240, 240, 216, 248, 248, 232, 236, 172, 183
@ db 183, 183, 183, 159, 191, 191, 159, 31, 63, 63, 28, 62, 62, 63, 28, 28
@ db 0, 128, 225, 255, 255, 255, 255, 124, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0
@ db 0, 0, 1, 3, 15, 63, 143, 0, 0, 0, 0, 0, 0, 140, 30, 214
@ db 231, 227, 243, 251, 249, 252, 252, 252, 254, 254, 255, 124, 240, 240, 192, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 3, 15, 248, 128, 6, 62, 255, 255, 191, 191, 255
@ db 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
@ db 252, 128, 0, 0, 0, 24, 248, 252, 255, 255, 15, 7, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 192, 112, 248, 248, 248, 248, 248, 248, 254
@ db 254, 254, 254, 246, 254, 252, 248, 193, 15, 30, 252, 240, 225, 199, 207, 158
@ db 63, 127, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
@ db 255, 255, 254, 62, 30, 31, 31, 15, 15, 15, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 31, 31, 7, 7, 15, 63
@ db 127, 63, 7, 15, 15, 127, 255, 247, 198, 192, 248, 124, 29, 31, 159, 159
@ db 223, 254, 252, 253, 249, 51, 247, 239, 255, 255, 255, 255, 255, 255, 255, 255
@ db 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 224, 127, 15, 128, 224, 248, 252, 127, 31, 15, 15
@ db 7, 7, 7, 7, 3, 0, 0, 0, 0, 3, 63, 254, 255, 255, 125, 251
@ db 255, 223, 222, 254, 206, 224, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 12, 31, 63, 112, 252, 255, 127, 31, 1, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 63, 126, 127
@ db 127, 255, 189, 223, 255, 55, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0
surfer64 :
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 252
@ db 254, 254, 255, 254, 254, 254, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 192, 224, 240, 248, 252, 248, 255, 255, 255
@ db 255, 253, 249, 240, 248, 240, 240, 224, 224, 192, 192, 192, 192, 192, 128, 192
@ db 128, 192, 128, 192, 192, 192, 192, 192, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 128, 252, 255, 95, 15, 7, 63, 255, 255, 255, 255, 255, 255, 255, 63
@ db 31, 2, 0, 0, 1, 1, 1, 1, 1, 3
@ db 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 170, 255, 255, 225, 128, 0, 0, 253, 255
@ db 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 0, 0, 0, 1, 3, 7
@ db 7, 31, 63, 127, 255, 255, 255, 255, 255, 254, 252, 240, 224, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 192, 192, 0, 112, 240, 240, 0, 0, 96, 184, 28, 224, 192, 128, 224
@ db 224, 0, 0, 84, 255, 255, 255, 31, 1, 7, 63, 127, 255, 255, 248, 64
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 16, 16, 145, 147, 83, 182, 117, 165, 53, 43, 77, 106, 235, 227, 231, 252, 243
@ db 239, 240, 224, 255, 255, 255, 193, 192, 192, 192, 128, 192, 131, 223, 255, 255, 248
@ db 192, 128, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 4, 14, 6, 6, 6, 6, 5, 13, 29, 26, 22, 22, 21, 21, 21
@ db 21, 21, 13, 91, 123, 87, 87, 87, 215, 87, 255, 87, 255, 87, 207, 95, 191
@ db 223, 159, 159, 159, 95, 159, 95, 127, 95, 95, 95, 95, 95, 79, 87, 47, 23
@ db 27, 27, 9, 5, 4, 4, 4, 4, 4, 4
lizard64 :
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192
@ db 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 128, 253, 192
@ db 112, 158, 65, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 128, 192, 224, 248, 224, 80, 88, 76, 32
@ db 16, 0, 0, 128, 192, 224, 240, 240, 240, 248, 252, 60, 16, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 127, 127, 127
@ db 127, 105, 116, 240, 240, 248, 248, 248, 248, 152, 128, 192, 192, 192, 192, 224
@ db 192, 224, 228, 238, 255, 255, 255, 255, 253, 251, 251, 241, 241, 241, 241, 248
@ db 248, 252, 124, 63, 31, 15, 7, 7, 7, 3, 1, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 224, 240, 240
@ db 248, 252, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
@ db 127, 63, 63, 63, 63, 63, 31, 31, 31, 15, 95, 255, 255, 255, 223, 207
@ db 195, 128, 128, 128, 192, 160, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 128, 240, 248, 252, 254, 127, 31, 15, 7, 7, 3
@ db 1, 1, 1, 0, 6, 7, 7, 7, 7, 15, 31, 31, 31, 63, 31, 63
@ db 21, 23, 21, 21, 21, 20, 20, 20, 20, 0, 0, 0, 0, 0, 1, 1
@ db 1, 3, 3, 7, 15, 31, 39, 14, 3, 10, 2, 0, 0, 0, 0, 0
@ db 0, 0, 0, 224, 255, 255, 255, 15, 1, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 128, 192, 96, 96, 48, 16, 16, 16, 8, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 7, 63, 127, 248, 240, 192, 192, 128, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 192, 64, 96, 48, 24
@ db 28, 6, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 7, 3, 7, 6
@ db 7, 6, 7, 6, 7, 3, 7, 3, 3, 1, 1, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Bookmarks