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

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

    Entire demo is 872 words ,its less than 1/3 size of other attempts and has same features and a full alpha-numeric font
    Attached Files Attached Files
    This is more entertaining than Free to Air TV

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,691

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

    Amazing work Richard.

    5*

    Ioannis

  3. #3
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    68

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

    Well done Richard, Ioannis almost got it right - put a star up against your name and let's call it 6*.

    Regards,
    Bill

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

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

    I agree... nicely done, Richard. I can't tell you how much I enjoy studying and learning from your code.

    I was inspired by how you compressed a 96 character 5x7 font table down to something like 288 words and I spent most of the day implementing something similar on an old 5110 demo program written in C for a 16F1823. With just basic INIT, CMD, DAT, and STR functions, the program now uses less than 500 words of program memory. I'm pretty geeked about it! Thank you...

    Take care. Have fun. Cheerful regards, Mike
    Last edited by Mike, K8LH; - 18th May 2018 at 09:41.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    1,342

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

    if you really want to geek it up


    changing the output routine to use the mssp module shaves another 10% off the code size
    and speeds the thing up by a factor of 10x

    din and clk need to be on sdo and sck

    this

    PAUSEUS 150
    SHiftOUT LCD_DIN,LCD_CLK,1,[LcdData]

    becomes

    PIR1.3=0
    SSP1BUF = LcdData
    WHILE !PIR1.3 : wend


    and this is added to init routine

    SSP1CON1=$21 ;$22,21,20 all work @32mhz 20 is fastest
    SSP1STAT=$40
    Last edited by richard; - 18th May 2018 at 09:52.
    This is more entertaining than Free to Air TV

  6. #6
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    192

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

    Yes, I already thought about using the SPI module. The current bit-bang driver uses 14 words of memory and runs at ~190-kb/s (with 8-MHz clock). An SPI driver and its init code shouldn't be any bigger. I hope to work on an SPI driver later today. I just need to refresh my memory on the SPI modes. Looks like you're using CKE = 1 and CKP = 0, yes?

    Name:  spi modes.png
