Graphical Displays with PBP3


+ Reply to Thread
Results 1 to 27 of 27
  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    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
    This is more entertaining than Free to Air TV

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

    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
    1,945

    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: 365
Size:  159.7 KB

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

    nokia 7110 too
    Attached Files Attached Files
    Last edited by richard; - 20th March 2021 at 12:52.
    This is more entertaining than Free to Air TV

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

    Default Re: Graphical Displays with PBP3

    That is awesome!

    Thanks for sharing,
    Ioannis

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

    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
    1,945

    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 .
    This is more entertaining than Free to Air TV

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

    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
    87

    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
    87

    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
    1,945

    Default Re: Graphical Displays with PBP3

    it appears there was a bug in drawing vertical lines. this now works
    Attached Files Attached Files
    This is more entertaining than Free to Air TV

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

    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
    87

    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
    1,945

    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.
    This is more entertaining than Free to Air TV

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

    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
    1,945

    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
    This is more entertaining than Free to Air TV

  16. #16
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    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
    This is more entertaining than Free to Air TV

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

    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
    87

    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
    1,945

    Default Re: Graphical Displays with PBP3

    needs to multiple of 8 for the rotation to work properly
    This is more entertaining than Free to Air TV

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

    Default Re: Graphical Displays with PBP3

    okay, that was simpler than I expected. Thx

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

    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
    1,945

    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
    This is more entertaining than Free to Air TV

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

    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
    1,945

    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.
    This is more entertaining than Free to Air TV

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

    Default Re: Graphical Displays with PBP3

    No probs.

    Troy

  26. #26
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    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
    This is more entertaining than Free to Air TV

  27. #27
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    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.
    This is more entertaining than Free to Air TV

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

Posting Permissions

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