Nokia lcd include , small footprint to suit pic16's


Closed Thread
Results 1 to 40 of 111

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    make them static
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    I think I prefer my take on this
    since:-
    the font is automatically located
    the pin/hw defines are in mcc ,therefore its simple to port to any chip that can read its own flash
    its easy to debug
    bigtext and inverted text are easily implemented
    its only 100 or so words bigger


    Code:
    /**
     
            Product Revision  :  PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2
            Device            :  PIC16F1847
            Driver Version    :  2.00
     * font.c included via ide source files
     */
    #include "mcc_generated_files/mcc.h"
    void putwreg(char work);
    void putcmd(char x);
    void WrChar(char );
    void WrStr(const char *);
    extern const char FNT;
    void main(void) {
        // initialize the device
        SYSTEM_Initialize();
        /*                                                                   *
         *  initialize Nokia 5110 LCD display                                *
         *                                                                   */
        __delay_ms(30); //
        LCD_RST_SetLow(); // 5110 'reset' pulse
        __delay_ms(1);
        LCD_RST_SetHigh(); // 5110 'reset' pulse
        __delay_ms(1);
        putcmd(0x20 + 0x01); // function set: extended instructions
        putcmd(0xc8); // set Vop (contrast), 0..127
        putcmd(0x04 + 0x02); // set temperature coefficient, 0..3
        putcmd(0x10 + 0x03); // Set bias system, 0..7
        putcmd(0x20 + 0x00); // function set: standard instructions
        putcmd(0x08 + 0x04); // display control: normal mode
        putcmd(0x80 + 0x20); // set DDRAM X address, 0..83
        putcmd(0x40 + 0x02); // set DDRAM Y address, 0..5
        WrChar('R'); // write ascii character
        WrStr("eady");
        while (1) {
        }
    }
    /**
     End of File
     */
     
    void putwreg(char work) // send byte, msb first (15 words)
    {
        LCD_CE_LAT = 0; // spi enable on
        SPI1_Exchange8bit(work);
        while (!PIR1bits.SSP1IF);
        LCD_CE_LAT = 1; // spi enable off
    } //
    void WrChar(char d) { // for packed 2.5 word 5x7 font
        uint16_t tmp, inx = (uint16_t) & FNT;
        char fd[6], j = 0, k = 3, *pt;
        inx += ((uint16_t) (d - 32)*5) >> 1;
        while (k--) {
            tmp = FLASH_ReadWord(inx++);
            fd[j + 1] = tmp & 0x7f;
            tmp <<= 1;
            fd[j] = tmp >> 8;
            j += 2;
        }
        pt = fd;
        if ((d & 1))pt++;
        k = 5;
        // with font now stored in bufer fd its easy to have large and/or inverted text
        while (k--) {
            putwreg(*pt++);
        }
        putwreg(0);
    }
    void putcmd(char x) {
        LCD_DC_SetLow();
        putwreg(x);
        LCD_DC_SetHigh();
    }
    void WrStr(const char *buff) {
        { //
            while (*buff)
                WrChar(*buff++); //
        }
    }
    font.c
    Code:
    #include <xc.h>
    #asm
    psect FONT_table,class=CODE,local,delta=2
      GLOBAL _FNT
    _FNT
            DW 0x0000, 0x0000, 0x0000, 0x005F, 0x0000 //  32 ' '  '!'
            DW 0x0007, 0x0007, 0x0014, 0x3F94, 0x3F94 //  34 '"'  '#'
            DW 0x122A, 0x3FAA, 0x0923, 0x0988, 0x3262 //  36 '$'  '%'
            DW 0x1B49, 0x2AA2, 0x2800, 0x0283, 0x0000 //  38 '&'  '''
            DW 0x001C, 0x1141, 0x0000, 0x20A2, 0x0E00 //  40 '('  ')'
            DW 0x0A08, 0x1F08, 0x0A08, 0x043E, 0x0408 //  42 '*'  '+'
            DW 0x0050, 0x1800, 0x0008, 0x0408, 0x0408 //  44 ','  '-'
            DW 0x0060, 0x3000, 0x0020, 0x0808, 0x0202 //  46 '.'  '/'
            DW 0x1F51, 0x24C5, 0x1F00, 0x217F, 0x2000 //  48 '0'  '1'
            DW 0x2161, 0x28C9, 0x2321, 0x20C5, 0x25B1 //  50 '2'  '3'
            DW 0x0C14, 0x097F, 0x0827, 0x22C5, 0x22B9 //  52 '4'  '5'
            DW 0x1E4A, 0x24C9, 0x1801, 0x3889, 0x0283 //  54 '6'  '7'
            DW 0x1B49, 0x24C9, 0x1B06, 0x24C9, 0x149E //  56 '8'  '9'
            DW 0x0036, 0x1B00, 0x0000, 0x2B36, 0x0000 //  58 ':'  ';'
            DW 0x0414, 0x1141, 0x0014, 0x0A14, 0x0A14 //  60 '<'  '='
            DW 0x0041, 0x1114, 0x0402, 0x00D1, 0x0486 //  62 '>'  '?'  
            DW 0x1949, 0x3CC1, 0x1F7E, 0x0891, 0x08FE //  64 '@'  'A'
            DW 0x3FC9, 0x24C9, 0x1B3E, 0x20C1, 0x20A2 //  66 'B'  'C'
            DW 0x3FC1, 0x20A2, 0x0E7F, 0x24C9, 0x24C1 //  68 'D'  'E'
            DW 0x3F89, 0x0489, 0x00BE, 0x20C9, 0x24FA //  70 'F'  'G'
            DW 0x3F88, 0x0408, 0x3F80, 0x20FF, 0x2080 //  72 'H'  'I'
            DW 0x1040, 0x20BF, 0x00FF, 0x0414, 0x1141 //  74 'J'  'K'
            DW 0x3FC0, 0x2040, 0x207F, 0x010C, 0x017F //  76 'L'  'M'
            DW 0x3F84, 0x0410, 0x3FBE, 0x20C1, 0x20BE //  78 'N'  'O'
            DW 0x3F89, 0x0489, 0x033E, 0x20D1, 0x10DE //  80 'P'  'Q'
            DW 0x3F89, 0x0CA9, 0x2346, 0x24C9, 0x24B1 //  82 'R'  'S'
            DW 0x0081, 0x3F81, 0x00BF, 0x2040, 0x203F //  84 'T'  'U'
            DW 0x0FA0, 0x2020, 0x0FBF, 0x2038, 0x203F //  86 'V'  'W'
            DW 0x3194, 0x0414, 0x3187, 0x0470, 0x0407 //  88 'X'  'Y'
            DW 0x30D1, 0x24C5, 0x2180, 0x3FC1, 0x2080 //  90 'Z'  '['
            DW 0x0104, 0x0410, 0x1000, 0x20C1, 0x3F80 //  92 '\'  ']'
            DW 0x0202, 0x0082, 0x0240, 0x2040, 0x2040 //  94 '^'  '_'
            DW 0x0001, 0x0104, 0x0020, 0x2A54, 0x2A78 //  96 '`'  'a'
            DW 0x3FC8, 0x2244, 0x1C38, 0x2244, 0x2220 //  98 'b'  'c'
            DW 0x1C44, 0x2248, 0x3FB8, 0x2A54, 0x2A18 // 100 'd'  'e'
            DW 0x047E, 0x0481, 0x010C, 0x2952, 0x293E // 102 'f'  'g'
            DW 0x3F88, 0x0204, 0x3C00, 0x227D, 0x2000 // 104 'h'  'i'
            DW 0x1040, 0x223D, 0x007F, 0x0828, 0x2200 // 106 'j'  'k'
            DW 0x0041, 0x3FC0, 0x007C, 0x0218, 0x0278 // 108 'l'  'm'
            DW 0x3E08, 0x0204, 0x3C38, 0x2244, 0x2238 // 110 'n'  'o'
            DW 0x3E14, 0x0A14, 0x0408, 0x0A14, 0x0C7C // 112 'p'  'q'
            DW 0x3E08, 0x0204, 0x0448, 0x2A54, 0x2A20 // 114 'r'  's'
            DW 0x023F, 0x2240, 0x103C, 0x2040, 0x107C // 116 't'  'u'
            DW 0x0E20, 0x2020, 0x0E3C, 0x2030, 0x203C // 118 'v'  'w'
            DW 0x2228, 0x0828, 0x220C, 0x2850, 0x283C // 120 'x'  'y'
            DW 0x2264, 0x2A4C, 0x2200, 0x0436, 0x2080 // 122 'z'  '{'
            DW 0x0000, 0x3F80, 0x0000, 0x20B6, 0x0400 // 124 '|'  '}'
            DW 0x0808, 0x0410, 0x0478, 0x2341, 0x2378 // 126 '~'  ''
    #endasm
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    tried a pbp version for the 5 byte compressed packed font, the unpacking done without asm
    takes more code space than the compressing saves

    inc file
    Code:
    '****************************************************************
    '*  Name    : NOKIA_ds5.INC                                     *
    '*  Author  : richard                                           *
    '*  Notice  :                                                   *
    '*          :                                                   *
    '*  Date    : 26/05/2018                                        *
    '*  Version : 1.0b mssp1 version  bigtxt                        *
    '*  Notes   :  inverse text  mike 5 byte font version           *
    '*          :FOR pic 16/18       NOKIA LCD                      *
    '****************************************************************
     
     goto overglcd
    ;##################################################################
    ; adjust these definitions to suit and  place in main prg
    
    '#DEFINE PIC16 1  ;IF PIC18 NOT USED
    '#define use_mssp 1  ;if mssp used DON'T FORGET to set sdo and sck pins as o/p's
    ' lcdheight con 5      ;  6 PAGES  
    ' lcdwidth  con 84     ; 84 PIXELS WIDE
     ;--------------ONLY IF MSSP NOT USED---------------
    ' LCD_CLK  var     Portb.4       '  Clock
    ' LCD_DIN  var     Portb.2       ' Data
    ;-----------------------------------------
    ' LCD_RST  var    PortA.4 
    ' LCD_DC   var    PortA.3
    ' LCD_CE   var    LATA.6
    ' LCD_LIGHT   var PortA.0 
    ;##################################################################
     USERCOMMAND "LCDC"     ;X,Y,CHR  0 <  X < 84  ,   0 <  Y < 7    31 < CHR > 127  
     USERCOMMAND "LCDCLR"   ;clear LCD   
     USERCOMMAND "LCDSTR"   ;STRING @ X,Y  or   Constant String
     USERCOMMAND "LCDCMD"   ;cmd BYTE TO LCD 
     USERCOMMAND "LCDDAT"   ;DATA BYTE TO LCD
    
     ASM  
      ;----[const String]---------------------------------------------------------------
    LCDSTR?CCS  macro Xin ,Yin,Cin 
     IFNDEF  TBLPTRL
        local TheString, OverStr ; define local labels so you can call macro multiple times
        goto OverStr ; goto over string stored in FLASH, so processor can't execute that
    TheString ;label to get address of your string
        da Cin, 0 ;add string to flash at TheString address and end string with 0
    OverStr
        MOVE?CW  TheString, _glcd_bigaddress
        MOVE?CB Xin , _POSX
        MOVE?CB Yin , _POSY
        L?CALL  _GlcdUnpackStr
     ELSE  
        local TheString, OverStr ; define local labels so you can call macro multiple times
        goto OverStr ; goto over string stored in FLASH, so processor can't execute that
    TheString ;label to get address of your string
        data Cin, 0 ;add string to flash at TheString address and end string with 0
    OverStr
        movlw   UPPER TheString
        movwf   TBLPTRU
        movlw   HIGH TheString 
        movwf   TBLPTRH
        movlw   LOW TheString
        movwf   TBLPTRL
        MOVE?CB Xin , _POSX
        MOVE?CB Yin , _POSY
        L?CALL  GLCD_Cstr_out 
     ENDIF     
        endm  
    
     ;----------------------Strings------------------------------------
    LCDSTR?CBB  macro Xin ,Yin ,Bin
        MOVE?CB Xin , _POSX
        MOVE?BB Yin , _POSY
        MOVE?CB high Bin, FSR1H ;load highbyte 
        MOVE?CB low  Bin, FSR1L ;load low byte
        L?CALL  GLCD_str_out
        endm         
    LCDSTR?CCB  macro Xin ,Yin ,Bin
        MOVE?CB Xin , _POSX
        MOVE?CB Yin  ,_POSY
        MOVE?CB high (Bin), FSR1H ;load highbyte 
        MOVE?CB low  (Bin), FSR1L ;load low byte
        L?CALL  GLCD_str_out
        endm              
    LCDSTR?BBB  macro Xin ,Yin ,Bin
        MOVE?B  Xin, _POSX
        MOVE?B  Yin, _POSY
        MOVE?CB high Bin, FSR1H ;load highbyte 
        MOVE?CB low  Bin, FSR1L ;load low byte
        L?CALL  GLCD_str_out
        endm 
    LCDSTR?WBB  macro Xin ,Yin ,Bin
        MOVE?WB Xin, _POSX
        MOVE?BB Yin, _POSY
        MOVE?CB high Bin, FSR1H ;load highbyte 
        MOVE?CB low  Bin, FSR1L ;load low byte
        L?CALL  GLCD_str_out
        endm  
    LCDSTR?WWB  macro Xin ,Yin ,Bin
        MOVE?WB Xin, _POSX
        MOVE?WB Yin, _POSY
        MOVE?CB high Bin, FSR1H ;load highbyte 
        MOVE?CB low  Bin, FSR1L ;load low byte
        L?CALL  GLCD_str_out
        endm 
     
     
    LCDCMD?C  macro Cin
        MOVE?CT 0,_LCD_DC
        MOVE?CB  Cin , _lcdData
        L?CALL   _lcd_byte
       endm 
    LCDCMD?B  macro Cin
        MOVE?CT 0,_LCD_DC
        MOVE?BB  Cin , _lcdData
        L?CALL   _lcd_byte
       endm 
    LCDCMD?W  macro Cin
        MOVE?CT 0,_LCD_DC
        MOVE?WB  Cin , _lcdData
        L?CALL   _lcd_byte
       endm   
       
       
    LCDDAT?C  macro Cin    
        MOVE?CT 1,_LCD_DC
        MOVE?CB  Cin , _lcdData
        L?CALL   _lcd_byte
       endm 
    LCDDAT?B  macro Cin 
        MOVE?CT 1,_LCD_DC   
        MOVE?BB  Cin , _lcdData
        L?CALL   _lcd_byte
       endm    
    LCDDAT?W  macro Cin   
        MOVE?CT 1,_LCD_DC 
        MOVE?WB  Cin , _lcdData
        L?CALL   _lcd_byte
       endm    
    
    LCDCLR? macro
        L?CALL   _lcd_clr
       endm 
    
    
           
     ;----------------------Character @ X,Y ------------------------------------        
    LCDC?BBB  macro Xin ,Yin , Bin
        MOVE?BB  Xin, _POSX 
        MOVE?BB  Yin, _POSY 
        MOVE?BB  Bin, _glcdCh
        L?CALL   _gcga
        endm    
    LCDC?WBB  macro Xin ,Yin , Bin
        MOVE?WB  Xin, _POSX 
        MOVE?BB  Yin, _POSY 
        MOVE?BB  Bin, _glcdCh
        L?CALL   _gcga
        endm  
    LCDC?WWB  macro Xin ,Yin , Bin
        MOVE?WB  Xin, _POSX 
        MOVE?WB  Yin, _POSY 
        MOVE?BB  Bin, _glcdCh
        L?CALL  _gcga
        endm    
            
    LCDC?BBC  macro Xin ,Yin , Cin
        MOVE?BB  Xin, _POSX 
        MOVE?BB  Yin, _POSY 
        MOVE?CB  Cin ,_glcdCh
        L?CALL   _gcga
        endm   
    LCDC?WBC  macro Xin ,Yin , Cin
        MOVE?WB  Xin, _POSX 
        MOVE?BB  Yin, _POSY 
        MOVE?CB  Cin ,_glcdCh
        L?CALL   _gcga
        endm
    LCDC?CCC  macro Xin ,Yin ,Cin
        MOVE?CB  Xin ,   _POSX 
        MOVE?CB  Yin,    _POSY 
        MOVE?CB  Cin,   _glcdCh
        L?CALL   _gcga 
        endm   
    LCDC?CCB  macro Xin ,Yin ,Bin
        MOVE?CB  Xin ,  _POSX 
        MOVE?CB  Yin,    _POSY 
        MOVE?BB  Bin, _glcdCh
        L?CALL   _gcga 
        endm  
    LCDC?B  macro Bin    
        MOVE?BB  Bin, _glcdCh
        L?CALL   _gcga 
        endm  
    
        
       
    GLetAddress macro Label, Wout
        CHK?RP Wout
        movlw low Label          ; get low byte
        movwf Wout
        movlw High Label         ; get high byte
        movwf Wout + 1  
        BANKSEL 0
        endm 
     IFDEF    TBLPTRL 
    GLCD_Cstr_out
        tblrd   *+
        movf   TABLAT,w
        bz	GLCD_exit_Cstr_out  ; EXIT ON Null char 
        CHK?RP  _glcdCh 
        MOVWF   _glcdCh 
        CHK?RP  _glcd_bigaddress
        movff   TBLPTRU,_glcd_bigaddress
        movff   TBLPTRH,_glcd_bigaddress+1
        movff   TBLPTRL,_glcd_bigaddress+2
        L?CALL  _gcga
        CHK?RP  _glcd_bigaddress
        movff   _glcd_bigaddress   ,TBLPTRU
        movff   _glcd_bigaddress+1 ,TBLPTRH
        movff   _glcd_bigaddress+2 ,TBLPTRL
        bra     GLCD_Cstr_out        
    GLCD_exit_Cstr_out
        BANKSEL 0
        return 
         
    
          
    GLCD_str_out
        movf POSTINC1, W	; Get a character
        bz	GLCD_exit_strout  ; EXIT ON Null char 
        CHK?RP  _glcdCh 
        MOVWF _glcdCh
        BANKSEL 0
        L?CALL _gcga  
        bra    GLCD_str_out        
    GLCD_exit_strout
        BANKSEL 0
        return    
    ELSE 
    GLCD_str_out
        IFDEF BSR
            MOVIW FSR1++	; Get a character
            BTFSC STATUS,Z
            BRA	GLCD_exit_strout  ; EXIT ON Null char 
        ELSE
            movf INDF, W	; Get a character
           BTFSC STATUS,Z
            GOTO	GLCD_exit_strout  ; EXIT ON Null char 
            INCF FSR,F 
        ENDIF
        CHK?RP  _glcdCh 
        MOVWF _glcdCh
        MOVE?BB FSR1L,_glcd_bigaddress
        MOVE?BB FSR1H,_glcd_bigaddress+1
        BANKSEL 0
        L?CALL _gcga 
        MOVE?BB _glcd_bigaddress,FSR1L
        MOVE?BB _glcd_bigaddress+1,FSR1H
        GOTO  GLCD_str_out      
    GLCD_exit_strout
        BANKSEL 0
        return     
     ENDIF 
    endasm
     
        glcd_bigaddress  VAR BYTE[3]
        glcdCh      var byte  'chr  DATA
        lcdData     VAR byte  'DATA
        glcdDC      VAR BYTE  'gca  var
        glcdFont    var word  'font address
        glcdOffset  VAR word  'font offset
        dsfbuff var byte[26]
        ctemp1 var word
        gl var byte
        glcdBc   var byte
        POSY        var byte  'gca  pg   address
        gy_         var byte  'gca  pg   address
        POSX        var byte  'gca  row  address
        gx_         var byte  'gca  row  address
        ctemp       var word
        glcdStrAddr var word ext
        bigtxt       var bit
        inverted      var bit
    @glcdStrAddr =   _glcd_bigaddress 
    
    
        
    GlcdUnpackStr:     
        readcode glcdStrAddr,CTEMP
        glcd_bigaddress[2]  = CTEMP&$7f
        ctemp=ctemp<<1
        glcdCh = CTEMP.HIGHBYTE 
        glcdStrAddr=glcdStrAddr+1
        if   glcdCh then 
            gosub gcga
            glcdCh =  glcd_bigaddress[2]
        else
            return
        endif
        if   glcdCh then 
          gosub gcga
        else
            return
        endif
        goto   GlcdUnpackStr:     
    return   
     
    lcd_init:
        @ GLetAddress _font7x5,_glcdFont
        bigtxt = 0
        inverted =0
        #ifdef use_mssp 
        SSP1CON1=$21  ;$22,21,20 all work @32mhz  20 is fastest 
        SSP1STAT=$40
        #endif
        LCD_CE=1 
        pause 30 
        Lcd_RST = 0         ' Reset LCD (HW reset)
        pause 1
        Lcd_RST = 1         ' Release Reset
    '    lcd_dc=0
        LCDCMD   $21        ' LCD EXTENDED COMMANDS
        LCDCMD   $c8        ' SET LCD Vop (CONTRAST) initial value $C8 = 200.
        LCDCMD   $06        ' SET TEMP COEFFICIENT
        LCDCMD   $13        ' LCD BIAS MODE
        LCDCMD   $20        ' LCD STANDARD COMMANDS
        LCDCMD   $08        ' LCD blank
        LCDCMD   $0c        ' LCD IN NORMAL MODE
    return 
        
    lcd_clr:    ' clear
          FOR  gy_ =0 TO 5          
              FOR GX_=0 TO 83
                 LCDDAT  0
              NEXT
          NEXT     
    return
    
    
    lcd_byte:  'send command sequence "glcdData "
    LCD_CE=0
    #ifdef use_mssp
        PIR1.3=0     
        SSP1BUF = LcdData 
        WHILE   !PIR1.3 :    wend 
    #else
        PAUSEUS 150
        SHiftOUT LCD_DIN,LCD_CLK,1,[LcdData]  
    #endif  
    LCD_CE=1 
    return 
    
    
    
    LCDxy:    ;set LCD XY  
       POSY = POSY MIN lcdheight 
       POSX = POSX MIN lcdwidth
       LCDCMD POSY|$40
       LCDCMD POSX|$80
    return
        
    
    
    gcga:      ;unpack font from flash and display it
        #ifdef PIC16
            glcdOffset = (glcdch-32)*5/2 + glcdFont  ; point to cga data
        #ELSE
            glcdOffset = (glcdch-32)*6 + glcdFont  ; point to cga data
        #ENDIF
       gosub LCDxy
    #ifdef PIC16
    '     ; COMMENT OUT THIS ASM SECTION IF CHIP HAS NO EEDAT REG
    '    ASM
    '    MOVE?CB high _dsfbuff, FSR1H ;load highbyte 
    '    MOVE?CB low  _dsfbuff, FSR1L ;load low byte
    '    MOVE?WW    _glcdOffset,EEADRL
    '    MOVE?CB    3,_glcdDC
    'nxtf   
    '    BANKSEL   EECON1 
    '    BSF EECON1, EEPGD ;Point to PROGRAM memory
    '    BSF EECON1, RD ;EE Read
    '    NOP
    '    NOP 
    '    RLF    EEDAT, W 
    '    RLF    EEDATH, W
    '    MOVE?AB  _glcdBc
    '    BANKSEL   EEDAT
    '    BCF    EEDAT,7
    '    MOVF   EEDAT,W
    '    MOVWI FSR1++
    '    MOVE?BA   _glcdBc
    '    MOVWI FSR1++
    '    BANKSEL   EEADRL
    '    incf    EEADRL,F      
    '    btfsc   STATUS,Z      
    '    incf    EEADRH,F 
    '    BANKSEL  _glcdDC
    '    DECFSZ  _glcdDC,F                ;dec count 
    '    GOTO    nxtf
    '    BANKSEL 0
    '    ENDASM
        ; UNCOMMENT IF CHIP HAS NO EEDAT REG
        glcdBc=0
        gosub getflash 
        if !glcdch.0 then 
            dsfbuff[glcdBc] = CTEMP.HIGHBYTE  
            glcdBc=glcdBc+1
        endif        
        dsfbuff[glcdBc] = glcdDC
        glcdBc=glcdBc+1     
        gosub getflash 
        dsfbuff[glcdBc] = CTEMP.HIGHBYTE 
        glcdBc=glcdBc+1
        dsfbuff[glcdBc] = glcdDC 
        glcdBc=glcdBc+1
        gosub getflash 
        dsfbuff[glcdBc] = CTEMP.HIGHBYTE   
        if glcdch.0 then  
            glcdBc=glcdBc+1
            dsfbuff[glcdBc] = glcdDC
        endif
        dsfbuff[5] =  0
    #else 
        for glcddc = 0 to 2
           dsfbuff[glcddc*2] = CTEMP
           dsfbuff[glcddc*2+1] = CTEMP.HIGHBYTE 
           glcdOffset     = glcdOffset + 2 
        NEXT
    #endif
       if inverted then
       for glcddc = 5 to 0 STEP -1
          dsfbuff[glcddc]=~dsfbuff[glcddc]
       next   
       endif
       if bigtxt then ;create a big chr from a small one
           DSFBUFF[24] = POSX
           DSFBUFF[25] = POSy
           for glcddc = 5 to 0 STEP -1
               ctemp = 0
               ctemp1 = 3
               gL = dsfbuff[glcddc]
               for glcdBc = 0 to 7
                   IF  GL & 1 THEN ctemp = ctemp|ctemp1
                   ctemp1 = ctemp1<<2
                   GL = GL>>1
               NEXT
               gL = glcddc*2
               dsfbuff[GL]   =ctemp.LOWBYTE
               dsfbuff[GL+1] =ctemp.LOWBYTE
               dsfbuff[GL+12]=ctemp.HIGHBYTE
               dsfbuff[GL+13]=ctemp.HIGHBYTE
           NEXT
           for   glcddc = 0 to 11
            LCDDAT   dsfbuff[GLCDDC]
           NEXT
           POSY=POSY+1
           POSX=DSFBUFF[24]
           gosub LCDxy
           for   glcddc = 12 to 23
            LCDDAT   dsfbuff[GLCDDC]
           NEXT
           POSx = POSX + 12 
           IF POSX > 72  THEN  POSX=0    ;wrap 
           posy=DSFBUFF[25]
       else
           for   glcddc = 0 to 5
            LCDDAT   dsfbuff[GLCDDC]
           NEXT
           POSx = POSX + 6      
           IF POSX > 78  THEN  POSX=0    ;wrap    
       endif
    RETURN 
    
    getflash:
            readcode glcdOffset,CTEMP
        glcdDC= CTEMP&$7f
        ctemp = ctemp << 1
         glcdOffset = glcdOffset + 1
         return
    overglcd :

    demo file
    Code:
     '****************************************************************
    '*  Name    : NOKIA_DEMO.PBP                                     *
    '*  Author  : richard                                            *
    '*  Notice  :                                                    *
    '*          :                                                    *
    '*  Date    : 16/5/2018                                          *
    '*  Version :  mssp1 version  with bigtxt  ,inverse txt          *
    '*  Notes   :  used mikes compressed packed 5 byte font          *
    '*          :FOR pic 16F1847@32MHZ           NOKIA               *
    '****************************************************************
    #CONFIG ; 16FF1847.
            __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _BOREN_OFF
            __config _CONFIG2, _PLLEN_OFF & _LVP_OFF
    #ENDCONFIG
    define      OSC         32
    
     
    ; --- *** Oscillator  *** ---------------------------------------------------
    OSCCON = %11110000           ;32 MHz, 
    ANSELb = 0
    ANSELA = 0
    TRISA=%10010000
    TRISB=%11101011
     
    
     ;DEFINES FOR DISPLAY   use   font7x5_16.bas   or  font7x5_18.bas     for pic18
     #DEFINE PIC16 1            
     #define use_mssp 1
     lcdheight con 5      ;  6 PAGES   
     lcdwidth  con 83     ; 84 PIXELS WIDE
    ' LCD_CLK     var     LATB.4       ' SCK1     pin needs to be set as dig o/p
    ' LCD_DIN     var     LATB.2       ' SDO1     pin needs to be set as dig o/p
     LCD_RST     var     LATA.4 
     LCD_DC      var     LATA.3
     LCD_CE      var     LATA.6
     LCD_LIGHT   var     LATA.0
     
    
     
    BUFF VAR BYTE [16]
    char  VAR BYTE
    Include "nokia_ds5.inc"  ' bring it in
    include "font7x5_16_5.bas"
    
    '==========================    MAIN  Routine    ==============================  
        gosub lcd_init
        LCDCLR
        ARRAYWRITE BUFF,["READY",0]
         inverted=1
        LCDSTR  5,2,BUFF 
        PAUSE 1000
        LCDCLR
        inverted=0
        bigtxt = 1
        LCDSTR  5,2,BUFF 
        PAUSE 1000
        LCDCLR
        
        bigtxt = 0
        posx=0
        posy=0
        gosub LCDxy
        char=32
    looper:
        lcdc char
        while posx
        char=char+1
        if char>127 then char=32
        lcdc char
        PAUSE 100
        wend
        posy=posy+1
        if posy>5 then 
        posy=0 
        gosub LCDxy
        PAUSE 1000
        endif 
         
    GOTO LOOPER   
     
    '
    
    END

    font
    Code:
    '****************************************************************
    '*  Name    : font7x5_16_5.BAS                                  *
    '*  Author  : mike                                              *
    '*  Notice  :                                                   *
    '*          :                                                   *
    '*  Date    :                                                   *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    goto overfont
    font7x5:     ;14BIT   PACKED FORMAT   [2X7BITS]     CHR32-126 [SP TO ~ ]
    asm
         dw 0x0000, 0x0000, 0x0000, 0x005F, 0x0000     ;  32 ' '  '!'
         dw 0x0007, 0x0007, 0x0014, 0x3F94, 0x3F94     ;  34 '"'  '#'
         dw 0x122A, 0x3FAA, 0x0923, 0x0988, 0x3262     ;  36 '$'  '%'
         dw 0x1B49, 0x2AA2, 0x2800, 0x0283, 0x0000     ;  38 '&'  '''
         dw 0x001C, 0x1141, 0x0000, 0x20A2, 0x0E00     ;  40 '('  ')'
         dw 0x0A08, 0x1F08, 0x0A08, 0x043E, 0x0408     ;  42 '*'  '+'
         dw 0x0050, 0x1800, 0x0008, 0x0408, 0x0408     ;  44 ','  '-'
         dw 0x0060, 0x3000, 0x0020, 0x0808, 0x0202     ;  46 '.'  '/'
         dw 0x1F51, 0x24C5, 0x1F00, 0x217F, 0x2000     ;  48 '0'  '1'
         dw 0x2161, 0x28C9, 0x2321, 0x20C5, 0x25B1     ;  50 '2'  '3'
         dw 0x0C14, 0x097F, 0x0827, 0x22C5, 0x22B9     ;  52 '4'  '5'
         dw 0x1E4A, 0x24C9, 0x1801, 0x3889, 0x0283     ;  54 '6'  '7'
         dw 0x1B49, 0x24C9, 0x1B06, 0x24C9, 0x149E     ;  56 '8'  '9'
         dw 0x0036, 0x1B00, 0x0000, 0x2B36, 0x0000     ;  58 ':'  ';'
         dw 0x0414, 0x1141, 0x0014, 0x0A14, 0x0A14     ;  60 '<'  '='
         dw 0x0041, 0x1114, 0x0402, 0x00D1, 0x0486     ;  62 '>'  '?'
         dw 0x1949, 0x3CC1, 0x1F7E, 0x0891, 0x08FE     ;  64 '@'  'A'
         dw 0x3FC9, 0x24C9, 0x1B3E, 0x20C1, 0x20A2     ;  66 'B'  'C'
         dw 0x3FC1, 0x20A2, 0x0E7F, 0x24C9, 0x24C1     ;  68 'D'  'E'
         dw 0x3F89, 0x0489, 0x00BE, 0x20C9, 0x24FA     ;  70 'F'  'G'
         dw 0x3F88, 0x0408, 0x3F80, 0x20FF, 0x2080     ;  72 'H'  'I'
         dw 0x1040, 0x20BF, 0x00FF, 0x0414, 0x1141     ;  74 'J'  'K'
         dw 0x3FC0, 0x2040, 0x207F, 0x010C, 0x017F     ;  76 'L'  'M'
         dw 0x3F84, 0x0410, 0x3FBE, 0x20C1, 0x20BE     ;  78 'N'  'O'
         dw 0x3F89, 0x0489, 0x033E, 0x20D1, 0x10DE     ;  80 'P'  'Q'
         dw 0x3F89, 0x0CA9, 0x2346, 0x24C9, 0x24B1     ;  82 'R'  'S'
         dw 0x0081, 0x3F81, 0x00BF, 0x2040, 0x203F     ;  84 'T'  'U'
         dw 0x0FA0, 0x2020, 0x0FBF, 0x2038, 0x203F     ;  86 'V'  'W'
         dw 0x3194, 0x0414, 0x3187, 0x0470, 0x0407     ;  88 'X'  'Y'
         dw 0x30D1, 0x24C5, 0x2180, 0x3FC1, 0x2080     ;  90 'Z'  '['
         dw 0x0104, 0x0410, 0x1000, 0x20C1, 0x3F80     ;  92 '\'  ']'
         dw 0x0202, 0x0082, 0x0240, 0x2040, 0x2040     ;  94 '^'  '_'
         dw 0x0001, 0x0104, 0x0020, 0x2A54, 0x2A78     ;  96 '`'  'a'
         dw 0x3FC8, 0x2244, 0x1C38, 0x2244, 0x2220     ;  98 'b'  'c'
         dw 0x1C44, 0x2248, 0x3FB8, 0x2A54, 0x2A18     ; 100 'd'  'e'
         dw 0x047E, 0x0481, 0x010C, 0x2952, 0x293E     ; 102 'f'  'g'
         dw 0x3F88, 0x0204, 0x3C00, 0x227D, 0x2000     ; 104 'h'  'i'
         dw 0x1040, 0x223D, 0x007F, 0x0828, 0x2200     ; 106 'j'  'k'
         dw 0x0041, 0x3FC0, 0x007C, 0x0218, 0x0278     ; 108 'l'  'm'
         dw 0x3E08, 0x0204, 0x3C38, 0x2244, 0x2238     ; 110 'n'  'o'
         dw 0x3E14, 0x0A14, 0x0408, 0x0A14, 0x0C7C     ; 112 'p'  'q'
         dw 0x3E08, 0x0204, 0x0448, 0x2A54, 0x2A20     ; 114 'r'  's'
         dw 0x023F, 0x2240, 0x103C, 0x2040, 0x107C     ; 116 't'  'u'
         dw 0x0E20, 0x2020, 0x0E3C, 0x2030, 0x203C     ; 118 'v'  'w'
         dw 0x2228, 0x0828, 0x220C, 0x2850, 0x283C     ; 120 'x'  'y'
         dw 0x2264, 0x2A4C, 0x2200, 0x0436, 0x2080     ; 122 'z'  '{'
         dw 0x0000, 0x3F80, 0x0000, 0x20B6, 0x0400     ; 124 '|'  '}'
         dw 0x0808, 0x0410, 0x0478, 0x2341, 0x2378     ; 126 '~'  ''
     endasm    
    overfont:
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    Quote Originally Posted by richard View Post
    I think I prefer my take on this ...
    A great example. Thank you.

    Quote Originally Posted by richard
    tried a pbp version for the 5 byte compressed packed font, the unpacking done without asm
    takes more code space than the compressing saves ...
    That's a shame but it was worth a try.

    Thank you very much for the pointers and help. It's been a fun experiment and I've learned a lot.

    Cheerful regards, Mike

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    Thank you very much for the pointers and help. It's been a fun experiment and I've learned a lot.
    ditto
    and I finally figured out what I was doing wrong with asm psect labels
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    whats next
    a ttf
    a double size font for digits (0 to 9 +- : )
    Warning I'm not a teacher

  7. #7
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    Hi Richard,

    Thanks for the fix on the single char problem, it works well but I've found another problem...

    When I add DT Ints the big characters don't work, I tried with and without using mssp but same result.

    Also there's something strange taking place with the led backlight insomuch as I need to sprinkle port pin enable code immediately following any lcd write (with or without DT Ints). I tried changing LCD_LIGHT from A.0 to A.1 (while leaving it connected to A.0) with no difference - does the Inc file employ any commands for the light?

    Here's the edited code:

    Code:
    #CONFIG ; 16F1847.
            __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _BOREN_OFF
            __config _CONFIG2, _PLLEN_OFF & _LVP_OFF
    #ENDCONFIG
    
    @ ERRORLEVEL -306   ; turn off crossing page boundary message
     
    ; --- *** Oscillator  *** ---------------------------------------------------
    define      OSC         32
    OSCCON = %11110000   ; 32 MHz, 
    ANSELA = 0           ; all digital          
    ANSELB = 0           ; all digital 
    TRISA=%00000000
    'TRISB=%00000000
    TRISB=%11101011           ; Encoder inputs on B5-7
    
    ch var byte
    BUFF VAR BYTE [10]
    
     ;DEFINES FOR DISPLAY   use   font7x5_16.bas   or  font7x5_18.bas     for pic18
     #DEFINE PIC16 1            
     #define use_mssp 1   ; much faster and less words (1027 vs 1106).
     lcdheight con 5      ;  6 PAGES   
     lcdwidth  con 83     ; 84 PIXELS WIDE
     LCD_RST     var     LATA.4 
     LCD_DC      var     LATA.3
     LCD_CE      var     LATA.6
     LCD_LIGHT   var     LATA.0 
     LCD_CLK     var     LATB.4       ' SCK1     pin needs to be set as dig o/p
     LCD_DIN     var     LATB.2       ' SDO1     pin needs to be set as dig o/p
     ;--------------ONLY IF MSSP NOT USED---------------
    ' LCD_CLK  var     Portb.4       ' Clock
    ' LCD_DIN  var     Portb.2       ' Data
     
    Include "Modedefs.bas"
    INCLUDE "DT_INTS-14.bas"    ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"    ' Include if using PBP type interrupts
    Include "nokia_ds.INC"      ' bring it in
    include "font7x5_16.bas"
    'include "font7x5_16 edit degC.BAS"  ; use @ to access degC symbol.
    
    ASM
    INT_LIST  macro    ; IntSource,         Label,  Type, ResetFlag?
            INT_Handler    IOC_INT,  _Rot_Encoder,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @    INT_ENABLE   IOC_INT     ; Port Change Interrupt
    
    '==========================    MAIN  Routine    ==============================
        gosub lcd_init
        LCDCLR
        ARRAYWRITE BUFF,["READY",0]
        LCDSTR 5,0,BUFF 
        PortA.0 = 0    ' turn on backlight.
        PAUSE 1000
        LCDCLR
        PAUSE 1000  
    looper:
        LCDCLR
        PortA.0 = 0    ' turn on backlight.
        bigtxt = 1     ; double size chrs
        LCDSTR 0,0,"Noki+12"
        LCDSTR 0,2,"345678@" 
        bigtxt = 0     ; normal size chrs
    '    LCDSTR 52,3,"Demo"
    '    LCDSTR 0,4,"With@MSSP xfer" 
        LCDSTR 0,4,"Hi" 
        PortA.0 = 0    ' turn on backlight.
    '    LCDSTR 0,5,"Dble Size Chrs"     
    '    LCDSTR 0,5," "  ; this doesn't compile - causes errors and warnings wherever used.     
        LCDC 0,5,"a"    ; use LCDC for single chars.
        PortA.0 = 0    ' turn on backlight.
        PAUSE 1000       
        GOTO looper
    
    Rot_Encoder:
    '    if PortB.7 = 0 then        ' Check if Encoder pushbutton was pushed.
    '    ButtPush = 1               ' Set the flag for a quick exit.
    '    Old_Bits = New_Bits        ' Equalize the disturbance the pushbutton caused.
    @ INT_RETURN                   ; Exit accordingly.
    '    endif
    
    END
    Is the Inc file compatible with DT Ints?

    Regards,
    Bill

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    works perfectly if done correctly the include's order may matter, ioc int needs to configured
    if your programmer is still connected to portb.7 that can load things up a bit [I leave mine connected and avoid using b6,b7 pins]
    never use portx.x to set or clear pins , its just asking for rmw problems especially with fast fosc settings
    always use latx.x when available or use a shadow register



    Code:
    #CONFIG ; 16F1847.
            __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _BOREN_OFF
            __config _CONFIG2, _PLLEN_OFF & _LVP_OFF
    #ENDCONFIG
    @ ERRORLEVEL -306   ; turn off crossing page boundary message
     
    ; --- *** Oscillator  *** ---------------------------------------------------
    define      OSC         32
    OSCCON = %11110000   ; 32 MHz, 
    ANSELA = 0           ; all digital          
    ANSELB = 0           ; all digital 
    TRISA=%10010000
    'TRISB=%00000000
    TRISB=%11101011           ; Encoder inputs on B5-3
    IOCBN = %00101000          ;enable ioc falling edge b3,b5
    ch var byte
    BUFF VAR BYTE [10]
     ;DEFINES FOR DISPLAY   use   font7x5_16.bas   or  font7x5_18.bas     for pic18
     #DEFINE PIC16 1            
     #define use_mssp 1   ; much faster and less words (1027 vs 1106).
     lcdheight con 5      ;  6 PAGES   
     lcdwidth  con 83     ; 84 PIXELS WIDE
     LCD_RST     var     LATA.4 
     LCD_DC      var     LATA.3
     LCD_CE      var     LATA.6
     LCD_LIGHT   var     LATA.0 
     ;LCD_CLK     var     LATB.4       ' SCK1     pin needs to be set as dig o/p
     ;LCD_DIN     var     LATB.2       ' SDO1     pin needs to be set as dig o/p
     ;--------------ONLY IF MSSP NOT USED---------------
    '
    Include "nokia_ds.INC"      ' bring it in
    include "font7x5_16.bas" 
    INCLUDE "DT_INTS-14.bas"    ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"    ' Include if using PBP type interrupts
    '
    ASM
    INT_LIST  macro    ; IntSource,         Label,  Type, ResetFlag?
            INT_Handler    IOC_INT,  _Rot_Encoder,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    @    INT_ENABLE   IOC_INT     ; Port Change Interrupt
    '==========================    MAIN  Routine    ==============================
        gosub lcd_init
        LCDCLR
        ARRAYWRITE BUFF,["READY",0]
        LCDSTR 5,0,BUFF 
        LCD_LIGHT  = 0    ' turn on backlight.
        PAUSE 1000
        LCDCLR
        PAUSE 1000  
    looper:
        LCDCLR
        
        bigtxt = 1     ; double size chrs
        LCDSTR 0,0,"Noki+12"
        LCDSTR 0,2,"345678@" 
        bigtxt = 0     ; normal size chrs
    '    LCDSTR 52,3,"Demo"
    '    LCDSTR 0,4,"With@MSSP xfer" 
        LCDSTR 0,4,"Hi" 
       
    '    LCDSTR 0,5,"Dble Size Chrs"     
    '    LCDSTR 0,5," "  ; this doesn't compile - causes errors and warnings wherever used.     
        LCDC 0,5,"a"    ; use LCDC for single chars.
        
        PAUSE 1000       
        GOTO looper
    Rot_Encoder:
       if IOCBF.3 then    LCD_LIGHT  = 0     ' Check if button was pushed.
       if IOCBF.5 then    LCD_LIGHT  = 1
       IOCBF=0 
    @ INT_RETURN                   ; Exit accordingly.
    '    endif
    END
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    include order does not seem to matter [as I hoped]
    INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas" ' Include if using PBP type interrupts
    Include "nokia_ds.INC" ' bring it in
    include "font7x5_16.bas"
    works fine
    Warning I'm not a teacher

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. 16F946 pcb footprint (64 tqfp)
    By nomad in forum Schematics
    Replies: 2
    Last Post: - 8th September 2009, 11:14
  3. small 2X16 LCD
    By Ron Marcus in forum Off Topic
    Replies: 2
    Last Post: - 26th October 2007, 20:37
  4. Nokia 3310 LCD
    By barkerben in forum General
    Replies: 3
    Last Post: - 10th December 2005, 19:08
  5. Small LCD module,character
    By Ron Marcus in forum Off Topic
    Replies: 6
    Last Post: - 27th November 2005, 18:13

Members who have read this thread : 3

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