SSD1306 INCLUDE for PBP3


+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 40 of 102
  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512

    Default SSD1306 INCLUDE for PBP3

    Features :-
    Pic 16 or 18
    Tiny size about 1.5k words for soft i2c 1.3k for hw i2c
    64X128 OR 32X128 DISPLAYS
    SOFT I2C OR HARDWARE I2C
    NORMAL OR DOUBLE SIZE CHAR
    HORIZ and VERT LINES
    Speed for hw i2c tested up to 2,666,666 clock rate, makes soft i2c look like a snail
    Simple Usercommand Commands
    Attached Images Attached Images    
    Attached Files Attached Files
    Last edited by richard; - 4th December 2017 at 11:34.
    Warning I'm not a teacher

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    update include
    added inline const string capability for pic16 chips
    Attached Files Attached Files
    Warning I'm not a teacher

  3. #3
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Looks good. I don't have lcd to try it out.
    I hope that you didn't write all user command wrapper manually.
    I posted app for that
    http://www.picbasic.co.uk/forum/showthread.php?t=20208

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Code:
    I hope that you didn't write all user command wrapper manually.
     I posted app for that
    I am aware of your app but the base code for this preceded it , so yes it was a manual work
    I haven't done anything pbp wise with enough user command code in it to use your app yet .it seems that
    I have spent most of my time coming to terms with the mcc and xc8 lately . I don't see myself coming back
    from that exercise now . development wise C is just so much easier, I will still keep hacking away at pbp
    for now anyway.
    Warning I'm not a teacher

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Nice work, thanks Richard for sharing.

    Ioannis

  6. #6
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Thank you for posting an SSD1306 example, Richard. I'd like to bring up my 128x32 OLED display using a 16F1823 and XC8 with a 'retro' TIL311 type font.

    Cheerful regards, Mike
    Attached Images Attached Images  

  7. #7
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Richard, may I ask if you did anything special to run the SSD1306 display and I2C interface at ~2.6-MHz, please? I'm amazed that my setup (on a solderless breadboard) is running without any problems at 1-MHz but when I tried a 2-MHz I2C clock the display doesn't come up. I'm using 3.6 kOhm pull-up resistors on the I2C bus.

    Cheerful regards, Mike
    Attached Images Attached Images  

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    mike
    I had "setup" the display at a lower rate and kept increasing the i2c baud rate till the display failed to update .
    only one of my 6 displays could exceed 1mhz , one had issues above 400khz. I did not look at the pull up resistors .just trusted that the modules were fitted out appropriately. vcc was 3.3 v
    the data sheet specs give a ic2 clock of 2.5uS 400khz so its probably not the best idea I have had.
    i'm running them a 400k for reliability
    Warning I'm not a teacher

  9. #9
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    I didn't realize there were pull-up resistors already installed on the display module. I pulled the 3.6k resistors and the display works fine. My circult and display are running on 5v.

    Thank you again for new info'...

    Hope you and family are well and enjoying a wonderful summer.

    Cheerful regards, Mike

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Hi Richard,

    it's any possibilities to drawing a line like a progress bar?
    For example, I had ADVAL value from 0 to 120, and I want to draw line on OLED.
    I try this:
    Code:
    GLCDDHL 0,0,adval,1
    This didn't work because GLCDDHL accept only numbers not variables like ADVAL.

    It there any way to do it with your include?

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    This didn't work because GLCDDHL accept only numbers not variables like ADVAL.


    It there any way to do it with your include?
    EASY , Just add the highlighted macro's to the include file

    Code:
     ;----------------------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  
    
    
    GLCDDHL?CCBC  macro Xin ,Yin , Win ,Cin
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?BB  Win ,_gl
        MOVE?CB  Cin ,_glcdData 
        L?CALL _xyx
        endm  
    
    
    GLCDDHL?CCWC  macro Xin ,Yin , Win ,Cin
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?WB  Win ,_gl
        MOVE?CB  Cin ,_glcdData 
        L?CALL _xyx
        endm  
    Warning I'm not a teacher

  12. #12


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Thanks Richard, tomorrow I try it.

    And this probably for vertical lines:
    Code:
     ;----------------------VERT LINE------------------------------------        
    GLCDDVL?CCC  macro Xin ,Yin , Hin 
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?CB  Hin ,_gl 
        L?CALL _xyy
        endm 
    
    GLCDDVL?BCC  macro Xin ,Yin , Hin 
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?CB  Hin ,_gl 
        L?CALL _xyy
        endm 
    
    GLCDDVL?WCC  macro Xin ,Yin , Hin 
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?CB  Hin ,_gl 
        L?CALL _xyy
        endm
    Right?

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    And this probably for vertical lines:

    no , the Hin is what you would change


    Code:
    ;----------------------VERT LINE------------------------------------        
    GLCDDVL?CCC  macro Xin ,Yin , Hin 
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?CB  Hin ,_gl 
        L?CALL _xyy
        endm 
    
    
    GLCDDVL?CCB  macro Xin ,Yin , Hin 
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?BB  Hin ,_gl 
        L?CALL _xyy
        endm 
    
    
    GLCDDVL?CCW  macro Xin ,Yin , Hin 
        MOVE?CB  Xin ,_gx 
        MOVE?CB  Yin,_gy 
        MOVE?WB  Hin ,_gl 
        L?CALL _xyy
        endm
    Last edited by richard; - 6th April 2020 at 01:25.
    Warning I'm not a teacher

  14. #14


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    I tried it, and it works for drawing smooth line from variable 0 to 120 for example, but if the value decreasing from 120 to 0 then I'm not able to clean the line without clearing the whole display and it causes flickering.
    Why I need that? I'm trying to make a voltmeter with bargraph.
    Here are the code snipet:
    Code:
    gosub glcd_init
    GLCD_CLR
    
    do
    for n=0 to 120 step 1
    GLCDDHL 0,0,n,1
    next n
    
    for n=120 to 0 step -1
    GLCD_CLR
    GLCDDHL 0,0,n,1
    next n
    loop
    It would be good to have variable option in all options like:
    Code:
    GLCDDHL  var1,0,var2,0
    GLCDDVL  var1,0,var2,0
    GLCD_CLR var1,0,var2,0
    It's that possible?
    Last edited by louislouis; - 6th April 2020 at 17:26.

  15. #15
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    I Think a new command is easier
    USERCOMMAND "GLCD_BAR" ;clear/SET area x,y,X1,Y1,COLOUR


    eg

    GLCD_BAR 0,0,var1,3,1 ;draw a horiz bar from 0,0 to var1 . three pixels wide
    GLCD_BAR 0,0,var1,3,0 ;clear a bar from 0,0 to var1 . three pixels wide

    or

    GLCD_BAR 0,0,3,var1,1 ;draw a vert bar from 0,0 to var1 . three pixels wide
    GLCD_BAR 0,0,3,var1,0 ;clear a bar from 0,0 to var1 . three pixels wide


    i don't have anything setup so this is untested, caveat emptor



    ps if GLCD_BAR 0,0,3,var1,1 is not right then
    GLCD_BAR 0,0,3,var1,255 might be needed
    Attached Files Attached Files
    Last edited by richard; - 6th April 2020 at 23:14.
    Warning I'm not a teacher

  16. #16
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    an improvement if bar cmd fails
    Code:
    gosub glcd_init
    GLCD_CLR
    
    
    do
    for n=0 to 120 step 1
    GLCDDHL 0,0,n,1
    next n
    
    
    for n=120 to 0 step -1
    GLCD_CLR 0,0,120,1 ;is a lot more efficient
    GLCDDHL 0,0,n,1
    next n
    loop
    Warning I'm not a teacher

  17. #17


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Thanks for reply,
    It doesn't work quite well. It draw four lines instead one line. For me is more suitable to have variables in usercommands like I wrote before.
    Code:
    GLCDDHL  var1,0,var2,0
    GLCDDVL  var1,0,var2,0
    GLCD_CLR var1,0,var2,0
    because in this case I can point exactly what and where I want to clear the line, or draw a for example 10pixel wide line and move it horizontally wherever I want with changing variables.
    Code:
    do
    for n=0 to 120 step 1
    GLCDDHL 0,0,n,1
    next n
    
    
    for n=120 to 0 step -1
    GLCD_CLR 0,0,120,1 ;is a lot more efficient
    GLCDDHL 0,0,n,1
    next n
    loop
    This solution I tried before as well, it still flicker if line goes from 120 to 0.

  18. #18
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    i can't follow what your saying
    show some code of what you try an describe what you get or post a pic

    did you try new include file like this for narrow bar?
    GLCD_BAR 0,0,var,1,1 ;draw a horiz bar from 0,0 to var . 1 pixels wide ;//or
    GLCD_BAR 0,0,var,1,255 ;draw a horiz bar from 0,0 to var . 1 pixels wide
    Warning I'm not a teacher

  19. #19


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    I want to create this just with straight one pixel line.

  20. #20
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    i understand what you are trying to do.
    i don't follow how you are trying to implement it
    Warning I'm not a teacher

  21. #21
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    while usercmd helps alleviate the turpitude of pbp's immutable condition when it comes to
    support for any peripheral devices/hardware module less than 20 years old.
    usercmd is by no means perfect, a macro needs to exist for each and every permutation of input term/s
    and that can be lots and lots of macros. i create only the ones i require ,its not difficult to
    add more . a close look at the error messages when compiling tells you whats missing if there is an issue


    pedja089 made this if you want an easy way to cover many bases


    http://www.picbasic.co.uk/forum/show...hlight=usercmd
    Warning I'm not a teacher

  22. #22
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    I suppose you are aware of the Darrel's Bargraph include file (http://dt.picbasic.co.uk/CODEX/LCDBARgraphs). Isn't this enough for your needs?

    Ioannis

  23. #23


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    It took a little while to figure out how to do it, but finally I made it.
    Thanks for help to Richard. He pointed me how to modify usercomands for my needs. Endless possibilities to create a bargraphs, progress bars etc. On camera looks a bit flickery, but in real life no flicker whatssoever.
    Here a little demo how it works:

  24. #24
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    looks good
    Warning I'm not a teacher

  25. #25
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Very nice! Congratulations for the conquer of the Usercommand. Never could find how to make use of it.

    Ioannis

  26. #26
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Hello,

    I need help getting this to work. My oled display does not respond at all and appears off. I'm running the sd1306_demo_16.pbp program. Everything compiles fine. I'm using a 16F1619. Here is what I've tried so far.

    1. I tried both the old and newer i2c.inc files
    2. Confirmed the oled works by using it on an Arduino
    3. Confirmed the proper oled address with the Arduino (0x3C). I made the change in the demo.pbp file
    4. Ran blink LED program on the PIC16F1619 to verify functionality
    5. Tried at lower 4Mhz clock speed
    6. Checked Clock and Data pins with scope to make sure data was being output to the display, it is
    7. Tried two other oled

    I'm not sure what else to try. I've never used an include file before so maybe I'm doing something wrong. I put all the include files and font files in the same folder as the .pbp file location.

    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

  27. #27
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    3. Confirmed the proper oled address with the Arduino (0x3C). I made the change in the demo.pbp file
    arduino use a 7 bit address pbp uses an 8 bit addresss , correct address to use is (arduino address)<<1
    0x3c<<1 = 0x78
    Warning I'm not a teacher

  28. #28
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    thanks Richard,

    I had no idea. I changed the address back to 0x78 just now and I still don't get anything on the screen. I get this ASM Warning in the results window after compiling. Not sure if it matters

    [ASM WARNING] SD1306_DEMO_16.ASM (400) : Found label after column 1. (GLCD_BAR?CCBWC)
    [ASM WARNING] SD1306_DEMO_16.ASM (432) : Found label after column 1. (GLCD_BAR?CCBWC)

  29. #29
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    I get this ASM Warning in the results window after compiling. Not sure if it matters

    [ASM WARNING] SD1306_DEMO_16.ASM (400) : Found label after column 1. (GLCD_BAR?CCBWC)

    [ASM WARNING] SD1306_DEMO_16.ASM (432) : Found label after column 1. (GLCD_BAR?CCBWC)
    it does matter, it means you are not compiling the code you posted.
    Found label after column 1 means the macro you are trying to compile does not exist.

    the GLCD_BAR usercommand does not exist in the original include it was added to for louis' setup and only a small subset of input var combinations are
    catered for. i have not tested the added code and am not sure what louis wound up with.

    get the demo working first



    Warning I'm not a teacher

  30. #30
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    thanks, I went back and used the original ssd1306_I2C.inc. Now no warning when I compile. With no changes to the demo I still can't get anything to show on the oled. To make sure the oled hardware is still good I just checked it with the arduino and it's working fine. I've triple checked my wiring and don't see any mistakes.

  31. #31
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    i havent used one of those displays for some time ,my other demo for a pic16f1619 used the mssp i2c module
    try this ,it worked on my curiosity board , plugged straight in to click socket
    Code:
     '****************************************************************
    '*  Name    : ssd1306_DEMO.PBP                                   *
    '*  Author  : richard                                            *
    '*  Notice  :                                                    *
    '*          :                                                    *
    '*  Date    : 19/11/2017                                         *
    '*  Version :                                                    *
    '*  Notes   : plugs into click port note !!!!sda/scl     swapped on click skt*
    '*          :FOR pic 16F1619             SSD1306                 *
    '****************************************************************
    #CONFIG
        __config _CONFIG1,  _FOSC_INTOSC & _PWRTE_OFF & _MCLRE_ON & _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
    
    
     
    ; --- *** Oscillator  *** ---------------------------------------------------
    OSCCON = %11110000           ;32 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.4      ' I2C Clock
    'SDA var PortB.6      ' I2C Data
    RB VAR WORD
    ;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_16.bas"
    '==========================    MAIN  Routine    ==============================
    TRISB = $F0;
    PPSLOCK = $55;
    PPSLOCK = $AA;
    PPSLOCK = 0 ;     unlock PPS
    SSPCLKPPS = $0C;   //RB4->MSSP:SCL;
    SSPDATPPS = $0E;   //RB6->MSSP:SDA;
    RB6PPS = $11;   //RB6->MSSP:SDA;
    RB4PPS = $10;   //RB4->MSSP:SCL;
    PPSLOCK = $55;
    PPSLOCK = $AA;
    PPSLOCK = 1; ; lock PPS   
    
    
    gosub glcd_init
    GLCD_CLR
    BIG_TEXT = 0
    ARRAYWRITE BUFF,["READY",0]
    GLCDSTR 10,1,BUFF
    Warning I'm not a teacher

  32. #32
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    unfortunately I don't get anything on the oled

  33. #33
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Maybe it is nonsense this but, is there a contrast control? I had an issue once on LCD with this.

    Ioannis

  34. #34
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    thanks but no, there is no contrast control. if anyone has any ideas let me know. i'll post if I ever figure it out

  35. #35
    wizard's Avatar
    wizard Guest


    Did you find this post helpful? Yes | No

    Question Re: SSD1306 INCLUDE for PBP3

    Hi Guys
    Can anyone help! I am trying to get this code to work with a 16f88 and a 128x32 OLED.

  36. #36
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,569


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    I'm using Richards code with a small 0.96" 128x32 OLED display, soft I2C (because the 18F46K42 doesn't have the "old" MSSP module).
    I've managed to print text and variables on the screen but in order to update those values without clearing the whole screen I'm trying to figure out how to use the GLCD_CLR command to clear an area.

    I can make it do something but what it does doesn't make much sense to me. It seems to be pixel by row based but still, it's acting weirdly on me.
    For example, with the following screen as a starting point:
    Name:  SSD1306_1.png
