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


    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

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


    Did you find this post helpful? Yes | No

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

    a version with fonts of user defined size

    this has a 14x10 font for two char 0,1 ie 2 rows 10 columns


    fonts now have a header added to define rows/columns first chr and last chr

    eg


    Code:
    #asm
    psect FONT_table,class=CODE,local,delta=2
      GLOBAL _FNT
    _FNT
            DW 0X0501, 0X207F  //1 ROW 5 COL CHR 32-127
            DW 0x0000, 0x0000, 0x0000, 0x005F, 0x0000 //  32 ' '  '!'
            DW 0x0007, 0x0007, 0x0014, 0x3F94, 0x3F94 //  34 '"'  '#'
            DW 0x122A, 0x3FAA, 0x0923, 0x0988, 0x3262 //  36 '$'  '%'
           ...............................

    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 *);
    void set_fnt(const char *);
    extern const char FNT,NUM;
    uint16_t fnt_addr;
    char fnt_row,fnt_col,fnt_fc,fnt_lc,POSX,POSY;
    void main(void) {
        // initialize the device
        SYSTEM_Initialize();
        set_fnt(&FNT);
        
        /*                                                                   *
         *  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
        POSX=32;
        POSY=2;
        WrChar('R'); // write ascii character
        WrStr("eady");
        
        set_fnt(&NUM);
        putcmd(0x80 + 0x10); // set DDRAM X address, 0..83
        putcmd(0x40 + 0x04); // set DDRAM Y address, 0..5
        POSX=16;
        POSY=5;
        WrChar('0'); // write ascii character
        WrChar('1'); // write ascii character
        
        while (1) {
        }
    }
    /**
     End of File
     */
    void set_fnt(const char *F){
        uint16_t tmp;
        fnt_addr=(uint16_t)F&0x1fff;
        tmp=FLASH_ReadWord(fnt_addr++);
        fnt_row = (char)tmp;
        fnt_col = tmp>>8;
        tmp=FLASH_ReadWord(fnt_addr++);
        fnt_lc = (char)tmp;
        fnt_fc = tmp>>8;
    }
    
    void putwreg(char work) // send byte, msb first (15 words)
    {
        LCD_CE_LAT = 0; // spi enable on
        SPI1_Exchange8bit(work);
        LCD_CE_LAT = 1; // spi enable off
    } //
    void WrChar(char d) { // for packed 2.5 word 5x7 font
        uint16_t tmp, inx = fnt_addr;
        char fd[32], i = fnt_row, j = 0, k, *pt;
        if ((d < fnt_fc) || (d > fnt_lc))return;
        inx += ((d - fnt_fc) * fnt_col*fnt_row) >> 1;
        while (i--) {
            k = fnt_col >> 1;
            if (k == 2)k++;
            while (k--) {
                tmp = FLASH_ReadWord(inx++);
                if (!i)
                    fd[j + 1] = ((char)tmp & 0x7f) ;//<< 1
                else
                    fd[j + 1] = ((tmp & 0x7f)<<1)&0xfe;
                tmp <<= 1;
                if (!i)
                    fd[j] = (tmp >> 8)& 0x7f;
                else
                    fd[j] = (tmp >> 7)& 0xfe;;
                j += 2;
                
            }
        }
        pt = fd;
        if ((d & 1)&&(fnt_col == 5))pt++;
        i = fnt_row;
        while (i--) {
            k = fnt_col;
            putcmd(0x40 +POSY-i);
            if(!i){
                 putcmd(0x80 +POSX);
                 
            }
            // with font now stored in bufer fd its easy to have large and/or inverted text
            while (k--) {
                putwreg(*pt++);
            }
            putwreg(0);
        }
        
        POSX+=fnt_col+1;
    }
    void putcmd(char x) {
        LCD_DC_SetLow();
        putwreg(x);
        LCD_DC_SetHigh();
    }
    void WrStr(const char *buff) {
        { //
            while (*buff)
                WrChar(*buff++); //
        }
    }
    #asm
    psect nums_table,class=CODE,local,delta=2
    _NUM
            DW 0X0A02, 0X3031  //2 ROW 10 COL CHR 0,1
            DW 15998, 899 ,8691, 15775 ,16252     // chr 0x30 " 0 "
            DW 4031, 15486, 14307, 12400, 8095
            DW 0, 518, 16383, 0, 0                         // chr 0x31 " 1 "
            DW 64 ,8288 ,16383 ,12352, 8192
    Last edited by richard; - 28th May 2018 at 05:52.
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

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

    IT needed a tweak to work for a 18f26k22
    Attached Files Attached Files
    Warning I'm not a teacher

  4. #4
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    Richard thanks,

    tested and confirmed that is working.

    I have tested only the small font 7x5_18 as text.

    I'm trying to figure out how to display a variable.

  5. #5
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

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

    tested with big fonts as well.

    it is really easy to use it like that.

    Richard is there a way to print variables other than text?

Similar Threads

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

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