max7219 4x 8x8 panels spi


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: max7219 4x 8x8 panels spi

    I'm slowly working on an 18F version.
    Currently running on the 18F57Q43 using the SPI peripheral (planning to get to DMA eventually) but can work with MSSP or even SHIFTOUT.
    Supports an arbitrary width display (within limits of available RAM) but only one row (starting to second guess myself on that one). Pixel by pixel scrolling left/right/up/down is almost working. We'll see where this ends up in the comming weeks...

    Name:  DSCF2561.JPG
Views: 1738
Size:  100.4 KB

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


    Did you find this post helpful? Yes | No

    Default Re: max7219 4x 8x8 panels spi

    you could always just add a driver to suit this and not have to reinvent the wheel font&graphics wise etc

    http://www.picbasic.co.uk/forum/showthread.php?t=24218

    i'm sure a max7219 driver would be easy enough to contrive and it would make multi row /column display simpler
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: max7219 4x 8x8 panels spi

    Quote Originally Posted by HenrikOlsson View Post
    I'm slowly working on an 18F version....
    Very interesting work! Looking forward!

    Ioannis

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


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: max7219 4x 8x8 panels spi

    now with scrolling



    Code:
       
    '****************************************************************'*  Name    : max7219 16f1825                                      *
    '*  Author  : richard                                              *
    '*  Notice  : Copyright (c) 2019                                   *
    '*          :                                                      *
    '*  Date    : 25/2/2020                                            *
    '*  Version : 1.1                                                  *
    '*  Notes   : max7219   5 6x5 chrs on 4 8x8 panels                 *
    '*          : right justified leading zero suppression             *
    '*          :                                                      * 
    '*          :                                                      * 
    '*          : pic16f1825                                           *
    '*******************************************************************
    #CONFIG
                 __config    _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_OFF  &  _PWRTE_ON  &  _MCLRE_ON  & _CLKOUTEN_OFF
                 __config    _CONFIG2, _PLLEN_ON & _LVP_OFF
    #ENDCONFIG
    define OSC 32
    goto overasm 
    asm
    GetAddress macro Label, Wout
        CHK?RP Wout
        movlw low Label          ; get low byte
        movwf Wout
        movlw High Label         ; get high byte
        movwf Wout + 1
        endm
    endasm
    overasm:
    SSPCON1 = $20;
    SSPSTAT = $40;
    ANSELA = 0
    ANSELC = 0
    OSCCON = $70
    
    
    tmp      var byte
    dsp      var byte
    dspbuff  var byte[32]
    BUFF     var byte[16]
    cnt      var byte
    row      var byte
    drow     var byte
    srow     var byte
    col      var byte
    dcol     var byte
    aFont    var word
    fOffset  var word
    cga      var byte
    cgah     var byte
    ch       var byte
    chr      var byte
    inx      var byte
    mask     var word
    counter  var word
    bcnt     var byte
    ncnt     var byte
    number  var word
    clear
    
    
    mxld     var portc.1
    mxck     var portc.0
    mxdi     var portc.2
    
    
    trisc = %11111000
    trisa = %11011110
    lata.0=1
    init:
        lata.5 = 1
        mxld = 1
        dsp = 11
        tmp = 5
        gosub xfer4
        dsp = 9
        tmp = 0
        gosub xfer4
        dsp = 12 
        tmp = 1
        gosub xfer4
        dsp = 10
        tmp = 8     
        gosub xfer4
        dsp = $b
        tmp = 7     
        gosub xfer4
        dsp = $f
        tmp = 0     
        gosub xfer4
    @ GetAddress _font,_aFont
        
    'dspbuff[0]=$73
    'dspbuff[4]=$37 
    counter=1235
        col = 1  
        gosub showrjbuf
        gosub  strchr   
    gosub show  
     pause 100 
    loopy:
    gosub rotate
    '    col = 1  
    '    gosub showrjbuf
    '    gosub  strchr
    '    chr=":" + counter.0
    '    col = 27 
    '    gosub  gcga 
        gosub show
    '    counter  =  counter + 1
       pause 100
    GOTO loopy
    end	 
    
    
    strchr:     ;null  terminated
        bcnt = 0
        while buff[bcnt]
            chr = buff[bcnt]
            gosub gcga 
            bcnt = bcnt + 1
            col = col + 5
        wend
    return 
     
    show:     
        for srow = 0 to 7
            GOSUB SHOWROW 
        next 
    return        
       
    showROW:      
        	mxld = 0		
       	    for dcol = 0 to 3        	 
            	 SSPBUF = srow + 1 
                 while !pir1.3:wend
                 pir1.3 = 0
                 SSPBUF = dspbuff[(srow<<2) + dcol] rev 8
                 while !pir1.3:wend
                 pir1.3 = 0    
            next 
        	mxld = 1 
    return
    
    
    xfer4:
         for dcol = 0 to 3
             mxld = 0
             pir1.3 = 0
             SSPBUF = dsp  
             while !pir1.3:wend
             pir1.3=0
             SSPBUF =tmp 
             while !pir1.3:wend
             pir1.3 = 0
         next
         mxld = 1 
    return
    
    
    gcga:      ;ROW= 0-1 COL=0-28 CHR = SPACE,"0" TO ";"
        if chr = " " then chr = ";"   ;TRANSLATE SPACE TO ";"
        fOffset = (chr - "0")*4 + aFont  ; point to cga data
        drow = 0 
        mask = ~(31<<(col//8))
        inx = col/8
        for tmp = 0 to 3 
            gosub unpack
            inx = (drow<<2) + col/8 
            dspbuff[inx] = dspbuff[inx] & mask.lowbyte
            dspbuff[inx] = dspbuff[inx] | (cga<<(col//8))         
            if  mask.highbyte then
                INX = INX + 1
                dspbuff[inx] = dspbuff[inx] & mask.highbyte
                dspbuff[inx] = dspbuff[inx] | (cga>>(8-col//8) )
                inx = inx + 3
            else
                inx = inx + 4
            endif
            drow = drow + 1
            dspbuff[inx] = dspbuff[inx] & mask.lowbyte
            dspbuff[inx] = dspbuff[inx] | (cgah<<(col//8))
            if  mask.highbyte then
                INX = INX+1
                dspbuff[inx] = dspbuff[inx] & mask.highbyte
                dspbuff[inx] = dspbuff[inx] | (cgah>>(8 - col//8) )
            endif
            drow = drow + 1
            fOffset = fOffset + 1
         next            
    return  
     
    showrjbuf:    ;load  buff righ justified
        number = counter
        for ncnt = 0 to 4
            BUFF[ncnt] = $30
        next
        while number >10000
            buff[0] = buff[0] + 1
            number = number - 10000
        wend
        while number >1000
            buff[1] = buff[1] + 1
            number = number - 1000
        wend 
        while number>100
            buff[2] = buff[2] + 1
            number = number - 100
        wend 
        while number >10
            buff[3] = buff[3] + 1
            number = number - 10
        wend 
        buff[4] = buff[4] + number    
    lzr:       ;repress leading zeros
        for ncnt = 0 to 3
          if BUFF[ncnt] == $30 then
               BUFF[ncnt] = $20
          else
              return
          endif
        next
    return
    
    
    unpack:
        readcode foffset ,cgah 
        cga=(cgah >> 4) 
        cgah=(cgah&15 ) 
    return 
    
    
    rotate:
    asm
        bcf STATUS,C
        rrf   _dspbuff+3,f
        rrf   _dspbuff+2,f
        rrf   _dspbuff+1,f
        rrf   _dspbuff ,f
        btfsc  STATUS, C
        bsf   _dspbuff+3,7
        bcf STATUS,C
        rrf   _dspbuff+7,f
        rrf   _dspbuff+6,f
        rrf   _dspbuff+5,f
        rrf   _dspbuff+4 ,f
        btfsc  STATUS, C
        bsf   _dspbuff+7,7
        bcf STATUS,C
        rrf   _dspbuff+11,f
        rrf   _dspbuff+10,f
        rrf   _dspbuff+9,f
        rrf   _dspbuff+8 ,f
        btfsc  STATUS, C
        bsf   _dspbuff+11,7
        bcf STATUS,C
        rrf   _dspbuff+15,f
        rrf   _dspbuff+14,f
        rrf   _dspbuff+13,f
        rrf   _dspbuff+12 ,f
        btfsc  STATUS, C
        bsf   _dspbuff+15,7
        bcf STATUS,C
        rrf   _dspbuff+19,f
        rrf   _dspbuff+18,f
        rrf   _dspbuff+17,f
        rrf   _dspbuff+16 ,f
        btfsc  STATUS, C
        bsf   _dspbuff+19,7
        bcf STATUS,C
        rrf   _dspbuff+23,f
        rrf   _dspbuff+22,f
        rrf   _dspbuff+21,f
        rrf   _dspbuff+20 ,f
        btfsc  STATUS, C
        bsf   _dspbuff+23,7
        bcf STATUS,C
        rrf   _dspbuff+27,f
        rrf   _dspbuff+26,f
        rrf   _dspbuff+25,f
        rrf   _dspbuff+24 ,f
        btfsc  STATUS, C
        bsf   _dspbuff+27,7
        bcf STATUS,C
        rrf   _dspbuff+31,f
        rrf   _dspbuff+30,f
        rrf   _dspbuff+29,f
        rrf   _dspbuff+28 ,f
        btfsc  STATUS, C
        bsf   _dspbuff+31,7
    endasm
    return 
     
     
    font: 
    @ dw 0x69,0x99,0x99,0x96
    @ dw 0x46,0x54,0x44,0x4F
    @ dw 0x69,0x98,0x61,0x1F
    @ dw 0x69,0x86,0x89,0x96
    @ dw 0x99,0x9E,0x88,0x88
    @ dw 0xF1,0x17,0x89,0x96
    @ dw 0x69,0x17,0x99,0x96
    @ dw 0xF8,0x84,0x42,0x22
    @ dw 0x69,0x96,0x99,0x96
    @ dw 0x69,0x9E,0x89,0x96
    @ dw 0x00,0x10,0x01,0x00
    @ dw 0x00,0x00,0x00,0x00
    Warning I'm not a teacher

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: max7219 4x 8x8 panels spi

    Thanks for the new example.

    In real life does it look like the video? I mean it seems that the scrolling is not very smooth but stepping a bit. OK, since the resolution is not that great this is expected I guess.

    Ioannis

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


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: max7219 4x 8x8 panels spi

    ITS as smooth as silk , can't say the same for the camera

    made a better parametric version too

    Code:
    rotate:
    asm
        banksel _bcnt    ;ROW
        movlw   8
        movwf   _bcnt 
        banksel _inx
        movlw   31         ;BUFFER SIZE
        movwf   _inx
    NROW    
        banksel _inx 
        movlw   high (_dspbuff)
        movwf   FSR0H
        movlw   low  (_dspbuff)
        movwf   FSR0L
        movf    _inx,W
        ADDWF   FSR0L,F
        bcf     STATUS, C
        rrf     INDF0 ,f     ;PER COLUMN
        addfsr  0,-1
        rrf     INDF0 ,f     ;PER COLUMN
        addfsr  0,-1
        rrf     INDF0 ,f     ;PER COLUMN
        addfsr  0,-1
        rrf     INDF0 ,f     ;PER COLUMN
        btfss   STATUS, C
        GOTO    NBNC
        addfsr  0,3
        bsf     INDF0,7
    NBNC 
        movlw   4         ;ROW LENGTH
        SUBWF   _inx,F
        banksel _bcnt
        DECFSZ  _bcnt ,F
        GOTO    NROW
    endasm
    return
    Warning I'm not a teacher

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: max7219 4x 8x8 panels spi

    even nicer

    Code:
    rotate:
    asm
        banksel _bcnt    ;ROW
        movlw   8
        movwf   _bcnt
        movlw   high (_dspbuff)
        movwf   FSR0H
        movlw   low  (_dspbuff)
        movwf   FSR0L
        movlw   31         ;BUFFER SIZE
        ADDWF   FSR0L,F
        banksel _bcnt
    NROW     
        bcf     STATUS, C
        rrf     INDF0 ,f     ;PER COLUMN
        addfsr  0,-1
        rrf     INDF0 ,f     ;PER COLUMN
        addfsr  0,-1
        rrf     INDF0 ,f     ;PER COLUMN
        addfsr  0,-1
        rrf     INDF0 ,f     ;PER COLUMN
        btfss   STATUS, C
        GOTO    NBNC
        addfsr  0,3
        bsf     INDF0,7
        addfsr  0,-3
    NBNC 
        addfsr  0,-1
        DECFSZ  _bcnt ,F
        GOTO    NROW
    endasm
    return
    Warning I'm not a teacher

Similar Threads

  1. 8x8 keypad matrix...
    By mbox in forum General
    Replies: 5
    Last Post: - 9th October 2014, 18:43
  2. 8x8 Scrolling LED display (Simple example)
    By wellyboot in forum Code Examples
    Replies: 68
    Last Post: - 11th July 2013, 05:03
  3. DC/DC with MPPT for solar panels
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 14th May 2013, 02:26
  4. MY FIRST scrolling 8X8 LED
    By earltyso in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th August 2008, 16:23
  5. SPI instead of SHIFTOUT - MAX7219
    By Momboz in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 26th April 2008, 22:58

Members who have read this thread : 1

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