Graphical Displays with PBP3


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

    Default Graphical Displays with PBP3

    i wrote this graphics lib to handle led dmd's [1/4 scan dot matrix displays] in mono, red/green or rgb in varing sizes up to 128x32 pixels.
    it occured to me that with a little more effort it would make a general purpose graphic lib for nearly any display. so here it is.
    it uses mikroe fonts that you can easily generate. the variable width fonts can be up to 23 bits wide if you like.

    a driver for ssd1306, nokia and the ubiquitious 128x64 glcd are included with a small demo for each.
    note this is pic18 pbp3 only and if a mssp port is warranted then its used. there are more functions in the lib than the USERCMDS
    indicate, i never use them all. i could not be bothered making the usecmd code for everything
    i might publish the led dmd stuff at sometime when i work out dma->spi transfers with a k42


    and some fonts


    and some demos
    Attached Files Attached Files
    Warning I'm not a teacher

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    You've done an excellent job. Would you consider posting a small video demo to visualize the results?

    Warm wishes

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    i dropped my camera and its not too happy, the phone makes ridiculous high res movies too big to use online
    so how about a sim still shot
    Name:  glcd.jpg
Views: 1988
Size:  159.7 KB

    Name:  n7110.png
Views: 1914
Size:  34.3 KB

    nokia 7110 too
    Attached Files Attached Files
    Last edited by richard; - 20th March 2021 at 12:52.
    Warning I'm not a teacher

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    That is awesome!

    Thanks for sharing,
    Ioannis

  5. #5
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Fantastic work again Richard!

    Would you have any particular recommendations for a display to purchase for a newbie just as a play-around learning tool ?

    Regards,

    Troy

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    if you don't mind waiting a few weeks the nokia 5110 from china is <$5 . the 7110 have a weird connector and are best avoided imo ,both are good size
    not too many pins needed, 3-5v ok.
    the ssd1306 are about $8 locally but they are pretty small need only two pins if you get i2c variant, 3-5v ok.
    if you catch a special at https://www.rockby.com.au/Index2012.cfm the 128x64 glcd can be real cheap < $5 but need heaps of pins to drive them 5v only.
    they all work .
    Warning I'm not a teacher

  7. #7
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Thanks Richard,
    Ordered a 5110 from Ebay. Looking forward to having a play.

    Cheers,

    Troy

  8. #8
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Richard,
    Received my 5110 display today and have just started to have a play. The nokia demo appears to display perfectly - excellent. I'm a bit stumped on one thing I'm trying to do. The nokia demo draws a circle:

    DRAWCIRCLE 64,15,12

    which I assume is a circle located a x=64, y=15 and radius of 12 yeah?

    so I'm trying to draw a line from the centre of the circle to the top of the circle (or vice versa) so I tried:

    DRAWLINE 64,3,64,15,1

    which I assume is drawing a line from starting point X=64, Y=3 to ending point X=64, Y=15

    And indeed the line starts at the correct point (top centre) but only extends down 7 or 8 pixels ie not to centre of the circle?

    Any ideas?

    Regards,

    Troy

  9. #9
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    So, what's happening (for me) is for a line that's wider than it is higher (or equal), it appears from very initial testing to draw correctly. But if it's higher than it is wider, it doesn't?

    Troy

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    it appears there was a bug in drawing vertical lines. this now works
    Attached Files Attached Files
    Warning I'm not a teacher

  11. #11
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Excellent! Hats off again Richard. This looked like a lot of work in putting it all together. If we ever meet, the drinks will definitely be on me!

    Troy

  12. #12
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Richard,
    Another question: can we pass variables as parameters to these geometric routines?

    Like:

    DRAWLINE My_x1, My_y1, My_x2, My_y2, 1

    So far I'm trying to pass byte size variables but getting illegal opcode messages at compile?

    Troy

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Another question: can we pass variables as parameters to these geometric routines?
    EASY , Just add the needed macro's to the include file, you can dial up whatever you like

    http://www.picbasic.co.uk/forum/show...hlight=ssd1306
    http://www.picbasic.co.uk/forum/show...hlight=usercmd
    http://support.melabs.com/forum/picb...er/usercommand
    Last edited by richard; - 3rd April 2021 at 14:03.
    Warning I'm not a teacher

  14. #14
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    EASY , Just add the needed macro's to the include file, you can dial up whatever you like
    oookay

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    DRAWLINE My_x1, My_y1, My_x2, My_y2, 1
    You need a macro like
    DRAWLINE?BBBBC
    the error message will tell you this does not exist

    the existing drawline macros
    Code:
    ;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


    you could add this



    Code:
    DRAWLINE?BBBBC  macro X0in ,Y0in ,X1in ,Y1in,Col
        MOVE?BB     X0in ,_s_xstart
        MOVE?BB     X1in ,_s_xend
        MOVE?BB     Y0in ,_s_ystart
        MOVE?BB     Y1in ,_s_yend
        MOVE?CB     Col  ,_colour
        L?CALL _dline 
        endm

    or set the colour manually
    eg colour=1

    and use
    DRAWLINE My_x1, My_y1, My_x2, My_y2
    which already exists
    DRAWLINE?BBBB
    with a mono display you probably wont change the colour too often
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    a 5 input user command has the potential to need 5 raised to the 7th power of macros to cover every input permutation possible
    a ridiculous number, i only ever create what seems useful to me. it's trivially easy to add any other combination you app calls for
    and the compiler error virtually spells it out for you
    Warning I'm not a teacher

  17. #17
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Quote Originally Posted by richard View Post
    a 5 input user command has the potential to need 5 raised to the 7th power of macros to cover every input permutation possible
    a ridiculous number, i only ever create what seems useful to me. it's trivially easy to add any other combination you app calls for
    and the compiler error virtually spells it out for you
    Yeah, I did get that part from reading the links you provided - which makes it understandable (I guess) why you don't include that broad functionality.

    Thanks for the example though. I now get it

    Cheers,

    Troy

  18. #18
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Richard,
    with the Nokia 5110 demo settings, the "width" constant is set at 88 instead of 84. Can you explain the reason for that? Like, with other displays, is it just a case of trial & error to gather this parameter or is available in documentation or from standard formula?

    Thanks,

    Troy

  19. #19
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    needs to multiple of 8 for the rotation to work properly
    Warning I'm not a teacher

  20. #20
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    okay, that was simpler than I expected. Thx

  21. #21
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Richard,
    would your drivers (with some tweaking of the input pins) be compatible with the jlx12864g-086 display? Someone online mentioned it would be a good substitute for the 5110 but they seem (to me) to be quite different interfaces?

    Troy

  22. #22
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    don't see why not. they look pretty much like a 128x64 glcd with a serial i/f
    do you have a data sheet ? , i can't locate an English version
    Warning I'm not a teacher

  23. #23
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Unfortunately I can't find one. Amazon says the IC is a UC1701X which there are English data sheets for. Attached is an online translation if that's any use?

    JLX12864G-086.pdf

    TP

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    looking at that ds i expect it would require its own driver to be written to use it with my graphics lib, should be easy enough. i don't have a display to experiment with and
    my simulator does not include a model for the display either so don't hold your breath.
    Warning I'm not a teacher

  25. #25
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    No probs.

    Troy

  26. #26
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Driver for st7920 display for my system

    notes
    you need to change in/out of graphics mode to use lcdout commands on the display if you have the need, i don't

    it doesn't need the r/w pin when used with frame buffering but i did not test it
    Attached Files Attached Files
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    serial i/f and busy flag check added for st7920


    Code:
    '****************************************************************'*  Name    : ST7920-LCD_DEMO.PBP                               *
    '*  Author  : RICHARD                                           *
    '                                                               *
    '*  Date    : 4/8/2017                                          *
    '*  Version : 1.0                                               *
    '*  Notes   : pic18f26k22                                       *
    '*          :  ST7920-LCD 128X64                                *
    '****************************************************************
    #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 = OFF
      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
        
        DEFINE OSC 64
    
    
       
        #DEFINE colours 1   ;1 mono 2 rg or 3 rgb
        width  con 128      ;
        height con 64      ;
        'use serial i/f
        #define  stserial 1
        include "grx.pbpMOD" 
        include "st7920.pbpmod" 
        include "font.bas"
        include "bignum.bas"       
        include "bigchr.bas"
        BUFF       VAR BYTE[32]
        ani_h var word  bank0
        ani_r var byte
        ani_c var byte
        OSCCON=$70
        OSCTUNE.6=1
        while ! osccon2.7 :WEND    ;wait for pll
        ANSELB=0
        ANSELC=0
        ANSELA=0 
        
        trisc = %11010101 ;cs,sck,sdo are output
    
    
    
    
        gosub st7920_init    'graphic mode
        SETFONT FONT5x7
        gosub grf_clr
        
        
        ani_r=%10101011
        ARRAYWRITE BUFF,[bin8 ani_r ,0]
        DMDSTR 3,4,buff,1
        for ani_c=0 to 7
        ani_h=ani_h<<2
        if  ani_r.7 then ani_h=ani_h+3
        ani_r=ani_r<<1
        next
        ARRAYWRITE BUFF,[bin16 ani_h ,0]
        DMDSTR 3,12,buff,1   
        
        
    
    
        ani_r=%10101011
        ARRAYWRITE BUFF,[bin8 ani_r ,0]
        DMDSTR 3,20,buff,1
    
    
    X VAR WORD
    
    
    
    
    x = ani_r;
    x = (x ^ (x << 4)) & $0f0f;
    x = (x ^ (x << 2)) & $3333;
    x = (x ^ (x << 1)) & $5555;
    ani_h = x | (x << 1);
    
    
    
    
    ARRAYWRITE BUFF,[bin16 ani_h ,0]
    DMDSTR 3,28,buff,1
           
     gosub show 
    
    
    
    stop
    Code:
    '****************************************************************'*  Name    : st7920.pbpmod                                     *
    '*  Author  : richard                                           *
    '*  Notice  : Copyright (c) 2021 caveat emptor                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 23/10/2021                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : R/W NOT USED, HAS FRAME BUFFER INSTEAD            *
    '*          : LEVERAGES PBP LCD ROUTINES                        *
    '**************************************************************** 
    'SCREEN MAP    128X64
    'ROW COLUMNS  [WORDS]
    ' 0 | 0 1... 6  7
    ' . |
    ' . |
    ' . |
    ' 30| 
    ' 31| 0 1... 6  7
    ' 0 | 8 9...14 15
    ' . |
    ' . |
    ' 30|
    ' 31| 8 9...14 15
    
    
    '  usual  LCD defines are used  eg
    
    
    '    DEFINE LCD_BITS 4 	'defines the number of data interface lines (4 or 8) 
    '    DEFINE LCD_DREG PORTB	'defines the port where data lines are connected to
    '    DEFINE LCD_DBIT 0	'defines the position of data lines for 4-bit interface (0 or 4)
    '    DEFINE LCD_RSREG PORTB	'defines the port where RS line is connected to
    '    DEFINE LCD_RSBIT 6 	'defines the pin where RS line is connected to 
    '    DEFINE LCD_EREG PORTB 	'defines the port where E line is connected to 
    '    DEFINE LCD_EBIT 4 	'defines the pin where E line is connected 
    '    DEFINE LCD_COMMANDUS 1000 	'defines the delay after LCDOUT statement 
    '    DEFINE LCD_DATAUS 40 		'delay in micro seconds
    '    DEFINE LCD_RWREG PORTB ' LCD read/write port
    '    DEFINE LCD_RWBIT 5 ' LCD read/write pin bit
    ''END of LCD DEFINES 
    
    
    
    
    st7920_page var byte
    st7920_gli  var byte
    st7920_inx  var word
    st7920_tmx  var word
    st7920_lfx  var word
    st7920_bf   var byte
    
    
    
    
    
    
    goto overst7920
    #ifndef stserial  
    '4 or 8 bit parallel normsl pbp lcd defs
    st7920_init:
        lcdout $FE,$24 'In same instruction cannot alter DL, RE and G at once. Make sure that change DL or G first and then RE.
        lcdout $FE,$26 
        bgcolour = 0
        colour = 1
    return 
    
    
    st7920_send:   'd in R3
    @  L?CALL lcdsend
    return    
        
    
    
    
    
    st7920_busy:
       TRISB=TRISB&240
    ASM 
        MOVLW 0X0F
        IORWF LCD_DREG+0X12,F
        bsf   LCD_RWREG ,LCD_RWBIT
        NOP
        bcf   LCD_RSREG ,LCD_RSBIT
        NOP
        bsf   LCD_EREG ,LCD_EBIT
        NOP
        NOP
        NOP
        NOP
        MOVFF LCD_DREG ,_st7920_bf
        MOVF  LCD_DREG,W
        BANKSEL  _st7920_bf
        MOVWF   _st7920_bf
        bcf   LCD_EREG ,LCD_EBIT
        NOP
        NOP 
        NOP
        NOP        
        bsf   LCD_EREG ,LCD_EBIT
        NOP
        NOP
        NOP
        NOP
        bcf   LCD_EREG ,LCD_EBIT
        NOP
        NOP 
        NOP
        NOP
        bsf   LCD_RSREG ,LCD_RSBIT
        bcf   LCD_RWREG ,LCD_RWBIT
        NOP
        NOP
        MOVLW 0XF0
        ANDWF LCD_DREG+0X12,F
        BANKSEL 0
        ENDASM
     RETURN
     
    setxy:
    GOSUB   st7920_busy
    IF   st7920_bf.3 THEN  GOTO setxy
    ASM
        MOVLW 128
        BANKSEL _st7920_gli
        IORWF   _st7920_gli,W
        BANKSEL R3
        MOVWF   R3
        bcf   LCD_RSREG ,LCD_RSBIT
        MOVE?CT 1,FLAGS ,0
        L?CALL _st7920_send
        MOVLW 128
        BANKSEL _st7920_page
        IORWF   _st7920_page,W
        BANKSEL R3
        MOVWF   R3 
        bcf   LCD_RSREG ,LCD_RSBIT   
        MOVE?CT 1,FLAGS ,0
        L?CALL _st7920_send
        BANKSEL 0
    ENDASM
    return
    senddat16:
    GOSUB   st7920_busy
    IF   st7920_bf.3 THEN   GOTO setxy
    asm
        MOVE?BB   _st7920_tmx ,R3
        bsf   LCD_RSREG ,LCD_RSBIT
        MOVE?CT 1,FLAGS ,0
        L?CALL _st7920_send
        bsf  LCD_RSREG ,LCD_RSBIT
        MOVE?BB   _st7920_tmx+1 ,R3
        MOVE?CT 1,FLAGS ,0
        L?CALL _st7920_send
        BANKSEL 0
    ENDASM
    
    
    return 
    show:     'SEE MAP
        for  st7920_GLi = 0 to 31
            st7920_page = 0
            gosub setxy
            st7920_inx = st7920_gli*16
            for st7920_page = 0 TO 7    ;IS WORDS 0-7 IN TOP HALF
                st7920_tmx.lowbyte = fbr[st7920_inx] REV 8
                st7920_inx = st7920_inx + 1
                st7920_tmx.highbyte = fbr[st7920_inx]  REV 8
                st7920_inx = st7920_inx + 1
                gosub  senddat16
            next
            st7920_inx = st7920_gli*16+512
            for st7920_page = 0 TO 7     ;IS WORDS 8-15 IN BOTTOM HALF
                st7920_tmx.lowbyte = fbr[st7920_inx]  REV 8
                st7920_inx = st7920_inx + 1
                st7920_tmx.highbyte = fbr[st7920_inx]  REV 8
                st7920_inx = st7920_inx + 1
                gosub  senddat16
            next 
        next     
    return
    
    
    ;spi
    #else
    st7920_dat   var byte
    'spi pins used
    st7920_cs   var latc.1 
    'st7920_sck  is latc.3
    'st7920_sdi  is latc.4
    'st7920_sdo  is latc.5
    
    
    st7920_init:
      SSP1CON1=$22  ;$22 fastest that works @64m
      SSP1STAT=$40
      st7920_cs=1
      st7920_dat = %00001100
      gosub ST7920Command
      st7920_cs=0
      pause 20
      st7920_cs=1
      st7920_dat = %00100100 ; //EXTENDED INSTRUCTION SET
      gosub ST7920Command
      st7920_dat = %00100110 ; //EXTENDED INSTRUCTION SET
      gosub ST7920Command
      st7920_cs=0
      bgcolour = 0
      colour = 1
    return  
    
    
    setxy: 
        st7920_dat = st7920_gli| 128
        gosub ST7920Command
        st7920_dat = st7920_page| 128 
        gosub ST7920Command
    return 
    
    
    
    
    ST7920Data: 
      	PIR1.3=0     
        SSP1BUF = %11111010 
        WHILE   !PIR1.3 :    wend
        PIR1.3=0     
        SSP1BUF = (st7920_dat & %11110000)
        WHILE   !PIR1.3 :    wend
        PIR1.3=0     
        SSP1BUF = (st7920_dat<< 4)
        WHILE   !PIR1.3 :    wend
      	pauseus 50
    return
    
    
    ST7920Command:   
      	PIR1.3=0     
        SSP1BUF = %11111000
        WHILE   !PIR1.3 :    wend
        PIR1.3=0     
        SSP1BUF = st7920_dat & %11110000
        WHILE   !PIR1.3 :    wend
        PIR1.3=0     
        SSP1BUF = (st7920_dat<< 4)
        WHILE   !PIR1.3 :    wend
      	pauseus 100
    return
    
    
    show:     'SEE MAP
        for  st7920_GLi = 0 to 31
            st7920_cs=1
            st7920_page = 0
            gosub setxy
            st7920_inx = st7920_gli*16
            for st7920_page = 0 TO 7    ;IS WORDS 0-7 IN TOP HALF
                st7920_dat = fbr[st7920_inx] REV 8
                gosub  ST7920data
                st7920_inx = st7920_inx + 1
                st7920_dat = fbr[st7920_inx]  REV 8
                gosub  ST7920data
                st7920_inx = st7920_inx + 1
            next
            st7920_inx = st7920_gli*16+512
            for st7920_page = 0 TO 7     ;IS WORDS 8-15 IN BOTTOM HALF
                st7920_dat = fbr[st7920_inx] REV 8
                gosub  ST7920data
                st7920_inx = st7920_inx + 1
                st7920_dat = fbr[st7920_inx]  REV 8
                gosub  ST7920data
                st7920_inx = st7920_inx + 1
            next
           st7920_cs=0  
        next
    return
    
    
    senddat16:
                st7920_dat = st7920_tmx REV 8
                gosub  ST7920data
                st7920_dat = (st7920_tmx>>8) REV 8
                gosub  ST7920data
    return
    #endif
    
    
    
    
    
    
    overst7920:
    Last edited by richard; - 25th October 2021 at 00:51.
    Warning I'm not a teacher

  28. #28
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Hi Richard,
    Ordered a couple of st7920 displays for this and in the mean time I'm revisiting the Nokia display. 1 question: you're driving the 18F26K22 @64MHz for the sample codes; is that necessary? Can I drive the display using the same processor at, say, 16 MHz?

    Thanks,

    Troy

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    1 question: you're driving the 18F26K22 @64MHz for the sample codes; is that necessary? Can I drive the display using the same processor at, say, 16 MHz?
    no not essential any speed will work, its just slower. the hw 12c / spi speeds can be tweaked in some cases to compensate
    Warning I'm not a teacher

  30. #30
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Hi Richard,
    I've received my "st7920" displays from China (at least they're supposed to be) but I can't get anything from them from running your original code attachments in post #26. I haven't tried any of the code in #27 yet as I'm having problems with the "st7920.pbpmod" code having duplicate subroutines???
    Anyway, can you possibly post a link or example of the wiring to this display. So far, I've connected all the 4 data lines, E bit, RS & RW bits to the declared PortB pins in your code. I've connected the V0 pin via a 10K pot and I've pulled up the serial/parallel selection pin to parallel selection and of course connected the power rails.

    Thanks,

    Troy

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


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    for parallel i/f the connections are as defined
    'LCD defines begin here
    ' DEFINE LCD_BITS 4 'defines the number of data interface lines (4 or 8)
    ' DEFINE LCD_DREG PORTB 'defines the port where data lines are connected to
    ' DEFINE LCD_DBIT 0 'defines the position of data lines for 4-bit interface (0 or 4)
    ' DEFINE LCD_RSREG PORTB 'defines the port where RS line is connected to
    ' DEFINE LCD_RSBIT 6 'defines the pin where RS line is connected to
    ' DEFINE LCD_EREG PORTB 'defines the port where E line is connected to
    ' DEFINE LCD_EBIT 4 'defines the pin where E line is connected
    ' DEFINE LCD_COMMANDUS 1500 'defines the delay after LCDOUT statement
    ' DEFINE LCD_DATAUS 60 'delay in micro seconds
    ' DEFINE LCD_RWREG PORTB ' LCD read/write port
    ' DEFINE LCD_RWBIT 5 ' LCD read/write pin bit
    ' 'END of LCD DEFINES

    for serial i/f the connections are the mssp sdi sdo sck pins plus what you pick for st7920_cs
    the st7920_rst pin was not required in my tests.

    for a 26k22 i used
    'spi pins used
    'st7920_rst var latc.0
    st7920_cs var latc.1
    'st7920_sck is latc.3
    'st7920_sdi is latc.4
    'st7920_sdo is latc.5

    I'm having problems with the "st7920.pbpmod" code having duplicate subroutines???
    there is no problem pbp just doesn't understand conditional compilation, ignore the warnings
    Last edited by richard; - 20th September 2022 at 02:51.
    Warning I'm not a teacher

  32. #32
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    there is no problem pbp just doesn't understand conditional compilation, ignore the warnings
    Maybe it's because I thought I needed to compile that include file (on its own) where I probably don't?

    Anyway... hmmm... I'll recheck everything and maybe try the serial option if I can't get the parallel working. So far I can't see anything I was doing wrong.

    Cheers,

    Troy

  33. #33
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Maybe it's because I thought I needed to compile that include file (on its own)
    include files will seldom if ever compile on their own
    Warning I'm not a teacher

  34. #34
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    include files will seldom if ever compile on their own
    Cool. I think the parallel version did which probably gave me the wrong assumptions. Anyway... couldn't get the parallel option working after trying both displays and throwing everything at it. I'm guessing there was a jumper fuse on the display that needed soldering closed to configure the data lines from 8 to 4, but I couldn't find any datasheet for the display so gave up that and went to serial. Took a bit of head scratching to match up the I2C lines to completely different labelled pads on the display, and then I finally got something from the display - a bunch of plain (non graphical looking) 1s and 0s. Took me 5-10 mins to figure out that's actually what was supposed to be there for the serial code - I was expecting demo graphics and large text - but that simply required copying over that stuff from the parallel code.
    So, good stuff again Richard. Hats off and thanks again for the assistance.

    Cheers,

    Troy

  35. #35
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    glad you got something to work

    for parallel mode there is a pin PSB that needs to be set high on the display low for serial

    i used this ds for reference
    Attached Images Attached Images
    Warning I'm not a teacher

  36. #36
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    for parallel mode there is a pin PSB that needs to be set high on the display low for serial
    yeah, I knew about that - that's actually what I was referring to in my post #30, BUT what I didn't know (from glancing over the datasheet you just provided) was that I might have needed to pull data line #5 to ground to configure 4 line mode . Damn.

    Cheers,

    Troy

  37. #37
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    i don't remember doing that and there was no pin on the 20 pin connector to do that. maybe there was a jumper on the display but i thought it was a software selection.
    the parallel conn is on d3 - d7 with d0 - d3 grounded
    the display is off in another project and no longer available to me for confirmation
    Warning I'm not a teacher

  38. #38
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Well, there's 2 things I never considered - (1) using the upper 4 data lines for transfer and (2) grounding the unused.
    It's probably worth mentioning (for a heads up to others) the display I'm using has a serial/parallel 3 pad jumper on the back that was soldered to parallel setting as purchased. I needed to change that to serial in order to operate in serial mode. Whether that eliminates the need to pull/push the PSB pad I never bothered finding out - I just assumed the PSB pad still needed setting.

    edit: just after posting that I realised that jumper is probably a direct link to the PSB pad to push or pull - duh.

    Troy
    Last edited by rocket_troy; - 21st September 2022 at 03:37.

  39. #39
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    127


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    Richard,
    Is it a big deal adding a character like a colon to the large font table? Working out the dot matrix for the character should be pretty straight forward, but not sure about the indexing and whatnot?

    Thanks,

    Troy

  40. #40
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Graphical Displays with PBP3

    you can use your own fonts Generated by MikroElektronika GLCD Font Creator 1.2.0.0
    the font headers have some basic details on how to pbp-ify MikroElektronika fonts


    ;//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
    ;//MikroElektrnika 2011
    ;//http://www.mikroe.com
    ;
    ;//GLCD FontName : Comic_Sans_MS10x14
    ;//GLCD FontSize : 10 x 14
    ; needs a few tweaks for pbp weaknesses
    ;no odd data lines allowed ,shift bytes up to even lines out , no commas on line ends
    ;do not add or remove any bytes
    ;const char bignum[] = {
    Warning I'm not a teacher

Similar Threads

  1. Replies: 3
    Last Post: - 1st January 2021, 22:28
  2. problem using Graphical LCD
    By Mostafa in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2007, 19:15
  3. Graphical LCDs
    By T.Jackson in forum General
    Replies: 5
    Last Post: - 14th May 2007, 07:29
  4. Vb 6.0 Graphical plug in
    By rocky79 in forum Serial
    Replies: 0
    Last Post: - 8th March 2006, 19:42
  5. Graphical user interface
    By rocky79 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th October 2005, 13:25

Members who have read this thread : 17

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