Views: 64
Size:  156.5 KB

    Implementing the 'packed' font table and extracting data was surprisingly simple, though I'm coding pretty close to the metal and the results are nothing as agile or elegant as your use of the 'readcode' function. Here's an excerpt, if you're interested;

    Code:
      /********************************************************************
       *                                                                  *
       ********************************************************************/
       void RdFlash()               // bank 3 (inserted by compiler)
       { asm bcf     _eecon1,CFGS   // not 'config' memory            |03
         asm bsf     _eecon1,EEPGD  // select 'program' memory        |03
         asm bsf     _eecon1,RD     // initiate read operation        |03
         asm nop                    // required nop                   |03
         asm nop                    //  "                             |03
         asm incf    _eeadrl,F      // bump EEADR                     |03
         asm btfsc   _status,Z      //  "                             |03
         asm incf    _eeadrh,F      //  "                             |03
         asm rlf     _eedatl,W      // move b7 into Carry             |03
         asm rlf     _eedath,W      // wreg = the 7 bit hi byte       |03
         asm bcf     _eedatl,7      // eedatl = the 7 bit lo byte     |03
       }                            //
    
      /********************************************************************
       *                                                                  *
       ********************************************************************/
       void WrChar(char ascii)      // WrChar() for packed 5x7 font
       { asm movf    _ascii,W       // ascii char value, 32..127      |00
         asm addlw   -32            // minus table offset             |00
         asm movwf   _ascii         // font array index, 0..95        |00
     /*                                                                   *
      *  multiply index by 3 (0..95 -> 0..285), add table base address,   *
      *  and stuff the result in the EEADR register pair.                 *
      *                                                                   */
         asm lslf    _wreg,W        // wreg = (ascii-32)*2            |00
         asm addwf   _ascii,W       // wreg = (ascii-32)*3            |00
      // asm movlb   3              // bank 3 (inserted by compiler)  |03
         asm movwf   _eeadrl        // flash address lo               |03
         asm movlw   1024/256       // table address hi               |03
         asm btfsc   _status,C      // overflow? no, skip, else       |03
         asm addlw   1              // bump value                     |03
         asm movwf   _eeadrh        // flash address hi               |03
     /*                                                                   *
      *  read 3 words (6 bytes) of font pattern data from the 5x7 font    *
      *  array and write them to the Nokia 5110 LCD.                      *
      *                                                                   */
         for(char i=0; i<3; i++)    // 
         { RdFlash();               // read one word (2 bytes)
           putlcd(wreg);            // send hi byte
           putlcd(eedatl);          // send lo byte
         }                          //
       }                            //
    
      /********************************************************************
       *                                                                  *
       ********************************************************************/
       void WrChar(rom char *data)  // overload function for strings
       { char ndx = 0;              //
         while(data[ndx++])         // while not end-of-string
           WrChar(wreg);            //
       }                            //
    Code:
     /*                                                                   *
      *  initialize Nokia 5110 LCD display                                *
      *                                                                   */
         delay_ms(30);              //
         rst = 0;                   // 5110 'reset' pulse
         rst = 1;                   //
         dc = 0;                    // command mode
         putlcd(0x20+0x01);         // function set: extended instructions
         putlcd(0x80+0x30);         // set Vop (contrast), 0..127
         putlcd(0x04+0x02);         // set temperature coefficient, 0..3
         putlcd(0x10+0x03);         // Set bias system, 0..7
         putlcd(0x20+0x00);         // function set: standard instructions
         putlcd(0x08+0x04);         // display control: normal mode
    
         putlcd(0x80+0x20);         // set DDRAM X address, 0..83
         putlcd(0x40+0x02);         // set DDRAM Y address, 0..5
         dc = 1;                    // data mode
         WrChar("Hello");           // test string overload function
    Thank you again for sharing your work. Mike
    Last edited by Mike, K8LH; - 18th May 2018 at 15:49. Reason: additional code excerpt

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

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

    Hi Richard,

    Just taking a quick look at your Include demo and I can only write 13 characters per line successfully... if 14 then the result is a wrap around and overwriting of the first char. Example below:


    Code:
    looper:
        LCDCLR
    ;    LCDSTR  6,0,"-Nokia-Demo-"      ; Line 0, position 6. 
        LCDSTR  0,0,"I wonder what happens if the string is large?"  ; = Rubbish on first line and "missing quote" error message. 
    ;    LCDSTR  0,0,"I wonder what?"    ; = "? wonder what" [14 chars]
        LCDSTR  0,0,"I wonder what"     ; = "I wonder what" [13 chars only]
        LCDC   0,4,"'"                  ; Line 4, position 0.
        LCDC   25,5,"8"                ; Line 5, position 25.
        PAUSE 1000
        GOTO looper
    I'll test more later today and let you know if I find anything else needing a tweak. Again, great job.

    Regards,
    Bill

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    1,342

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

    yes probably, but here is a new version with double size chr capability and mssp and font unpacking in asm [like in my ks0108 code]

    its not been texted on a pic18 , but its blisteringly fast on the 16f1847, and will fill screen fully

    thanks go to blll [wjsmarine] for donation of hardware for this project, enjoy
    Attached Files Attached Files

  9. #9
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    68

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

    That's impressive, Richard.

    Can you explain how your font table works and how you derived those values in each column please? What limits the size of the table one can create?

    I'd like to learn from it and maybe if I can get my head around the process find a way to smooth out the double size characters (particularly 0-9, the degree symbol and C) - I'm guessing you are working your magic to achieve double size by math so it probably means making a larger table to accommodate these.

    An indication of smooth characters is shown in the pic attached, made with the previous lookup table style, which consumed 4 normal sized chars' area per big one and 2 lines (as does yours) and also noting the degree C was formed as one big character. Apologies for the blurry image, not helped with the scratchy plastic over the LCD to protect the glass...

    Thanks for your patience and help.

    Regards,
    Bill
    Attached Images Attached Images  

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    1,342

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

    I replace the _ chr with @ dw 642 , 9266 ,72 in my fonts to get a deg C chr
    achieve double size by math so it probably means making a larger table to accommodate these
    correct , I know of no realistic way to smooth the result , it has been tried.
    table size is only limited by the memory available.
    if you create a large font say 14x10 for digits it would not be an unreasonable size, but would need its own routines to unpack and display
    if you plot my font on graph paper its pretty obvious how it works, the pic 18 version is easier to disassemble
    Attached Files Attached Files

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    1,342

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

    some 8x8 graphpaper
    AND an old spread sheet that did the number crunching
    Attached Images Attached Images  
    Attached Files Attached Files
    This is more entertaining than Free to Air TV

  12. #12
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    192

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

    I used a spreadsheet to convert my old 5 byte per character tables, too. Works a treat...

    Cheerful regards, Mike

    Name:  5x7 Font Packer-Editor-Viewer.png
