Test Message - Please disregard
Printable View
Test Message - Please disregard
if you wish to run the display in inverse colour mode at any time :
use one of these "usercommands" that are part of the include
to invert entire display
SSDC $A7
to restore it USE
SSDC $A6
Thanks for information
Richard, I am hoping you can help me with an issue I am having making your SSD1306 driver work. Everything is working well except when I display a bitmap with the y axis not set at 0 it cuts the image in half. I have tried with every version of the ssd1306_I2C.INC found in this thread with the same result. Posted here is the code with a simple 16x16 bitmap icon and an image of it displayed at both y=0 and y=4. Any chance you can help sort what is going on here?
Attachment 9622Code:'****************************************************************
'* Name : ssd1306_DEMO.PBP *
'* Author : richard *
'* Notice : *
'* : *
'* Date : 19/11/2017 *
'* Version : *
'* Notes : *
'* :FOR pic 18F26K22 SSD1306 *
'****************************************************************
#CONFIG
CONFIG FOSC = INTIO67
CONFIG PLLCFG = ON
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
OSCCON = %11110000
char var byte
x var byte
y var byte
BUFF VAR BYTE[16]
ANSELb = 0
ANSELA = 0
ANSELC = 0
;use this define for hw i2c
#define hwi2c 1 'SCL=C.3 & SDA=C.4
;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"
'========================== MAIN Routine ==============================
pause 100
gosub glcd_init
GLCD_CLR
BIG_TEXT = 0
main:
SSDBM 112,0,16,16 ,StallIcon ;x,y,w,h,label Y=0 (DISPLAYS OK)
' pause 100
' SSDBM 112,0,16,16 ,BlankIcon ;x,y,w,h,label
' SSDBM 112,2,16,16 ,StallIcon ;x,y,w,h,label Y>0 (DISPLAYS HALF OF IMAGE)
' pause 100
' SSDBM 112,2,16,16 ,BlankIcon ;x,y,w,h,label
SSDBM 112,4,16,16 ,StallIcon ;x,y,w,h,label Y>0 (DISPLAYS HALF OF IMAGE)
pause 1000
' SSDBM 112,4,16,16 ,BlankIcon ;x,y,w,h,label
' SSDBM 112,6,16,16 ,StallIcon ;x,y,w,h,label Y>0 (DISPLAYS HALF OF IMAGE)
' pause 100
' SSDBM 112,6,16,16 ,BlankIcon ;x,y,w,h,label
goto main
end
StallIcon: '16x16 BMP image
@ db 248, 4, 226, 241, 57, 25, 25, 193, 241, 121, 25, 25, 241, 226, 4, 248
@ db 15, 16, 35, 71, 78, 76, 78, 71, 67, 64, 76, 78, 71, 35, 16, 15
BlankIcon: '16x16 BMP image
@ 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
yep, i never did test with other than 64x64 bmps, that masked the faultQuote:
Any chance you can help sort what is going on here?
now we know it works with 64x64 and 16x16 bmps at least
there is a defect in the include file, the bmp usercommand macro is not quite right
in the include file the bit in red needs to be added in
Code: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+Yin-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
latest version
Thank you, Richard! That works perfectly! You have no idea how much time I spent attempting to fix that.
One other request. I am struggling to understand the macros but would like one that can do a point to point line. Something that would do x1,y1 to x2,y2. Can you assist with adding a macro to accomplish this?
not possible with this small footprint method , horizontal and vertical lines is the best it can doQuote:
One other request. I am struggling to understand the macros but would like one that can do a point to point line.
if you want full graphics use this
https://www.picbasic.co.uk/forum/sho...741#post146741
I was afraid that would be the case. I have spent time playing with that version and can't figure out how to display a bitmap image, which is a requirement for this project. That's using DMDBMP command.
If I copy in the macro from this version and add the SSDBM command, I can display an image, but not correctly. Likely due to the difference in how the height differs from both drivers.
post what you have tried and i will have a look
When I use SSDBM it shows the top half of the image twice, and seems to lock the display as I can't clear or alter what is displayed afterwards.
Using the DMDBMP format, it displays a black screen, but if I attempt to display something afterwards it goes nuts. I assume I'm not addressing the BMP data location correctly, but don't see an example or instructions on using a bitmap.
Here is the code I am running right now with the bmp. Doing it this way seems to get stuck right after the image is displayed, and it looks like the picture below.Code:DMDBMP 0,0,logo64 'X,Y,LABEL (HOW DO I SPECIFY SIZE???)
gosub show
Attachment 9624Code:#CONFIG
CONFIG FOSC = INTIO67
CONFIG PLLCFG = ON
CONFIG PRICLKEN = ON
CONFIG FCMEN = OFF
CONFIG IESO = OFF
CONFIG PWRTEN = ON
CONFIG BOREN = SBORDIS
CONFIG BORV = 190
CONFIG WDTEN = ON
CONFIG WDTPS = 32768
CONFIG CCP2MX = PORTC1
CONFIG PBADEN = OFF
CONFIG CCP3MX = PORTB5
CONFIG T3CMX = PORTC0
CONFIG HFOFST = ON
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
OSCCON=%01110000 ' SET TO 16 MHZ internal oscillator
OSCTUNE.6=1 ' 4xPLL
DEFINE OSC 64
;set these to match display
ssd1306_addr con $78
#DEFINE colours 1 ;1 mono 2 rg or 3 rgb
width con 128
height con 64
h_offset con 0 ;28 for 40x72
include "grx.pbpMOD"
include "SSD1306.pbpMOD"
include "font.bas"
include "bignum.bas"
include "bigchr.bas"
BUFF VAR BYTE[10]
J VAR BYTE
BGCOLOUR=0
ANSELB=0
ANSELC=0
ANSELA=0
OSCCON=$70
gosub glcd_init
gosub grf_clr
gosub show
SETFONT FONT5x7
main:
'DMDBMP 128,64,logo64 'X,Y,LABEL (HOW DO I SPECIFY SIZE???)
'gosub show
'pause 5000
'gosub grf_clr
'gosub show
ARRAYWRITE BUFF,["STRING OF TEXT",0]
DMDSTR 10,5,buff,1
gosub show
pause 5000
gosub grf_clr
gosub show
SSDBM 31,0,64,64 ,logo64 'This displays the top half of the image ok, and repeats the top half on lower half of screen
'Using this MACRO inside of grx.pbpmod
'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+Yin-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
pause 1000 'WE GET STUCK HERE!!!
gosub grf_clr
gosub show
pause 1000
goto main
end
logo64: '64x64 image
@ 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, 192, 112, 60, 28, 6, 7, 3
@ db 3, 7, 6, 14, 28, 112, 224, 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, 248, 254, 7, 7, 3, 3, 3, 3
@ db 3, 6, 2, 6, 4, 12, 136, 184, 23, 33, 64, 64, 0, 128, 0, 0
@ db 0, 0, 0, 128, 64, 32, 33, 23, 120, 136, 12, 4, 4, 6, 2, 3
@ db 3, 3, 3, 3, 7, 6, 254, 252, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 60, 224, 128, 128, 128, 128
@ db 0, 64, 0, 64, 0, 64, 110, 0, 32, 0, 64, 32, 32, 8, 33, 2
@ db 6, 9, 32, 16, 0, 32, 128, 32, 0, 21, 96, 0, 64, 64, 0, 64
@ db 128, 128, 128, 128, 224, 28, 15, 1, 0, 0, 0, 0, 0, 0, 0, 0
@ db 192, 224, 120, 24, 28, 4, 6, 2, 3, 0, 1, 0, 1, 6, 8, 16
@ db 32, 0, 192, 0, 32, 154, 4, 0, 1, 128, 224, 248, 248, 252, 252, 254
@ db 252, 252, 252, 252, 248, 224, 64, 1, 2, 0, 73, 16, 64, 128, 0, 64
@ db 32, 8, 6, 1, 1, 1, 1, 3, 2, 6, 12, 12, 56, 112, 240, 192
@ db 3, 15, 30, 24, 60, 96, 96, 64, 192, 128, 128, 128, 128, 64, 60, 12
@ db 2, 1, 0, 2, 0, 0x2C, 144, 0, 0, 0, 15, 31, 31, 63, 127, 63
@ db 127, 63, 63, 31, 31, 15, 1, 128, 0, 32, 0x94, 8, 2, 0, 1, 2
@ db 8, 16, 96, 128, 0, 128, 128, 64, 64, 96, 96, 60, 24, 14, 15, 3
@ db 0, 0, 0, 0, 0, 0, 0, 0, 128, 240, 56, 7, 1, 1, 1, 0
@ db 3, 0, 2, 2, 4, 2, 234, 4, 0, 1, 4, 4, 0, 12, 144, 64
@ db 64, 36, 152, 0, 4, 2, 0, 4, 0, 178, 6, 0, 2, 2, 2, 2
@ db 0, 1, 1, 1, 7, 28, 240, 128, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 31, 127, 240, 192, 192, 192, 192, 192
@ db 192, 192, 32, 96, 32, 16, 16, 31, 248, 132, 4, 2, 1, 0, 0, 0
@ db 0, 0, 0, 1, 2, 4, 132, 120, 31, 16, 60, 32, 32, 96, 64, 192
@ db 192, 192, 192, 192, 224, 112, 127, 63, 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, 3, 14, 60, 60, 112, 224, 192
@ db 192, 224, 112, 112, 24, 30, 3, 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
there is no need to modify the include
the correct usage is
DMDBMP 0,0,logo64
bmp's need a header to set width and height
Code:logo64: '64x64 image
@ db 64,64 // header width,height
@ 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, 192, 112, 60, 28, 6, 7, 3
@ db 3, 7, 6, 14, 28, 112, 224, 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, 248, 254, 7, 7, 3, 3, 3, 3
@ db 3, 6, 2, 6, 4, 12, 136, 184, 23, 33, 64, 64, 0, 128, 0, 0
@ db 0, 0, 0, 128, 64, 32, 33, 23, 120, 136, 12, 4, 4, 6, 2, 3
@ db 3, 3, 3, 3, 7, 6, 254, 252, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 60, 224, 128, 128, 128, 128
@ db 0, 64, 0, 64, 0, 64, 110, 0, 32, 0, 64, 32, 32, 8, 33, 2
@ db 6, 9, 32, 16, 0, 32, 128, 32, 0, 21, 96, 0, 64, 64, 0, 64
@ db 128, 128, 128, 128, 224, 28, 15, 1, 0, 0, 0, 0, 0, 0, 0, 0
@ db 192, 224, 120, 24, 28, 4, 6, 2, 3, 0, 1, 0, 1, 6, 8, 16
@ db 32, 0, 192, 0, 32, 154, 4, 0, 1, 128, 224, 248, 248, 252, 252, 254
@ db 252, 252, 252, 252, 248, 224, 64, 1, 2, 0, 73, 16, 64, 128, 0, 64
@ db 32, 8, 6, 1, 1, 1, 1, 3, 2, 6, 12, 12, 56, 112, 240, 192
@ db 3, 15, 30, 24, 60, 96, 96, 64, 192, 128, 128, 128, 128, 64, 60, 12
@ db 2, 1, 0, 2, 0, 0x2C, 144, 0, 0, 0, 15, 31, 31, 63, 127, 63
@ db 127, 63, 63, 31, 31, 15, 1, 128, 0, 32, 0x94, 8, 2, 0, 1, 2
@ db 8, 16, 96, 128, 0, 128, 128, 64, 64, 96, 96, 60, 24, 14, 15, 3
@ db 0, 0, 0, 0, 0, 0, 0, 0, 128, 240, 56, 7, 1, 1, 1, 0
@ db 3, 0, 2, 2, 4, 2, 234, 4, 0, 1, 4, 4, 0, 12, 144, 64
@ db 64, 36, 152, 0, 4, 2, 0, 4, 0, 178, 6, 0, 2, 2, 2, 2
@ db 0, 1, 1, 1, 7, 28, 240, 128, 0, 0, 0, 0, 0, 0, 0, 0
@ db 0, 0, 0, 0, 0, 0, 0, 0, 31, 127, 240, 192, 192, 192, 192, 192
@ db 192, 192, 32, 96, 32, 16, 16, 31, 248, 132, 4, 2, 1, 0, 0, 0
@ db 0, 0, 0, 1, 2, 4, 132, 120, 31, 16, 60, 32, 32, 96, 64, 192
@ db 192, 192, 192, 192, 224, 112, 127, 63, 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, 3, 14, 60, 60, 112, 224, 192
@ db 192, 224, 112, 112, 24, 30, 3, 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
That gets me closer, in the sense I figured it needed specified somewhere! But it doesn't correctly display the image. I have reverted back to non-edited include files. Thoughts? Thank you for your assistance!!!
Attachment 9625
ah! the bmps are in a different format the byte are now laid out horizontally
i also discovered the dmp code upsets the font height [did have a shared variable]
i used lcdassistant to generate bmps
some files to play with
Attachment 9628
glcd tools also works well in generating bmp's
and formats the data nicely
Attachment 9629
The only version of GLCD Tools I can find is 0.2. I have been using LCD Assistant, but I'm having mixed results. Do you have a link to download GLCD Tools 1.5?
This attached file has a few BMP's in it, the Logo64 opens successfully, except it takes 5+ seconds to display each image after the screen clear... The other 2 (StallIcon and OneIcon) both don't load and results in a bricked display until power cycle. I have tried other's and can't get them to open.
These were created with LCD Assistant set to horizontal and formatted appropriately.
I'm not sure the reason for the failed images to display,
I'm not sure the reason for the really slow load times to display the images
The SSD1306 driver this thread was created for loads images with excellent performance.
I resolved the slow load times by commenting out the debug lines in the sbmp subroutine.
I have found if I revise the first byte of the bitmap to = 0x00 instead of the value it should be, the image will display. Obviously missing the first 8 pixels worth of data though...
I have everything working, but using the SSDBM version for bitmap. This obviously required modifying the include files, but everything seems to be getting along.
I can share the modified files, but won't if you prefer as to prevent confusion. If you find a fix for the DMDBMP version, I'm sure it is a better solution.
Thanks for your work on this Richard!
there was another bug in the include, the bpm height var was reading in the first byte of the image as its high.byte
when there was not meant to be a high.byte
and i did accidentally leave the debug messages active
i have updated the include in the proper thread
i cant find the gltools on the web any more
i did find my install version in my downloads folder
at your own risk
Thanks Richard!