-
1 Attachment(s)
Re: SSD1306 INCLUDE for PBP3
Quote:
I also got the two Label after column 1 warnings (GLCDS_BAR_?CCBWC) etc but it turns out that there's a whitespace infront of those two macro labels on the include file. There was also an ELSE in column 1 causing another warning.
i had a look at the org file i posted and it has the same errors, i always have trouble with white space
also found 2017 version where the glcd_clrxy routine was ok, so i must have broken it when i added the bar stuff
this is better
Code:
glcd_clrxy: ' clear area x1y1 to x2 y2
FOR GRX = 0 TO 31
glcd_buff[GRX] = glcdData
NEXT
CTEMP = (1 + GX_ - GX)*(1 + GY_ - GY)
gosub setxy
glcd_rad=32
GRX = CTEMP/32
while grx
gosub ssd_data
grx=grx-1
wend
glcd_rad = CTEMP//32
IF glcd_rad THEN
gosub ssd_data
ENDIF
return
-
Re: SSD1306 INCLUDE for PBP3
-
Re: SSD1306 INCLUDE for PBP3
I'm trying to run this on 16F886
and getting error
ASM Symbol not previously defined FSR1L Error 113
Any ideas?
-
Re: SSD1306 INCLUDE for PBP3
Wrong MCU selected on the IDE?
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
Quote:
I'm trying to run this on 16F886
and getting error
ASM Symbol not previously defined FSR1L Error 113
my expectation is that old clunker chips with only one FSR register will likely not have enough Flash and/or Sram
to be useful with this sort of display, the code makes no allowance for them
-
Re: SSD1306 INCLUDE for PBP3
Well, as author stated, this code is suited for 16F series and fits under 4K. 886 has 8K.
-
Re: SSD1306 INCLUDE for PBP3
I have not found FSR1L register on 886 chip...
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
OK, will try with 18F2550 later and write back.
-
Re: SSD1306 INCLUDE for PBP3
Had no chance to test it yet on PBP, connected to Arduino uno for testing and launched adafruit library demos. Adjusted some speeds and quite impressed. Should I expect same speed on PIC18F2550 or it will be significantly slower?
-
Re: SSD1306 INCLUDE for PBP3
Can these LCD's show custom characters?
I have a request to make a display that will show chess pieces like this ♟️ -> A4.
Unfortunately character LCD do not have enough resolution with 5x7 characters so this 1306 may be a good alternative.
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
Yes any font can be created in fixed or variable width
-
Re: SSD1306 INCLUDE for PBP3
OK, thanks.
Will order then a few to play with.
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
How are fonts or special symbols to be designed for SSD1306?
I could not figure out studying the font7x5 include files.
As I posted above I need to design some chess pieces and 5x7 is not enough space.
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
i use MikroElektronika GLCD Font Creator
here is example pawns as 16x16 font [variable width C code output new type ]
chars A,B,C,D have been mapped to black pawn on black square , black pawn on white square
and white pawn on black square , white pawn on white square
PAWNS.BAS
Code:
;//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0;//MikroElektrnika 2011
;//http://www.mikroe.com
;//GLCD FontName : pawns16x16
;//GLCD FontSize : 16 x 16
;const unsigned short pawns16x16[] = {
goto overpawns
pawns:
@ db 0X00,0
@ db 0X41,0X00
@ db 0X44,0X00
@ db 0X10,0
@ db 0XF,0X18,0X00,0X00
@ db 0XF,0X38,0X00,0X00
@ db 0XF,0X58,0X00,0X00
@ db 0XF,0X78,0X00,0X00
@ db 0XC0,0X01,0X20,0X02,0X10,0X04,0X10,0X04,0X20,0X02,0X40,0X01,0X78,0X0F,0X08,0X08,0X78,0X0F,0X40,0X01,0X20,0X02,0X10,0X04,0X08,0X08,0XFC,0X1F,0X00,0X00,0XFE,0X3F; // Code for char num 65
@ db 0XC0,0X01,0XE0,0X03,0XF0,0X07,0XF0,0X07,0XE0,0X03,0XC0,0X01,0XF8,0X0F,0XF8,0X0F,0XF8,0X0F,0XC0,0X01,0XE0,0X03,0XF0,0X07,0XF8,0X0F,0XFC,0X1F,0X00,0X00,0XFE,0X3F; // Code for char num 66
@ db 0X3F,0XFE,0X1F,0XFC,0X0F,0XF8,0X0F,0XF8,0X1F,0XFC,0X3F,0XFE,0X07,0XF0,0X07,0XF0,0X07,0XF0,0X3F,0XFE,0X1F,0XFC,0X0F,0XF8,0X07,0XF0,0X03,0XE0,0XFF,0XFF,0X01,0XC0; // Code for char num 67
@ db 0X3F,0XFE,0XDF,0XFD,0XEF,0XFB,0XEF,0XFB,0XDF,0XFD,0XBF,0XFE,0X87,0XF0,0XF7,0XF7,0X87,0XF0,0XBF,0XFE,0XDF,0XFD,0XEF,0XFB,0XF7,0XF7,0X03,0XE0,0XFF,0XFF,0X01,0XC0; // Code for char num 68
; };
overpawns:
-
Re: SSD1306 INCLUDE for PBP3
http://www.picbasic.co.uk/forum/show...363#post147363
use ssd1306 code from here , it can use variable width fonts that do not have to be hand coded
makes life easy
i have a ver that can do bmp like images too if interested
-
Re: SSD1306 INCLUDE for PBP3
Thank you very much. Your support and help is beyond words.
The selection of pixel columns and lines is really slow process. Seems you cannot numerically define lines and columns. Just adding one at a time waiting to complete.
Then, what are your settings for export?
Be blessed,
Ioannis
-
4 Attachment(s)
Re: SSD1306 INCLUDE for PBP3
step 1 create a font
Attachment 9121
step 2 edit it to taste
Attachment 9122
step 3 create blank include file
and export
Attachment 9123
step 4 paste export in suitable format into include
Attachment 9124
do some editing to get it to pbp format
remembering never allow a odd number of bytes on a line
never change order or number of data bytes to encode
-
Re: SSD1306 INCLUDE for PBP3
-
Re: SSD1306 INCLUDE for PBP3
BEFORE AFTER EXAMPLE
Code:
'//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
'//MikroElektrnika 2011
'//http://www.mikroe.com
'//GLCD FontName : pawns16x12
'//GLCD FontSize : 16 x 12
'const unsigned short pawns16x12[] = {
' 0x00,
' 0x00,
' 0x41,0x00,
' 0x44,0x00,
' 0x0C,
' 0x00,
' 0x10,0x18,0x00,0x00,
' 0x0D,0x30,0x00,0x00,
' 0x0D,0x48,0x00,0x00,
' 0x0D,0x60,0x00,0x00,
' 0x00,0x00,0x80,0x03,0x80,0x0F,0xC0,0x1F,0xC0,0x1F,0xE0,0x07,0x30,0x04,0x1C,0x0C,0x04,0x18,0x04,0x30,0x02,0x60,0x03,0xC0, // Code for char num 65
' 0xF0,0x00,0x10,0x03,0x10,0x0D,0x10,0x19,0x10,0x11,0x30,0x17,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // Code for char num 66
' 0x00,0x00,0x00,0x00,0xC0,0x0F,0x60,0x18,0x60,0x10,0xD0,0x1F,0x10,0x00,0x70,0x02,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, // Code for char num 67
' 0x00,0x00,0x80,0x01,0x80,0x00,0x80,0x1C,0x00,0x15,0x00,0x1F,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 // Code for char num 68
' };
'//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
'//MikroElektrnika 2011
'//http://www.mikroe.com
'//GLCD FontName : pawns16x12
'//GLCD FontSize : 16 x 12
'const unsigned short pawns16x12[] = {
goto overpawns
pawns:
@ DB 0x00,0x00
@ DB 0X41,0x00
@ DB 0X44,0x00
@ DB 0X0C,0x00
@ DB 0X10,0x18,0x00,0x00
@ DB 0X0D,0x30,0x00,0x00
@ DB 0X0D,0x48,0x00,0x00
@ DB 0X0D,0x60,0x00,0x00
@ DB 0X00,0x00,0x80,0x03,0x80,0x0F,0xC0,0x1F,0xC0,0x1F,0xE0,0x07,0x30,0x04,0x1C,0x0C,0x04,0x18,0x04,0x30,0x02,0x60,0x03,0xC0' // Code for char num 65
@ DB 0XF0,0x00,0x10,0x03,0x10,0x0D,0x10,0x19,0x10,0x11,0x30,0x17,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00' // Code for char num 66
@ DB 0X00,0x00,0x00,0x00,0xC0,0x0F,0x60,0x18,0x60,0x10,0xD0,0x1F,0x10,0x00,0x70,0x02,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00' // Code for char num 67
@ DB 0X00,0x00,0x80,0x01,0x80,0x00,0x80,0x1C,0x00,0x15,0x00,0x1F,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00' // Code for char num 68
overpawns:
ps , for a chess board all chrs need to be same size , the font creator will optimize the shit out of your creations it hates blank columns on either edge
its a battle of wits .
this ver may make fonts easier to but up to each other
Code:
'*******************************************************************
'* Name : grx.pbpmod *
'* Author : richard *
'* Notice : Copyright (c) 2021 *
'* : *
'* Date : 21/11/2021 *
'* Version : 1.0B ;BMP ADDED *
'* Notes : generic graphics suite for pic18 *
'* : 1 bit /pixel/colour *
'* : uses variable width fonts up to 23 bits wide *
'* : Generated by MikroElektronika GLCD Font Creator *
'* : *
'* : *
'*******************************************************************
; TO MAKE AUTO FLIP OF DISP USE
' #DEFINE DISPFLIP 1
' #DEFINE colours 3 ;1 mono 2 rg or 3 rgb
' width con 64
' height con 16
;buffers
fbr var byte[width/8 * height] ;frame buffer r 4x8x16 pixels row 0 to 31 col 0 to 15
black con 0
red con 1
#if colours = 3
;buffers
fbb var byte[width/8 * height] ;frame buffer b 4x8x16 pixels row 0 to 31 col 0 to 15
fbg var byte[width/8 * height] ;frame buffer g 4x8x16 pixels row 0 to 31 col 0 to 15
ccc con 3
green con 2
yellow con 3
blue con 4
purple con 5
aqua con 6
white con 7
#endif
#if colours = 2
;buffers
fbg var byte[width/8 * height] ;frame buffer g 4x8x16 pixels row 0 to 31 col 0 to 15
ccc con 2
green con 2
yellow con 3
#endif
#if colours = 1
ccc con 1
#endif
dmd_bigaddress var byte[3] BANK0 ;ALLOWS 128K SAFE CONST STRS
fbsb var byte[width/8 * height * ccc ] ;output buffer in scan order
fpx var byte ;work regs
tmp var word ;work regs
' ----------- General use variables used -------------------
gl_x var byte
gl_y var byte
gl_i var word ' General loop counter
gl_l var word ' used in Line subroutine
gl_m var word ' used in Line subroutine
gl_byte var BYTE ' Graphic byte
gl_char var BYTE ' Text byte
g_char var BYTE
' ----- Circle constants and variables
gl_pi con 2
glc_x var word ' Calculation var
glc_y var word ' Calculation var
glc_s var WORD ' Slope
glc_cx var word ' Center x
glc_cy var word ' Center y
glc_r var word ' Radius
g_num var WORD
' ----- Line variables
gl_x1 var BYTE
gl_x2 var BYTE
gl_y1 var BYTE
gl_y2 var BYTE
gl_inc1 var WORD
gl_inc2 var WORD
' ----- Chart Variables
s_xstart var BYTE
s_xend var BYTE
s_ystart var BYTE
s_yend var BYTE
' s_tick var BYTE
;cga stuff
fontaddr var WORD ;work regs
foffset var WORD ;work regs
f_start var WORD ;work regs
f_end var WORD ;work regs
f_height var WORD ;work regs
fw VAR BYTE ;work regs width of last chr
fchb var byte[4] ;work regs
fchd var byte[4] ;work regs
fbp VAR BYTE ;work regs
fbo var WORD ;work regs
fbc VAR BYTE ;work regs
hght VAR BYTE ;work regs
fbrow VAR BYTE ;work regs
fbrc var byte ;work regs
fbfp VAR BYTE ;work regs
fbbpr VAR BYTE ;work regs
fbscn VAR word ;work regs
fbinx VAR BYTE ;work regs
fbpx VAR word ;work regs
dssh VAR BYTE ;work regs
x0 var BYTE ;work regs
x1 var BYTE ;work regs
y0 var BYTE ;work regs
y1 var BYTE ;work regs
BMPLABEL VAR word EXT
;user
fx VAR BYTE
fy VAR BYTE
fch VAR BYTE
colour VAR BYTE ;0-7
bgcolour VAR BYTE ;0-7
@BMPLABEL= _dmd_bigaddress
goto Jumpover_grx_Lib
USERCOMMAND "SETFONT" ;font must be located in first 64k block
USERCOMMAND "FILLRECT" ;X,Y,W,H
USERCOMMAND "DRAWRECT" ;X,Y,W,H
USERCOMMAND "DMDSTR" ;{X,Y},{buffer|const str}, {colour} is 128k safe
USERCOMMAND "DRAWLINE" ;X1,Y1,X2,Y2 , {colour}
USERCOMMAND "DRAWCIRCLE" ;X,Y,R
USERCOMMAND "DMDBMP" ;X,Y,LABEL
sfnt:
readcode fontaddr + 2,f_start
readcode fontaddr + 4,f_end
readcode fontaddr + 6,f_height
return
flip:
fbpx = width/8 * height - 1
while fbpx >width/8 * height/2-1
#if colours = 2
fbscn = fbg[fbpx] rev 8
#endif
fbrc = fbr[fbpx] rev 8
#if colours = 3
fbrow = fbb[fbpx] rev 8
#endif
#if colours = 2
fbg[fbpx] = fbg[width/8 * height - 1 - fbpx] rev 8
#endif
fbr[fbpx] = fbr[width/8 * height - 1 - fbpx] rev 8
#if colours = 3
fbb[fbpx] = fbb[width/8 * height - 1 - fbpx] rev 8
#endif
#if colours = 2
fbg[width/8 * height - 1 - fbpx] = fbscn
#endif
fbr[width/8 * height - 1 - fbpx] = fbrc
#if colours = 3
fbb[width/8 * height - 1 - fbpx] = fbrow
#endif
fbpx = fbpx - 1
wend
return
drawch: ;set fw to -1 if chr out of range or width of chr if successful
; needs h/w check
fw=-1
if ((fch<f_start)||(fch>f_end)) then return
readcode fontaddr + (Fch - f_start)*4 + 8 ,fw
readcode fontaddr + (Fch - f_start)*4 + 9 ,foffset
if (fx+fw) > width then
fw=-1
return
endif
for dssh = 0 to 3 ;fchb = ~0
fchb[dssh] = 255
next
fbp = fx//8
fbo = fy*width/8 + fx/8
for dssh = 1 to (31 - fw) ; fchb = fchb>>(32 - fw)
asm
bcf STATUS,0
banksel _fchb
rrcf _fchb +3
rrcf _fchb +2
rrcf _fchb +1
rrcf _fchb
banksel 0
endasm
next
for dssh = 1 to fbp ;fchb = fchb<<fbp;
asm
bcf STATUS,0
banksel _fchb
rlcf _fchb
rlcf _fchb +1
rlcf _fchb +2
rlcf _fchb +3
banksel 0
endasm
next
for dssh = 0 to 3 ; fchb = ~fchb
fchb[dssh] = ~fchb[dssh]
next
foffset = foffset
for fbc = 1 to f_height
for dssh = 0 to 3
fchd[dssh] = 0
next
for dssh=0 to fw/8
readcode fontaddr + foffset,fchd[dssh]
foffset = foffset + 1
next
for dssh = 1 to fbp ;fchd = fchd << fbp;
asm
bcf STATUS,0
banksel _fchd
rlcf _fchd
rlcf _fchd +1
rlcf _fchd +2
rlcf _fchd +3
banksel 0
endasm
next
fbr[fbo] = fbr[fbo]&fchb[0]
fbr[fbo+1] = fbr[fbo+1]&fchb[1]
fbr[fbo+2] = fbr[fbo+2]&fchb[2]
fbr[fbo+3] = fbr[fbo+3]&fchb[3]
#if colours <> 1
fbg[fbo] = fbg[fbo]&fchb[0]
fbg[fbo+1] = fbg[fbo+1]&fchb[1]
fbg[fbo+2] = fbg[fbo+2]&fchb[2]
fbg[fbo+3] = fbg[fbo+3]&fchb[3]
#endif
#if colours = 3
fbb[fbo] = fbb[fbo]&fchb[0]
fbb[fbo+1] = fbb[fbo+1]&fchb[1]
fbb[fbo+2] = fbb[fbo+2]&fchb[2]
fbb[fbo+3] = fbb[fbo+3]&fchb[3]
#endif
#if colours <> 1
if (bgcolour & 1) then
fbr[fbo] = fbr[fbo]|~fchb[0]
fbr[fbo+1] = fbr[fbo+1]|~fchb[1]
fbr[fbo+2] = fbr[fbo+2]|~fchb[2]
fbr[fbo+3] = fbr[fbo+3]|~fchb[3]
endif
if (bgcolour & 2) then
fbg[fbo] = fbg[fbo]|~fchb[0]
fbg[fbo+1] = fbg[fbo+1]|~fchb[1]
fbg[fbo+2] = fbg[fbo+2]|~fchb[2]
fbg[fbo+3] = fbg[fbo+3]|~fchb[3]
endif
#endif
#if colours = 3
if (bgcolour & 4) then
fbb[fbo] = fbb[fbo]|~fchb[0]
fbb[fbo+1] = fbb[fbo+1]|~fchb[1]
fbb[fbo+2] = fbb[fbo+2]|~fchb[2]
fbb[fbo+3] = fbb[fbo+3]|~fchb[3]
endif
#endif
if (colour &1)then
fbr[fbo] = fbr[fbo] | fchd[0]
fbr[fbo + 1] = fbr[fbo + 1]| fchd[1]
fbr[fbo + 2] = fbr[fbo + 2]| fchd[2]
fbr[fbo + 3] = fbr[fbo + 3]| fchd[3]
else
fbr[fbo] = fbr[fbo] & ~fchd[0]
fbr[fbo + 1] = fbr[fbo + 1]& ~fchd[1]
fbr[fbo + 2] = fbr[fbo + 2]& ~fchd[2]
fbr[fbo + 3] = fbr[fbo + 3]& ~fchd[3]
endif
#if colours <> 1
if (colour&2) then
fbg[fbo] = fbg[fbo] | fchd[0]
fbg[fbo + 1] = fbg[fbo + 1]| fchd[1]
fbg[fbo + 2] = fbg[fbo + 2]| fchd[2]
fbg[fbo + 3] = fbg[fbo + 3]| fchd[3]
else
fbg[fbo] = fbg[fbo] & ~fchd[0]
fbg[fbo + 1] = fbg[fbo + 1]& ~fchd[1]
fbg[fbo + 2] = fbg[fbo + 2]& ~fchd[2]
fbg[fbo + 3] = fbg[fbo + 3]& ~fchd[3]
endif
#endif
#if colours = 3
if (colour&4) then
fbb[fbo] = fbb[fbo] | fchd[0]
fbb[fbo + 1] = fbb[fbo + 1]| fchd[1]
fbb[fbo + 2] = fbb[fbo + 2]| fchd[2]
fbb[fbo + 3] = fbb[fbo + 3]| fchd[3]
else
fbb[fbo] = fbb[fbo] & ~fchd[0]
fbb[fbo + 1] = fbb[fbo + 1]& ~fchd[1]
fbb[fbo + 2] = fbb[fbo + 2]& ~fchd[2]
fbb[fbo + 3] = fbb[fbo + 3]& ~fchd[3]
endif
#endif
fbo = fbo + (width)/8
next
return
sbmp:
readcode BMPLABEL, fw ;width
readcode BMPLABEL+1 ,f_height ;height
DEBUG 13,10, HEX4 BMPLABEL ,9,#fw ,9,#f_height
foffset=2
f_height=f_height+Y0
' fw=(fw/16)-1
fw=(fw/8)-1
DEBUG 13,10
WHILE y0 < f_height
fbo = y0*width/8 + x0
DEBUG #Y0,9
for dssh = 0 to fw ;width
readcode BMPLABEL+foffset ,FBC'gl_inc1
DEBUG HEX2 FBC,9
fbr[fbo] = FBC REV 8
fbo=fbo+1
foffset=foffset+1
' fbr[fbo+1] =(gl_inc1>>8) REV 8
' fbr[fbo] = gl_inc1 REV 8
' fbo=fbo+2
' foffset=foffset+2
next
DEBUG 13,10
Y0=Y0+1
WEND
return
' void lcdBitmap(char x, char y, char w, char h, const char *bd) {
' char tm, bm, lastrow, row, col, db, rb, i = 0, pos;
' char *Findex;
' const char *Dindex;
' lastrow = ((y + h) / 8) - y / 8;
' for (row = 0; row <= lastrow; row++) {
' Findex = gFrame + (y / 8 + row)*84 + x;
' if (row == lastrow) {
' Dindex = bd + (row - 1) * w;
' pos = w;
' while (pos--) {
' db = *Dindex++;
' if (gMODE == 255)db = ~db;
' rb = *Findex;
' db = mask_b(rb, db, y + h);
' *Findex++ = db;
' }
' } else if (row == 0) {
' Dindex = bd;
' pos = w;
' while (pos--) {
' db = *Dindex++;
' if (gMODE == 255)db = ~db;
' rb = *Findex;
' db = mask_t(rb, db, y);
' *Findex++ = db;
' }
' } else {
' Dindex = bd + (row - 1) * w;
' pos = w;
' while (pos--) {
' db = *Dindex++;
' if (gMODE == 255)db = ~db;
' rb = *Findex;
' db = mask_b(rb, db, y);
' *Findex++ = db;
' }
' Findex = gFrame + (y / 8 + row)*84 + x;
' Dindex = bd + row*w;
' pos = w;
' while (pos--) {
' db = *Dindex++;
' if (gMODE == 255)db = ~db;
' rb = *Findex;
' db = mask_t(rb, db, y);
' *Findex++ = db;
' }
' }
' }
'}
gl_setdot: 'Set a pixel to colour given gl_x,gl_y
; clrs pixels colours not selected
fpx = 1<< (gl_x//8)
fbo = gl_y* (width)/8 + gl_x/ 8
if (colour & 1)then
fbr[ fbo ] = fbr[ fbo ]|fpx
else
fbr[ fbo ] = fbr[ fbo ]&~fpx
endif
#IF colours <> 1
if (colour & 2)then
fbg[ fbo ] = fbg[ fbo ]|fpx
else
fbg[ fbo ] = fbg[ fbo ]&~fpx
endif
#endif
#if colours = 3
if (colour & 4)then
fbb[ fbo ] = fbb[ fbo ]|fpx
else
fbb[ fbo ] = fbb[ fbo ]&~fpx
endif
#endif
return
grf_clr:
tmp = width/8 * height
while tmp
tmp = tmp - 1
if bgcolour then
if bgcolour & 1 then fbr[tmp] = 255
#if colours = 2
if bgcolour & 2 then fbg[tmp] = 255
#endif
#if colours = 3
if bgcolour & 4 then fbb[tmp] = 255
#endif
else
fbr[tmp] = 0
#if colours = 2
fbg[tmp] = 0
#endif
#if colours = 3
fbb[tmp] = 0
#endif
endif
wend
return
set8: ;seems ok
gl_x = glc_x+glc_cx : gl_y=glc_y+glc_cy '1
gosub gl_setdot
gl_x = glc_cx-glc_x : gl_y=glc_y+glc_cy '2
gosub gl_setdot
gl_x = glc_cx+glc_x : gl_y=glc_cy-glc_y '3
gosub gl_setdot
gl_x = glc_cx-glc_x : gl_y=glc_cy-glc_y '4
gosub gl_setdot
gl_x = glc_y+glc_cx : gl_y=glc_x+glc_cy '5
gosub gl_setdot
gl_x = glc_cx-glc_y : gl_y=glc_cy+glc_x '6
gosub gl_setdot
gl_x = glc_cx+glc_y : gl_y=glc_cy-glc_x '7
gosub gl_setdot
gl_x = glc_cx-glc_y : gl_y=glc_cy-glc_x '8
gosub gl_setdot
return
'------------ gl_circle d = diameter r = radius x,y are point locations ----------
'***** Given Center = glc_cx,glc_cy and Radius = glc_r ***
d_circ: ;seems ok
glc_x = 0
glc_y = glc_r
glc_s = gl_pi-2*glc_r
while (glc_x <= glc_y)
gosub set8
if (glc_s.15 =1) then
glc_s = glc_s + (4*glc_x + 6)
else
glc_s = glc_s + (4*(glc_x-glc_y) + 10)
glc_y = glc_y - 1
endif
glc_x = glc_x + 1
wend
return
'----------------- 4 sided Star ---------------------
'***** Given Center = gl_cx,gl_cy and Radius = gl_r **********
d_star4: ;sus r must be ? 3 and multiple of 3
glc_x = 0
glc_y = glc_r
glc_s = gl_pi-2*glc_r
while (glc_x <= glc_y)
gosub set8
glc_s = glc_s + (4*(glc_x-glc_y) + 10)
glc_y = glc_y - 3
glc_x = glc_x + 1
wend
return
drect:
gl_x2 = gl_x1+x1
gl_y2 = gl_y1+y1-1
gl_rect: 'Rectangle subroutine given gl_x1,gl_x2,gl_y1, gl_y2
gosub chk_xy
for gl_i= gl_x1 to gl_x2
gl_x = gl_i
gl_y = gl_y1
gosub gl_setdot
gl_y = gl_y2
gosub gl_setdot
next gl_i
for gl_i= gl_y1 to gl_y2
gl_y = gl_i
gl_x = gl_x1
gosub gl_setdot
gl_x = gl_x2
gosub gl_setdot
next gl_i
return
'*** gl_gl_square45 turned 45 degrees ***
'***** Given Center = gl_cx,gl_cy and Radius = gl_r *
d_square45: ;seems ok
glc_x = 0
glc_y = glc_r
glc_s = gl_pi-2*glc_r
while (glc_x <= glc_y)
gosub set8
glc_s = glc_s + (4*(glc_x-glc_y) + 10)
glc_y = glc_y - 1
glc_x = glc_x + 1
wend
return
chk_xy: ;seems ok
if gl_x1 > gl_x2 then
swap gl_x1,gl_x2
endif
if gl_y1 > gl_y2 then
swap gl_y1,gl_y2
endif
return
dline:
gl_inc1 = 0
if abs(s_yend - s_ystart) > abs(s_xend - s_xstart) then
swap s_xstart , s_ystart
swap s_xend , s_yend
gl_inc1 = 1
endif
if s_xstart > s_xend then
swap s_xstart , s_xend
swap s_ystart , s_yend
endif
gl_inc2 = s_xend - s_xstart
gl_l = abs(s_yend - s_ystart )
glc_s = gl_inc2.15
gl_m = abs(gl_inc2)/2
if glc_s then gl_m = -gl_m
if s_ystart < s_yend then
glc_s = 1
else
glc_s = -1
endif
while s_xstart <= s_xend
if gl_inc1>0 then
gl_x = s_ystart
gl_y = s_xstart
gosub gl_setdot
else
gl_x = s_xstart
gl_y = s_ystart
gosub gl_setdot
endif
gl_m = gl_m - gl_l
if gl_m.15 = 1 then
s_ystart = s_ystart + glc_s
gl_m = gl_m + gl_inc2
endif
s_xstart = s_xstart + 1
wenD
return
'dline:
' gl_inc1=0
' if abs(s_yend - s_ystart) > abs(s_xend - s_xstart) then
' gl_m = s_xstart;
' s_xstart = s_ystart;
' s_ystart = gl_m;
' gl_m = s_xend;
' s_xend = gl_y2;
' s_yend= gl_m;
' gl_inc1 = 1;
' endif
' if s_xstart > s_xend then
' gl_m = s_xstart;
' s_xstart = s_xend;
' s_xend = gl_m;
' gl_m = s_ystart;
' s_ystart = gl_y2;
' s_yend= gl_m;
' endif
' gl_inc2 = s_xend - s_xstart;
' gl_l = abs(s_yend- s_ystart);
' glc_s = gl_inc2.15
' gl_m = abs(gl_inc2) / 2;
' if glc_s then gl_m = ~gl_m;
' if s_ystart < s_yend then
' glc_s = 1;
' else
' glc_s = -1;
' endif
' while s_xstart <= s_xend
' if gl_inc1 > 0 then
' gl_x = s_ystart : gl_y= s_xstart
' else
' gl_x = s_xstart : gl_y= s_ystart
' endif
' gosub gl_setdot
' gl_m = gl_m - gl_l;
' if gl_m.15 then
' s_ystart = s_ystart+glc_s;
' gl_m = gl_m+gl_inc2;
' endif
' s_xstart = s_xstart +1;
' wend
'return
frect:
s_ystart=y0
s_yend=y0
while y1
s_xstart=x0
s_xend=x0+s_xend-1
gosub dLine
s_ystart=s_ystart+1
s_yend=s_ystart
y1=y1-1
wend
return
ASM
dmd_pmstr_out
tblrd *+
movf TABLAT,w
bz dmd_exit_pmstrout ; EXIT ON Null char
banksel _fch
MOVWF _fch
banksel 0
movff TBLPTRU,_dmd_bigaddress
movff TBLPTRH,_dmd_bigaddress+1
movff TBLPTRL,_dmd_bigaddress+2
L?CALL _drawch
banksel _fw
movf _fw, W
bn dmd_exit_pmstrout
banksel _fx
addwf _fx,f
incf _fx,f
banksel 0
movff _dmd_bigaddress ,TBLPTRU
movff _dmd_bigaddress+1 ,TBLPTRH
movff _dmd_bigaddress+2 ,TBLPTRL
bra dmd_pmstr_out
dmd_exit_pmstrout
RST?RP
return
dmd_str_out
movf POSTINC1, W ; Get a character
bz dmd_exit_strout ; EXIT ON Null char
banksel _fch
MOVWF _fch
banksel 0
L?CALL _drawch
banksel _fw
movf _fw, W
bn dmd_exit_strout
banksel _fx
addwf _fx,f
incf _fx,f
bra dmd_str_out
dmd_exit_strout
banksel 0
return
DMDBMP?CCL macro X0in ,Y0in,Lin
;MOVE?CW Lin , _dmd_bigaddress
MOVE?CB X0in ,_x0
MOVE?CB Y0in ,_y0
BANKSEL _dmd_bigaddress
movlw UPPER Lin
movwf _dmd_bigaddress+2
movlw HIGH Lin
movwf _dmd_bigaddress+1
movlw LOW Lin
movwf _dmd_bigaddress
BANKSEL 0
L?CALL _sbmp
endm
SETFONT?L macro Lin
MOVE?CW Lin , _fontaddr
L?CALL _sfnt
endm
FILLRECT?WWWW macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_x0
MOVE?WB X1in ,_x1
MOVE?WB Y0in ,_y0
MOVE?WB Y1in ,_y1
L?CALL _frect
endm
FILLRECT?WWBW macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_x0
MOVE?BB X1in ,_x1
MOVE?WB Y0in ,_y0
MOVE?WB Y1in ,_y1
L?CALL _frect
endm
FILLRECT?WWBB macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_x0
MOVE?BB X1in ,_x1
MOVE?WB Y0in ,_y0
MOVE?BB Y1in ,_y1
L?CALL _frect
endm
FILLRECT?WWCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_x0
MOVE?CB X1in ,_x1
MOVE?WB Y0in ,_y0
MOVE?CB Y1in ,_y1
L?CALL _frect
endm
FILLRECT?WWWB macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_x0
MOVE?WB X1in ,_x1
MOVE?WB Y0in ,_y0
MOVE?BB Y1in ,_y1
L?CALL _frect
endm
FILLRECT?BBBB macro X0in ,Y0in ,X1in ,Y1in
MOVE?BB X0in ,_x0
MOVE?BB X1in ,_x1
MOVE?BB Y0in ,_y0
MOVE?BB Y1in ,_y1
L?CALL _frect
endm
FILLRECT?CCCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?CB X0in , _x0
MOVE?CB X1in , _x1
MOVE?CB Y0in, _y0
MOVE?CB Y1in, _y1
L?CALL _frect
endm
FILLRECT?BBCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?BB X0in , _x0
MOVE?CB X1in , _x1
MOVE?BB Y0in , _y0
MOVE?CB Y1in, _y1
L?CALL _frect
endm
;dr
DRAWRECT?WWWW macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_gl_x1
MOVE?WB X1in ,_x1
MOVE?WB Y0in ,_gl_y1
MOVE?WB Y1in ,_y1
L?CALL _drect
endm
DRAWRECT?WWBW macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_gl_x1
MOVE?BB X1in ,_x1
MOVE?WB Y0in ,_gl_y1
MOVE?WB Y1in ,_y1
L?CALL _drect
endm
DRAWRECT?WWBB macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_gl_x1
MOVE?BB X1in ,_x1
MOVE?WB Y0in ,_gl_y1
MOVE?BB Y1in ,_y1
L?CALL _drect
endm
DRAWRECT?WWCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_gl_x1
MOVE?CB X1in ,_x1
MOVE?WB Y0in ,_gl_y1
MOVE?CB Y1in ,_y1
L?CALL _drect
endm
DRAWRECT?WWWB macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_gl_x1
MOVE?WB X1in ,_x1
MOVE?WB Y0in ,_gl_y1
MOVE?BB Y1in ,_y1
L?CALL _drect
endm
DRAWRECT?BBBB macro X0in ,Y0in ,X1in ,Y1in
MOVE?BB X0in ,_gl_x1
MOVE?BB X1in ,_x1
MOVE?BB Y0in ,_gl_y1
MOVE?BB Y1in ,_y1
L?CALL _drect
endm
DRAWRECT?CCCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?CB X0in ,_gl_x1
MOVE?CB X1in ,_x1
MOVE?CB Y0in ,_gl_y1
MOVE?CB Y1in ,_y1
L?CALL _drect
endm
DRAWRECT?BBCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?BB X0in ,_gl_x1
MOVE?CB X1in ,_x1
MOVE?BB Y0in ,_gl_y1
MOVE?CB Y1in ,_y1
L?CALL _drect
endm
;CIRC
DRAWCIRCLE?WWW macro X0in ,Y0in ,Rad
MOVE?WW X0in , _glc_cx
MOVE?WW Rad , _glc_r
MOVE?WW Y0in , _glc_cy
L?CALL _d_circ
endm
DRAWCIRCLE?WWB macro X0in ,Y0in ,Rad
MOVE?WW X0in , _glc_cx
MOVE?BW Rad , _glc_r
MOVE?WW Y0in , _glc_cy
L?CALL _d_circ
endm
DRAWCIRCLE?WWC macro X0in ,Y0in ,Rad
MOVE?WW X0in , _glc_cx1
MOVE?CW Rad , _glc_r
MOVE?WW Y0in , _glc_cy1
L?CALL _d_circ
endm
DRAWCIRCLE?BBB macro X0in ,Y0in ,Rad
MOVE?BW X0in , _glc_cx
MOVE?BW Rad , _glc_r
MOVE?BW Y0in , _glc_cy
L?CALL _d_circ
endm
DRAWCIRCLE?CCC macro X0in ,Y0in ,Rad
MOVE?CW X0in , _glc_cx
MOVE?CW Rad , _glc_r
MOVE?CW Y0in , _glc_cy
L?CALL _d_circ
endm
DRAWCIRCLE?BBC macro X0in ,Y0in ,Rad
MOVE?BW X0in , _glc_cx
MOVE?CW Rad , _glc_r
MOVE?BW Y0in , _glc_cy
L?CALL _d_circ
endm
;LINE
DRAWLINE?WWWW macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_s_xstart
MOVE?WB X1in ,_s_xend
MOVE?WB Y0in ,_s_ystart
MOVE?WB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?WWBW macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_s_xstart
MOVE?BB X1in ,_s_xend
MOVE?WB Y0in ,_s_ystart
MOVE?WB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?WWBB macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_s_xstart
MOVE?BB X1in ,_s_xend
MOVE?WB Y0in ,_s_ystart
MOVE?BB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?WWCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_s_xstart
MOVE?CB X1in ,_s_xend
MOVE?WB Y0in ,_s_ystart
MOVE?CB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?WWWB macro X0in ,Y0in ,X1in ,Y1in
MOVE?WB X0in ,_s_xstart
MOVE?WB X1in ,_s_xend
MOVE?WB Y0in ,_s_ystart
MOVE?BB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?BBBB macro X0in ,Y0in ,X1in ,Y1in
MOVE?BB X0in ,_s_xstart
MOVE?BB X1in ,_s_xend
MOVE?BB Y0in ,_s_ystart
MOVE?BB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?CCCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?CB X0in ,_s_xstart
MOVE?CB X1in ,_s_xend
MOVE?CB Y0in ,_s_ystart
MOVE?CB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?CCCB macro X0in ,Y0in ,X1in ,Y1in
MOVE?CB X0in ,_s_xstart
MOVE?CB X1in ,_s_xend
MOVE?CB Y0in ,_s_ystart
MOVE?BB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?CCCW macro X0in ,Y0in ,X1in ,Y1in
MOVE?CB X0in ,_s_xstart
MOVE?CB X1in ,_s_xend
MOVE?CB Y0in ,_s_ystart
MOVE?WB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?BBCC macro X0in ,Y0in ,X1in ,Y1in
MOVE?BB X0in ,_s_xstart
MOVE?CB X1in ,_s_xend
MOVE?BB Y0in ,_s_ystart
MOVE?CB Y1in ,_s_yend
L?CALL _dline
endm
DRAWLINE?CCCCC macro X0in ,Y0in ,X1in ,Y1in,Col
MOVE?CB Col ,_colour
MOVE?CB X0in ,_s_xstart
MOVE?CB X1in ,_s_xend
MOVE?CB Y0in ,_s_ystart
MOVE?CB Y1in ,_s_yend
L?CALL _dline
endm
;----------------------Strings------------------------------------
DMDSTR?CBB macro Xin ,Yin ,Bin
MOVE?CB Xin ,_fx
MOVE?BB Yin ,_fy
MOVE?CB high Bin, FSR1H ;load highbyte
MOVE?CB low Bin, FSR1L ;load low byte
L?CALL dmd_str_out
endm
DMDSTR?CCB macro Xin ,Yin ,Bin
MOVE?CB Xin ,_fx
MOVE?CB Yin ,_fy
MOVE?CB high Bin, FSR1H ;load highbyte
MOVE?CB low Bin, FSR1L ;load low byte
L?CALL dmd_str_out
endm
DMDSTR?CCBC macro Xin ,Yin ,Bin,Col
MOVE?CB Xin ,_fx
MOVE?CB Yin ,_fy
MOVE?CB Col ,_colour
MOVE?CB high Bin, FSR1H ;load highbyte
MOVE?CB low Bin, FSR1L ;load low byte
L?CALL dmd_str_out
endm
DMDSTR?BBB macro Xin ,Yin ,Bin
MOVE?BB Xin,_fx
MOVE?BB Yin,_fy
MOVE?CB high (Bin), FSR1H ;load highbyte
MOVE?CB low (Bin), FSR1L ;load low byte
L?CALL dmd_str_out
endm
DMDSTR?WBB macro Xin ,Yin ,Bin
MOVE?WB Xin,_fx
MOVE?BB Yin,_fy
MOVE?CB high (Bin), FSR1H ;load highbyte
MOVE?CB low (Bin), FSR1L ;load low byte
L?CALL dmd_str_out
endm
DMDSTR?WWB macro Xin ,Yin ,Bin
MOVE?WB Xin,_fx
MOVE?WB Yin,_fy
MOVE?CB high (Bin), FSR1H ;load highbyte
MOVE?CB low (Bin), FSR1L ;load low byte
L?CALL dmd_str_out
endm
;----[const String]---------------------------------------------------------------
DMDSTR?S macro Cin
local TheString, OverStr
goto OverStr
TheString
data Cin, 0
OverStr
movlw UPPER TheString
movwf TBLPTRU
movlw HIGH TheString
movwf TBLPTRH
movlw LOW TheString
movwf TBLPTRL
L?CALL dmd_pmstr_out
endm
DMDSTR?CCS macro Xin ,Yin, Cin
local TheString, OverStr
goto OverStr
TheString
data Cin, 0
OverStr
MOVE?CB Xin ,_fx
MOVE?CB Yin ,_fy
movlw UPPER TheString
movwf TBLPTRU
movlw HIGH TheString
movwf TBLPTRH
movlw LOW TheString
movwf TBLPTRL
L?CALL dmd_pmstr_out
endm
DMDSTR?CCSC macro Xin ,Yin,Bin,Col
local TheString, OverStr
goto OverStr
TheString
data Bin, 0
OverStr
MOVE?CB Xin ,_fx
MOVE?CB Yin ,_fy
MOVE?CB Col ,_colour
movlw UPPER TheString
movwf TBLPTRU
movlw HIGH TheString
movwf TBLPTRH
movlw LOW TheString
movwf TBLPTRL
L?CALL dmd_pmstr_out
endm
ENDASM
Jumpover_grx_Lib:
-
Re: SSD1306 INCLUDE for PBP3
It seems that ssd1306_i2c.inc file is not compatible with 18F4550 in regard I2C routines. Either hardware I2C because SSPCON3 does not exist or in software IC2 because SSP1STAT, SSP1CON2 do not exist also.
I am very reluctant to touch the include file, so any idea how to handle this please?
I just used software I2C finally and commented out the two lines that had the problem. Then it compiled OK and first time I got the demo text on the tiny LCD! Is it safe what I did?
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
not sure what you are trying to do
but ssd1306_18.inc is needed for pic 18 along with font7x5_18.bas
that system is a "light version" it has a fixed 5x7 width, the only way to change the font size is to alter the include
the other version "grx.pbpmod" is more generic, pic18 only and uses variable width fonts and has drivers for multiple display types
-
Re: SSD1306 INCLUDE for PBP3
Well, lets clear what I 've done so far. Just received my OLED display and started to experiment.
At the start of this thread there were the initial files. Downloaded to a folder.
Post #2 had and update so I replaced the ssd1306_18.inc with the ssd1306_I2C.inc that says on top of this file, it is for PIC16/18. Is this wrong?
Replaced again from post #15
And again with that from post #41 (after Henrik's posts).
So, the final test was done on a 18F4550 chip, with a 64x128 oled LCD, soft I2C and files sd1306_demo.pbp, font7x5_18.bas and latest ssd1306_I2C.inc from post #41.
Nothing else added or changed.
After compilation errors, I selected soft I2C and commented out the lines in the include file that referred to SSP1STAT, SSP1CON2 and got the demo message on screen.
Also as a second step, have not sorted out how, the font file that will be created, is working with the main program. I mean, OK there is a new character. How is this chosen to be displayed?
Ioannis
P.S. By the way, the font include files, what do describe? It seems not fonts anyway.
-
Re: SSD1306 INCLUDE for PBP3
Quote:
So, the final test was done on a 18F4550 chip, with a 64x128 oled LCD, soft I2C and files sd1306_demo.pbp, font7x5_18.bas and latest ssd1306_I2C.inc from post #41.
sorry I'm lost, i need to restore some old backup files to get back to speed with this.
i forgot i did actually make a 16/18 version, i have not used that pbp code for quite sometime and my laptop that
held all that code died bigtime. i only use the grx.pbpmod ver or C ver these days, so i'm a bit rusty on the old pbp stuff.
the old code should work with a 18F4550 and the pic18 font posted with hw or soft i2c, the new font format previously discussed will not work with this code
as it stands. i do have a 18F4550 proto board so i could check it out. post the whole lot, includes too i have lost most of the originals and am not absolutely sure we have the same thing.
i would just the new code.
-
Re: SSD1306 INCLUDE for PBP3
OK. Later I will do that. But all what I described is from this thread starting from post #1 and on.
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
i see the prob
4550 has only 1 mssp try this
Code:
'****************************************************************'* Name : ssd1306_I2C.INC *
'* Author : richard *
'* Notice : *
'* : *
'* Date : 7/5/2018 *
'* Version : 1.1 *
'* Notes : const str added for pic16 *
'* :FOR pic 16/18 SSD1306 *
'****************************************************************
goto overglcd
; adjust to suit and place these in main prg
;use this define for hw i2c
;#define hwi2c 1
;#DEFINE PIC16 1 ;IF PIC 16 USED [USE PIC16 FONT TOO}
' ssdheight con 7 ; 7 = 8 PAGES 64*128 , 3 = 4 pages 32*128
' ssdwidth con 127 ; 128 PIXELS WIDE
' SCL var PortC.3 ' I2C Clock
' SDA var PortC.4 ' I2C Data
' sdd1306_addr con $78
USERCOMMAND "GLCDC" ; X,Y,CHR 0 < X < 127 , 0 < Y < 7 31 < CHR > 127
USERCOMMAND "GLCD_CLR" ;clear area x,y,W,H
USERCOMMAND "GLCDSTR" ;STRING @ X,Y or Constant String
USERCOMMAND "GLCDDHL" ; x,y,L ,bit-patten
USERCOMMAND "GLCDDVL" ; x,y,H
USERCOMMAND "SSDC" ;cmd BYTE TO SSD1306
USERCOMMAND "SSDBM" ;x,y,w,h,label
ASM
;----------------------VERT LINE------------------------------------
GLCDDVL?CCC macro Xin ,Yin , Hin
MOVE?CB Xin ,_gx
MOVE?CB Yin,_gy
MOVE?CB Hin ,_gl
L?CALL _xyy
endm
;----------------------HORIZ LINE------------------------------------
GLCDDHL?CCCC macro Xin ,Yin , Win ,Cin
MOVE?CB Xin ,_gx
MOVE?CB Yin,_gy
MOVE?CB Win ,_gl
MOVE?CB Cin ,_glcdData
L?CALL _xyx
endm
;----[const String]---------------------------------------------------------------
GLCDSTR?CCS macro Xin ,Yin,Cin
IFNDEF TBLPTRL
local TheString, OverStr ; define local labels so you can call macro multiple times
goto OverStr ; goto over string stored in FLASH, so processor can't execute that
TheString ;label to get address of your string
da Cin, 0 ;add string to flash at TheString address and end string with 0
OverStr
MOVE?CW TheString, _glcd_bigaddress
MOVE?CB Xin , _gx
MOVE?CB Yin , _gy
L?GOTO _GlcdUnpackStr
ELSE
local TheString, OverStr ; define local labels so you can call macro multiple times
goto OverStr ; goto over string stored in FLASH, so processor can't execute that
TheString ;label to get address of your string
data Cin, 0 ;add string to flash at TheString address and end string with 0
OverStr
movlw UPPER TheString
movwf TBLPTRU
movlw HIGH TheString
movwf TBLPTRH
movlw LOW TheString
movwf TBLPTRL
MOVE?CB Xin , _gx
MOVE?CB Yin , _gy
L?CALL GLCD_Cstr_out
ENDIF
endm
SSDBM?CCCCL macro Xin ,Yin ,Win,Hin,BMin
IFNDEF TBLPTRL
ERROR BITMAPS ONLY SUPPORTED ON PIC18
ENDIF
MOVE?CB Xin , _gx
MOVE?CB Yin , _gy
MOVE?CB Hin/8-1 , _gy_
MOVE?CB Win+Xin-1 , _gx_
MOVE?CW Win*Hin/8 , _glcd_rad
banksel _glcdbm
movlw low BMin
movwf _glcdbm
movlw high BMin
movwf _glcdbm +1
BANKSEL 0
L?CALL _ssd_bitmap
endm
;----------------------Strings------------------------------------
GLCDSTR?CBB macro Xin ,Yin ,Bin
MOVE?CB Xin , _gx
MOVE?BB Yin , _gy
MOVE?CB high Bin, FSR1H ;load highbyte
MOVE?CB low Bin, FSR1L ;load low byte
L?CALL GLCD_str_out
endm
GLCDSTR?CCB macro Xin ,Yin ,Bin
MOVE?CB Xin , _gx
MOVE?CB Yin ,_gy
MOVE?CB high (Bin), FSR1H ;load highbyte
MOVE?CB low (Bin), FSR1L ;load low byte
L?CALL GLCD_str_out
endm
GLCDSTR?BBB macro Xin ,Yin ,Bin
MOVE?B Xin, _gx
MOVE?B Yin, _gy
MOVE?CB high Bin, FSR1H ;load highbyte
MOVE?CB low Bin, FSR1L ;load low byte
L?CALL GLCD_str_out
endm
GLCDSTR?WBB macro Xin ,Yin ,Bin
MOVE?WB Xin, _gx
MOVE?BB Yin, _gy
MOVE?CB high Bin, FSR1H ;load highbyte
MOVE?CB low Bin, FSR1L ;load low byte
L?CALL GLCD_str_out
endm
GLCDSTR?WWB macro Xin ,Yin ,Bin
MOVE?WB Xin, _gx
MOVE?WB Yin, _gy
MOVE?CB high Bin, FSR1H ;load highbyte
MOVE?CB low Bin, FSR1L ;load low byte
L?CALL GLCD_str_out
endm
SSDC?C macro Cin
MOVE?CB Cin , _glcdData
L?CALL _cmd_byte
endm
SSDC?B macro Cin
MOVE?BB Cin , _glcdData
L?CALL _cmd_byte
endm
GLCD_CLR? macro
MOVE?CB 0, _gx
MOVE?CB 0, _gy
MOVE?CB _ssdwidth, _gx_
MOVE?CB _ssdheight, _gy_
L?CALL _glcd_clrxy
endm
GLCD_CLR?CCCC macro Xin ,Yin,X1in ,Y1in
MOVE?CB Xin, _gx
MOVE?CB Yin, _gy
MOVE?CB X1in, _gx_
MOVE?CB Y1in, _gy_
L?CALL _glcd_clrxy
endm
;----------------------Character @ X,Y ------------------------------------
GLCDC?BBB macro Xin ,Yin , Bin
MOVE?BB Xin, _gx
MOVE?BB Yin, _gy
MOVE?BB Bin, _glcdCh
L?CALL _gcga
endm
GLCDC?WBB macro Xin ,Yin , Bin
MOVE?WB Xin, _gx
MOVE?BB Yin, _gy
MOVE?BB Bin, _glcdCh
L?CALL _gcga
endm
GLCDC?WWB macro Xin ,Yin , Bin
MOVE?WB Xin, _gx
MOVE?WB Yin, _gy
MOVE?BB Bin, _glcdCh
L?CALL _gcga
endm
GLCDC?BBC macro Xin ,Yin , Cin
MOVE?BB Xin, _gx
MOVE?BB Yin, _gy
MOVE?CB Cin ,_glcdCh
L?CALL _gcga
endm
GLCDC?WBC macro Xin ,Yin , Cin
MOVE?WB Xin, _gx
MOVE?BB Yin, _gy
MOVE?CB Cin ,_glcdCh
L?CALL _gcga
endm
GLCDC?CCC macro Xin ,Yin ,Cin
MOVE?CB Xin , _gx
MOVE?CB Yin, _gy
MOVE?CB Cin, _glcdCh
L?CALL _gcga
endm
GLCDC?CCB macro Xin ,Yin ,Bin
MOVE?CB Xin , _gx
MOVE?CB Yin, _gy
MOVE?BB Bin, _glcdCh
L?CALL _gcga
endm
GLetAddress macro Label, Wout
CHK?RP Wout
movlw low Label ; get low byte
movwf Wout
movlw High Label ; get high byte
movwf Wout + 1
BANKSEL 0
endm
IFDEF TBLPTRL
GLCD_Cstr_out
tblrd *+
movf TABLAT,w
bz GLCD_exit_Cstr_out ; EXIT ON Null char
CHK?RP _glcdCh
MOVWF _glcdCh
CHK?RP _glcd_bigaddress
movff TBLPTRU,_glcd_bigaddress
movff TBLPTRH,_glcd_bigaddress+1
movff TBLPTRL,_glcd_bigaddress+2
L?CALL _gcga
CHK?RP _glcd_bigaddress
movff _glcd_bigaddress ,TBLPTRU
movff _glcd_bigaddress+1 ,TBLPTRH
movff _glcd_bigaddress+2 ,TBLPTRL
bra GLCD_Cstr_out
GLCD_exit_Cstr_out
BANKSEL 0
return
GLCD_str_out
movf POSTINC1, W ; Get a character
bz GLCD_exit_strout ; EXIT ON Null char
CHK?RP _glcdCh
MOVWF _glcdCh
BANKSEL 0
L?CALL _gcga
bra GLCD_str_out
GLCD_exit_strout
BANKSEL 0
return
ELSE
GLCD_str_out
IFDEF BSR
MOVIW FSR1++ ; Get a character
BTFSC STATUS,Z
BRA GLCD_exit_strout ; EXIT ON Null char
ELSE
movf INDF, W ; Get a character
BTFSC STATUS,Z
GOTO GLCD_exit_strout ; EXIT ON Null char
INCF FSR,F
ENDIF
CHK?RP _glcdCh
MOVWF _glcdCh
MOVE?BB FSR1L,_glcd_bigaddress
MOVE?BB FSR1H,_glcd_bigaddress+1
BANKSEL 0
L?CALL _gcga
MOVE?BB _glcd_bigaddress,FSR1L
MOVE?BB _glcd_bigaddress+1,FSR1H
GOTO GLCD_str_out
GLCD_exit_strout
BANKSEL 0
return
ENDIF
endasm
glcd_bigaddress VAR BYTE[3]
glcd_buff VAR BYTE[32]
BIG_TEXT var byte
glcd_rad var word
glcdCh var byte 'chr DATA
glcdData VAR byte 'DATA
glcdBC VAR word 'gca var
glcdDC VAR BYTE 'gca var
glcdFont var word 'font address
glcdOffset VAR word 'font offset
glcdbm VAR word 'bitmap offset
gl var byte 'width/height
gy var byte 'gca pg address
gy_ var byte 'gca pg address
gx var byte 'gca row address
gx_ var byte 'gca row address
GRX var byte 'DATA
ctemp var word
ctemp1 var word
ssd_add var byte
glcdStrAddr var word ext
@glcdStrAddr = _glcd_bigaddress
GlcdUnpackStr:
readcode glcdStrAddr,CTEMP
glcd_bigaddress[2] = CTEMP&$7f
ctemp=ctemp<<1
glcdCh = CTEMP.HIGHBYTE
glcdStrAddr=glcdStrAddr+1
if glcdCh then
gosub gcga
glcdCh = glcd_bigaddress[2]
else
return
endif
if glcdCh then
gosub gcga
else
return
endif
goto GlcdUnpackStr:
return
glcd_init:
#ifdef hwi2c
SSPSTAT = 0 'High Speed Filter
SSPADD = $13'400 kHz @32 MHz
SSPCON1 = %00101000 'I2C Master Mode Enable
' SSPCON3 = 0
#endif
@ GLetAddress _font7x5,_glcdFont
ssd_add = sdd1306_addr
SSDc $AE ' Display OFF
SSDc $d5
SSDc $80
SSDc $a8 : SSDc $3f
SSDc $D3 : SSDc $00 ; Set Display Offset Mode Set 0
if ssdheight > 3 then
SSDc $40 ' Set display start line 0
else
SSDc $60 ' Set display start line 4
endif
SSDc $8D : SSDc $14 ' Set Charge Pump Internal
SSDc $20 : SSDc $00 ' Adressing mode Horizontal
SSDc $A1 ' set segment remap column 127 as start
SSDc $C8 ' Com Scan Direction, Flip display vertically
SSDc $DA ' set COM pins
if ssdheight > 3 then
SSDc$12 ' set COM pins = 128x64=$12
else
SSDc$02 ' set COM pins = 128x32=$02
endif
SSDc $81 : SSDc$7F ' Set brightness to $01 to $FF ($7F is default, $01 is faint)
SSDc $DB : SSDc$40 ' Set VCOM Deselect Level
SSDc $B0 ' Set Page Address From $B0 to $B7
SSDc $2e ; scroll off
SSDc $A4 ' display ON continue
SSDc $A6 ' $A6=NORMAL MODE; $A7=INVERSE MODE
SSDc $AF ' Display ON
return
xyx: ;draw HORIZ LINE @X,Y for W len 0<X>127 1<W>127
FOR GRX = 0 TO 31
glcd_buff[GRX] = glcdData ;uses this var to set which bit/s is used to generate line
NEXT
gx = gx&ssdwidth
gx_= gx + gl
gy = gy&ssdheight
gy_= gy
gosub setxy
GRX = gl/32
glcd_rad = 32
WHILE GRX
gosub ssd_data
GRX = GRX-1
WEND
glcd_rad = gl//32
IF glcd_rad THEN
gosub ssd_data
ENDIF
return
xyy: ;draw VERT LINE @X,Y for W len @X 0<X>127 1<W>7
FOR GRX = 0 TO ssdheight
glcd_buff[GRX] = 255
NEXT
gx = gx&ssdwidth
gx_= gx
gy = gy&ssdheight
gy_= gy+GL
gosub setxy
glcd_rad = gl
gosub ssd_data
return
glcd_clrxy: ' clear area x1y1 to x2 y2
FOR GRX = 0 TO 31
glcd_buff[GRX] = 0
NEXT
CTEMP = (1 + GX_ - GX)*(1 + GY_ - GY)
gosub setxy
GRX = CTEMP/32
glcd_rad=32
WHILE GRX
gosub ssd_data
GRX = GRX-1
WEND
glcd_rad = CTEMP//32
IF GRX THEN
gosub ssd_data
ENDIF
return
gcga: ;draw a chr
GY = gy&ssdheight
GY_= gy + BIG_TEXT
gx = gx&ssdwidth
#ifdef PIC16
glcdOffset = (glcdch-32)*3 + glcdFont ; point to cga data
#ELSE
glcdOffset = (glcdch-32)*6 + glcdFont ; point to cga data
#ENDIF
gosub unpack
IF BIG_TEXT THEN
GOSUB SSD_BIG
glcd_rad = 24
gx_= gx + 11
ELSE
glcd_rad = 6
gx_= gx + 5
ENDIF
gosub setxy
gosub ssd_data
gx = gx_+ 1 + BIG_TEXT
IF GX > 121 THEN gx=0 ;wrap
return
ssd_data: ;send data block
#ifdef hwi2c
glcdBC=0
SSPCON2.0 = 1 ; SEN - Start Condition Enable Bit
WHILE SSPCON2.0 = 1 : WEND ; Wait for Start to complete
SSPBUF = ssd_add ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
SSPBUF = $40 ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
while glcdBC < glcd_rad
SSPBUF = glcd_buff[glcdBC] ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
glcdBC=glcdBC+1
wend
SSPCON2.2 = 1 ; PEN - send stop bit
While SSPCON2.2 = 1 : Wend ; Wait for SSP to complete
#else
i2Cwrite SDA,SCL,ssd_add,[$40,str glcd_buff\ glcd_rad]
#endif
return
#ifndef PIC16
ssd_bitmap: ;send graphic block from flash
gosub setxy
glcdBC=0
SSPCON2.0 = 1 ; SEN - Start Condition Enable Bit
WHILE SSPCON2.0 = 1 : WEND ; Wait for Start to complete
SSPBUF = ssd_add ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
SSPBUF = $40 ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
while glcdBC < glcd_rad
readcode glcdbm+glcdBC,CTEMP
SSPBUF = ctemp.LOWBYTE ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
SSPBUF = ctemp.highBYTE ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
glcdBC=glcdBC+2
wend
SSPCON2.2 = 1 ; PEN - send stop bit
While SSPCON2.2 = 1 : Wend ; Wait for SSP to complete
return
#endif
SSD_BIG: ;create a big chr from a small one
for glcddc = 5 to 0 STEP -1
ctemp = 0
ctemp1 = 3
gL = glcd_buff[glcddc]
for glcdBc = 0 to 7
IF GL & 1 THEN ctemp = ctemp|ctemp1
ctemp1 = ctemp1<<2
GL = GL>>1
NEXT
gL = glcddc*2
glcd_buff[GL] =ctemp.LOWBYTE
glcd_buff[GL+1] =ctemp.LOWBYTE
glcd_buff[GL+12]=ctemp.HIGHBYTE
glcd_buff[GL+13]=ctemp.HIGHBYTE
NEXT
RETURN
unpack: ;unpack font from flash
for glcddc = 0 to 2
GL = glcddc<<1
readcode glcdOffset,CTEMP
#ifdef PIC16
glcd_buff[gl] = CTEMP&$7f
ctemp=ctemp<<1
glcd_buff[gl+1]= CTEMP.HIGHBYTE
glcdOffset = glcdOffset + 1
#else
glcd_buff[gl] = CTEMP
glcd_buff[gl+1]= CTEMP.HIGHBYTE
glcdOffset = glcdOffset + 2
#endif
next
return
cmd_byte: 'send command sequence "glcdData "
#ifdef hwi2c
;hw i2c
SSPCON2.0 = 1 ; SEN - Start Condition Enable Bit
WHILE SSPCON2.0 = 1 : WEND ; Wait for Start to complete
SSPBUF = ssd_add ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
SSPBUF = 0 ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
SSPBUF = glcdData ; Move data to SSPBUF
WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress
While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave
SSPCON2.2 = 1 ; PEN - send stop bit
While SSPCON2.2 = 1: Wend ; Wait for SSP to complete
#else
;soft i2c
I2Cwrite SDA,SCL,ssd_add,[0,glcdData]
#ENDIF
return
setxy: ;set PAGE WINDOW
SSDc $22
SSDc gy
SSDc gy_
SSDc $21
SSDc gx
SSDc gx_
return
overglcd :
-
Re: SSD1306 INCLUDE for PBP3
Quote:
Originally Posted by
Ioannis
OK. Later I will do that. But all what I described is from this thread starting from post #1 and on.
Ioannis
i know but some errors crept in and some posted files are not right and i cannot fix them nor remember which ones they are
its best to be dealing from the same deck
-
Re: SSD1306 INCLUDE for PBP3
Yes you are right. Will post that later today.
Ioannis
-
1 Attachment(s)
Re: SSD1306 INCLUDE for PBP3
Merry Xmas to all.
here are the files I used to test the SSD1306 lcd.
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
Just tested the new include you post and works with soft I2C as expected. But not on hardware I2C...
My code with new include:
Code:
#CONFIG
CONFIG PLLDIV = 1 ; Divide by 5 (20 MHz oscillator input)
CONFIG CPUDIV = OSC1_PLL2 ; [Primary Oscillator Src: /1][96 MHz PLL Src: /2]
CONFIG USBDIV = 2 ; USB clock source comes from the 96 MHz PLL divided by 2
CONFIG FOSC = ECPLLIO_EC ; HSPLL_HS ; HS oscillator, PLL enabled (HSPLL)
CONFIG FCMEN = OFF ; Fail-Safe Clock Monitor disabled
CONFIG IESO = OFF ; Oscillator Switchover mode disabled
CONFIG PWRT = OFF ; PWRT disabled
CONFIG BOR = ON ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
CONFIG BORV = 3 ; Minimum setting
CONFIG VREGEN = ON ; USB voltage regulator enabled
CONFIG WDT = ON ; WDT enabled
CONFIG WDTPS = 512 ; 1:512
CONFIG CCP2MX = ON ; CCP2 input/output is multiplexed with RC1
CONFIG PBADEN = OFF ; PORTB<4:0> pins are configured as digital I/O on Reset
CONFIG LPT1OSC = OFF ; Timer1 configured for higher power operation
CONFIG MCLRE = ON ; MCLR pin enabled; RE3 input pin disabled
CONFIG STVREN = ON ; Stack full/underflow will cause Reset
CONFIG LVP = OFF ; Single-Supply ICSP disabled
CONFIG ICPRT = OFF ; ICPORT disabled
CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
CONFIG DEBUG = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
CONFIG CP0 = OFF ; Block 0 (000800-001FFFh) is not code-protected
CONFIG CP1 = OFF ; Block 1 (002000-003FFFh) is not code-protected
CONFIG CP2 = OFF ; Block 2 (004000-005FFFh) is not code-protected
CONFIG CP3 = OFF ; Block 3 (006000-007FFFh) is not code-protected
CONFIG CPB = OFF ; Boot block (000000-0007FFh) is not code-protected
CONFIG CPD = OFF ; Data EEPROM is not code-protected
CONFIG WRT0 = OFF ; Block 0 (000800-001FFFh) is not write-protected
CONFIG WRT1 = OFF ; Block 1 (002000-003FFFh) is not write-protected
CONFIG WRT2 = OFF ; Block 2 (004000-005FFFh) is not write-protected
CONFIG WRT3 = OFF ; Block 3 (006000-007FFFh) is not write-protected
CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) are not write-protected
CONFIG WRTB = OFF ; Boot block (000000-0007FFh) is not write-protected
CONFIG WRTD = OFF ; Data EEPROM is not write-protected
CONFIG EBTR0 = OFF ; Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks
CONFIG EBTR1 = OFF ; Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks
CONFIG EBTR2 = OFF ; Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks
CONFIG EBTR3 = OFF ; Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks
CONFIG EBTRB = OFF ; Boot block (000000-0007FFh) is not protected from table reads executed in other blocks
#ENDCONFIG
DEFINE OSC 48
LATA = %00000000
LATB = %00000000
LATC = %00000000
LATD = %00000000
LATE = %00000000
TRISA = %00100001
TRISB = %00010000
TRISC = %00000000
TRISD = %00000000
TRISE = %00000000
;*********************************************************************
; ADC Settings
;*********************************************************************
ADCON0=%00000001
ADCON1=%00001110
ADCON2=%10100111
cmcon=0
;*********************************************************************
' Set LCD Data port
DEFINE LCD_DREG PORTD
' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_DBIT 4
' Set LCD Register Select port
DEFINE LCD_RSREG PORTD
' Set LCD Register Select bit
DEFINE LCD_RSBIT 0
' Set LCD Enable port
DEFINE LCD_EREG PORTD
' Set LCD Enable bit
DEFINE LCD_EBIT 1
' Set LCD bus size (4 or 8 bits)
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
' Set command delay time in us
'DEFINE LCD_COMMANDUS 1500
' Set data delay time in us
'DEFINE LCD_DATAUS 50
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
DEFINE ADC_CLOCK 3
pause 100
t1con=0
char var byte
x var byte
y var byte
BUFF VAR BYTE[16]
;use this define for hw i2c
#define hwi2c 1
;set and uncomment these to use softi2c
SCL var Portb.1 ' I2C Clock
SDA var Portb.0 ' 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_16_18.INC" ' bring it in
include "font7x5_18.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
ARRAYWRITE BUFF,["JBCDEF",0]
CHAR="!"
GLCDC 100,2,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
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
it works for me with
TRISB = % 00010011
most pic modules that switch pin directions like to control tris themselves, the data sheet for this chip is totally not clear
at all re i2c tris requirements
-
1 Attachment(s)
Re: SSD1306 INCLUDE for PBP3
Yes, you are right. I took it for granted that this was taken care in the include file. Now it works OK with hard I2C also.
Next, how to import the 16x16 characters into the 5x7 library.
Can these co-exist?
I tried to add your pawn example after the 5x7 data but obviously this does not work if one wants to print character 128...
I attach my failed try.
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
Quote:
I took it for granted that this was taken care in the include file
it is to some extent , the correct tris setting for sda and scl is the power on default of input for both hw and software i2c
if the user decides to overwrite those settings its extremely difficult to rectify in an include file since the pins can be virtually
anywhere on any port depending on chip used
Quote:
Next, how to import the 16x16 characters into the 5x7 library.
you cannot , the font is 5x7 hard coded
Quote:
Can these co-exist?
not as a font
Quote:
I tried to add your pawn example after the 5x7 data but obviously this does not work if one wants to print character 128...
i see no impediment to 5x7 chrs being added to the font to a byte sized quantity, the upper font boundary is not enforced
mixed font heights is not implemented
Quote:
I attach my failed try.
if you want 16x16 fonts see here, its a completely different strategy
http://www.picbasic.co.uk/forum/showthread.php?t=24218
if you want to persist with this code, the chess pieces will need to be bitmaps
bitmaps in an array would be fairly straight forward, two for each piece type , one as solid the other an outline, with a blank w and blk too
the board could also be a bit map a piece could then be or-ed or exor-ed into a square depending piece colour and square colour
-
2 Attachment(s)
Re: SSD1306 INCLUDE for PBP3
looks like a 4550 just hasn't the resources for graphics work
here is a look a my 16x16 pawn font on a 26k22
Attachment 9129
its still a bit clunky @ 16x16
bmp 48x51
Attachment 9130
-
Re: SSD1306 INCLUDE for PBP3
The thing is getting more and more complicated...
I am considering to switch over to a 3,5" Nextion display. Much easier, preloaded images. Even a 12F could handle that! Still I have to use the USB port, so 4550 is the least to use.
The last try of 48x51 looks great! I do not care about white or black pieces or even the board. White pieces is just fine. But if the resources needed are too much, I don't know if it is worth to keep on trying...
Thanks a lot for the efforts,
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
Bitmaps take very modest resources, that one just 48 x 8 bytes of flash
-
Re: SSD1306 INCLUDE for PBP3
That is nice! Is there any post on the forum how this can be done?
This needs 2304 bytes for 6 pieces and I think this can be managed.
Ioannis
-
Re: SSD1306 INCLUDE for PBP3
LCDAssistant.exe
GLCDtool.exe
will get you close [keep height to multiple of 8]
-
Re: SSD1306 INCLUDE for PBP3
found this example
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
-
Re: SSD1306 INCLUDE for PBP3
Got some genuine, 128x128 pixels, 16 shades of grey, OLED displays from Futaba. They use SSD1327. Any chances to adapt all above to that controller?
-
Re: SSD1306 INCLUDE for PBP3
no, my tft code would be a closer fit, a full redesign would be needed for the greyscale nibbles. full colour oleds are about the same price so i doubt if i would be interested in grey scale code anyway for such tiny displays.