Views: 6631
Size:  235.6 KB

    GLCD_CLR 0,0,5,1 or GLCD_CLR 0,0,10,1 does absolutely nothing while GLCD_CLR 0,0,10,2 does this:

    Name:  SSD1306_2.png
Views: 6555
Size:  216.1 KB

    GLCD_CLR 10,0,40,1 does this (which is reasonable, clearing a section of 30pixels wide, 1 row high):

    Name:  SSD1306_3.png
Views: 6661
Size:  213.0 KB

    While GLCD_CLR 10,0,41,1 does this:

    Name:  SSD1306_4.png
Views: 6725
Size:  225.1 KB

    I'm also getting strange results with the GLCD_BAR command. Anyone knows/understands what's going on here? Am I using it wrong or have I stumbled across an issue?

    /Henrik.

  37. #37
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,569


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Well, it turns out I don't have to worry about manually blanking out "stuff" - it just works. Still curious about the GLCD_CLR though.

  38. #38
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    henrik
    there is a great probability i never tested it to any great extent , was just happy that it cleared to whole screen at a default setting

    this works for one line as i intended things to [you need to work around the limited size of the data buffer glcd_buff]

    Code:
    gx=5:gx_=32:gy=0:gy_=0  ;  clear from x=5 for 32 bits one line 
    gosub setxy
    j=0
    for i=0 to gx_
    glcd_buff[i]=0   ;by default the buffer is 32 bytes so be wary
    next
    glcd_rad=gx_
    gosub ssd_data
    two lines
    Code:
    gx=5:gx_=32:gy=0:gy_=1
    gosub setxy
    j=0
    for i=0 to gx_
    glcd_buff[i]=0
    next
    glcd_rad=gx_
    gosub ssd_data
    gosub ssd_data
    you may be able to figure out why the command fails , i'm just not seeing it at the present time
    Last edited by richard; - 14th March 2021 at 01:56.
    Warning I'm not a teacher

  39. #39
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    try this
    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
        for GRX = 0 to   CTEMP/32
            gosub ssd_data
        next
        glcd_rad = CTEMP//32
        IF glcd_rad  THEN
            gosub ssd_data
        ENDIF
    return
    Warning I'm not a teacher

  40. #40
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,569


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    Thank you Richard!
    Replacing the glcd_clrxy subroutine with that from post #38 seems to have fixed it.
    It also seems to have made GLCD_BAR more predictable but I have not looked into how they're interconnected.

    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 need to spend some time trying to figure out how it does it's things, would like to be able to add a slightly larger font for example. Guessing I need to replace/change the unpack routine - at the very least.

    This SSD1306-driver saved me alot of time, much appreciated Richard!

    /Henrik.

Similar Threads

  1. SSD1306 Include example
    By timc in forum Code Examples
    Replies: 11
    Last Post: - 28th November 2017, 09:53
  2. SSD1306 start display problem
    By harryweb in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2016, 20:16
  3. Using INCLUDE to add a text file in PBP3
    By Sumobob in forum PBP3
    Replies: 4
    Last Post: - 16th May 2016, 19:56
  4. PBP3 to include 18F97J94?
    By fowardbias in forum PBP3
    Replies: 1
    Last Post: - 18th December 2013, 17:42
  5. Help With OLED Display / 128X64 SSD1306
    By Denner in forum General
    Replies: 6
    Last Post: - 25th May 2013, 16:40

Members who have read this thread : 24

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts