SSD1306 INCLUDE for PBP3


+ Reply to Thread
Results 1 to 40 of 102

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388

    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 10:34.
    Warning I'm not a teacher

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


    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
    737


    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,388


    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,802


    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


    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?

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


    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

  9. #9


    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?

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388


    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 00:25.
    Warning I'm not a teacher

  11. #11


    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 16:26.

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388


    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 22:14.
    Warning I'm not a teacher

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


    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

  14. #14


    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.

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


    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

  16. #16


    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.

  17. #17
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388


    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

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


    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

  19. #19
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    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

  20. #20


    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:

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


    Did you find this post helpful? Yes | No

    Default Re: SSD1306 INCLUDE for PBP3

    looks good
    Warning I'm not a teacher

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


    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

  23. #23
    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

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


    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

  25. #25
    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)

Similar Threads

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

Members who have read this thread : 23

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