Views: 41
Size:  42.9 KB
    Last edited by Mike, K8LH; - 19th May 2018 at 21:39.

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    1,342

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

    I came up with the same solution , the freely available font creators [like the mikronta one] don't really
    convert the font to the most efficient format for pic's when codespace is an issue.
    although they can be a good starting point
    This is more entertaining than Free to Air TV

  14. #14
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    192

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

    Nice job on the spreadsheet, Richard. I just finished modifying mine to format the packed font table output for either C or asm. Here's a sample;

    Code:
    	0x0000,	0x0000,	0x0000,	//  32	 ' '
    	0x0000,	0x2F80,	0x0000,	//  33	 '!'
    	0x0007,	0x0007,	0x0000,	//  34	 '"'
    	0x0A7F,	0x0A7F,	0x0A00,	//  35	 '#'
    	0x122A,	0x3FAA,	0x0900,	//  36	 '$'
    	0x1193,	0x0464,	0x3100,	//  37	 '%'
    	0x1B49,	0x2AA2,	0x2800,	//  38	 '&'
    	0x0005,	0x0180,	0x0000,	//  39	 '''
    	0x001C,	0x1141,	0x0000,	//  40	 '('
    	0x0041,	0x111C,	0x0000,	//  41	 ')'
    	0x0A08,	0x1F08,	0x0A00,	//  42	 '*'
    	0x0408,	0x1F08,	0x0400,	//  43	 '+'
    Code:
         dw	0x0000,	0x0000,	0x0000	;  32	 ' '
         dw	0x0000,	0x2F80,	0x0000	;  33	 '!'
         dw	0x0007,	0x0007,	0x0000	;  34	 '"'
         dw	0x0A7F,	0x0A7F,	0x0A00	;  35	 '#'
         dw	0x122A,	0x3FAA,	0x0900	;  36	 '$'
         dw	0x1193,	0x0464,	0x3100	;  37	 '%'
         dw	0x1B49,	0x2AA2,	0x2800	;  38	 '&'
         dw	0x0005,	0x0180,	0x0000	;  39	 '''
         dw	0x001C,	0x1141,	0x0000	;  40	 '('
         dw	0x0041,	0x111C,	0x0000	;  41	 ')'
         dw	0x0A08,	0x1F08,	0x0A00	;  42	 '*'
         dw	0x0408,	0x1F08,	0x0400	;  43	 '+'
    I also decided to render all 96 characters directly from the input table so that I can see at-a-glance which characters might need tweaking...

    Name:  5x7 Font Packer #2.png
Views: 37
Size:  67.7 KB

  15. #15
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    192

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

    Just finished the font render part of my spreadsheet. It renders directly from the unpacked 5-byte 'input' table. Change a byte in there and you'll see the changes immediately. Mind if I show it off, guys (see below)?

    Cheerful regards, Mike, K8LH
    Name:  Font 5x7 #1 50%.png
Views: 32
Size:  223.2 KB
    Last edited by Mike, K8LH; - 20th May 2018 at 20:03.

  16. #16
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    192

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

    Richard... Would you be interested in seeing my driver code for font tables with 2.5 word-per-character packing instead of 3 word-per-character packing? The new '2.5' font tables use 240 words of memory (down from 288 words) and my little single file ~225 line (non-PBP) demo program now weighs in at ~406 words total memory...

    Cheerful regards, Mike
    Last edited by Mike, K8LH; Today at 09:35.

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 : 19

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