• AVR Freaks

Hot!Anyone done scalable fonts on the PIC 16 bits?

Author
LdB_ECM
Senior Member
  • Total Posts : 148
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
2019/06/25 05:40:49 (permalink)
0

Anyone done scalable fonts on the PIC 16 bits?

I got excited by $6.00 ILI9341 320x240 colour screens and made a board connecting it to a 24FJ256GA705. Works beautifully but you forget how big a 320x240 will require screen fonts like between 32 and 80 pixels. You don't get to carry too many bitmap fonts at that size before running out of space.
 
I wrote a windows program to convert and squeeze a TTF into signed 12bit X,Y and 8 bit flags for each glyph vertex (so 32bits) and I can just get one of the simple helvetica TTF fonts to fit.  I really wanted 3 .. I know a big ask :-)
 
So before I launched into the work to write the renderer I thought it is one of those things someone might have already done ... and done better.
#1

13 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 17846
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 06:13:12 (permalink)
    +1 (1)
    You can store graphics in an external EEPROM. Or use a bigger PIC.
    #2
    du00000001
    Just Some Member
    • Total Posts : 3065
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 07:19:05 (permalink)
    +1 (1)
    Start with . . . forget about TTF fonts - using raster fonts! (way more efficient to handle)
    And "QVGA" is a synomym for CGA - no more than 40 (h) x 25 (v) characters on screen. Makes a matrix of 8 x 10 - 10 Bytes per character. 1550 Bytes for a complete character set.
    You really want larger characters ?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 17846
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 07:38:59 (permalink)
    +2 (2)
    Also note you do not need to include the full Font set if you do not need all the chars.
    #4
    LdB_ECM
    Senior Member
    • Total Posts : 148
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 08:46:25 (permalink)
    0
    No it is a graphics screen if I wanted an oversize Character LCD screen I would have connected one Smile: Smile
    Ultimately I will connect external storage I just didn't think to do it when I designed the board as this was for a low cost market.
     
    Raster fonts are not a viable option the shuffling of the huge files from the external storage thru the pic then out to the screen will get ridiculous. Unless the PIC can DMA between the two SPI buses which I have not seen or heard of that idea is dead in the water. Am I right in that the PIC SPI bus is limited to just over 4Mhz which I am running the screen can do 25Mhz.
     
    I tried bzt's scalable-font code as he has done an integer bezier spline render already and it works ok
    https://gitlab.com/bztsrc/scalable-font/
    It is setup for 32 bit ints which I had to fix it has lots of macros which are expecting integer cast to 32 bits
    spot the problem with things like these on XC16

    # define _ssfn_i2g(x) ((x)? (((x) << 16) - (1 << 15)) / ctx->m : 0)
    # define _ssfn_g2o(x) (((x) * ctx->m + (1 << 7)) >> 8)
    # define _ssfn_g2i(x) (((x) * ctx->m + (1 << 15)) >> 16)
    # define _ssfn_g2ic(x) (((x) * ctx->m + (1 << 16) - 1) >> 16)
    # define _ssfn_f2i(x) ((((x) << s) * ctx->m + (1 << 15)) >> 16)

    [/code]Supporting the compressed fonts is not a option and uncompressed the SFN fonts are bigger than my TTF conversion.
     
    I also ran across a blast from the pass the old Borland BGI scalable font they work but are just stroke fonts you have to change line widths which is semi OK.
     
    So yeah if anyone knows a scalable font and/or renderer kick the link.
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 17846
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 09:21:22 (permalink)
    0
    Another Option is a PIC with more Memory.
    you heard or read in the Doc 4 Mhz?  It looks like you can go up to the Peripheral Bus speed.  Unless you found something else in the Data sheet.
    #6
    du00000001
    Just Some Member
    • Total Posts : 3065
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 09:39:54 (permalink)
    +1 (1)
    OK - the PIC24FJ256GA705 is not exactly the fastest of all 16-Bit PICs. But 1/2 of the peripheral bus clock should be achievable. And if you need a large, cheap memory: attach an SD card via SPI (either the same as the one used for the display, or one of the others).
     
    And please - don't tell me about these huge files for raster fonts: no need to copy the whole font - just copy the character(s) you currently need.
     
    But to be honest: please ignore all suggestions made here: for you, the only way to gain experience seems to be to make your own faults...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #7
    LdB_ECM
    Senior Member
    • Total Posts : 148
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 11:02:20 (permalink)
    0
    Hey I have been making coding mistakes for 40 years but it pays well :-)
     
    I am not sure what huge issues you are seeing it's a boring basic software renderer admittedly I am usually on 32bit CPU's to do this but hey the PIC 16bit will do it.
    here is the unrendered .. from memory this is Tahomee
    https://github.com/LdB-EC...s/outline.jpg?raw=true
    Once you hit it with the hints, anti alising and render it you get this sort of thing
    https://github.com/LdB-EC.../rendered.jpg?raw=true
    It's working fine so I am not remotely interested in going back to Bitmap fonts
    #8
    LdB_ECM
    Senior Member
    • Total Posts : 148
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 11:03:37 (permalink)
    0
    What I will take a hand with because I am new to PIC cpu's is can anyone see if I can set the SPI faster here is my settings

        SPI1CON1bits.SPIEN         = 0;    // disable SPI port
        SPI1CON1bits.SPISIDL     = 0;     // Continue module operation in Idle mode
     
        SPI1STATLbits.SPIROV    = 0;    // Clear receive overrun
        
        IFS0bits.SPI1IF         = 0;    // clear interrupt flag
        IEC0bits.SPI1IE         = 0;    // disable interrupt
        SPI1IMSKLbits.SRMTEN    = 1;    // enable interrupt mask for shift register empty
          
        SPI1CON1Hbits.IGNROV    = 1;    // Ignore receive overrun
        SPI1CON1Hbits.IGNTUR    = 1;    // Ignore transmit underrun
        SPI1CON1Hbits.AUDEN     = 0;    // Audio protocol disabled
        SPI1CON1Hbits.SPISGNEXT = 0;    // Data from RX not sign extended
        
        SPI1CON1bits.DISSCK        = 0;    // Internal SPIx clock is enabled
        SPI1CON1bits.DISSDO        = 0;    // SDOx pin is controlled by the module
        SPI1CON1bits.DISSDI     = 0;    // SDIx pin is controlled by the module
        SPI1CON1bits.MODE16     = 0;    // set in 16-bit mode, clear in 8-bit mode
        SPI1CON1bits.MODE32     = 0;    // set in 32-bit mode, clear in 16/8-bit mode
        SPI1CON1bits.SMP        = 0;    // Input data sampled at middle of data output time
        SPI1CON1bits.CKP         = 1;    // CKP .. 1 = clock high at idle, 0 = clock low at idle
        SPI1CON1bits.CKE         = 1;    // CKE .. 1 = data on active to idle 0 = data on idle to active
        SPI1CON1bits.MSTEN         = 1;     // 1 =  Master mode; 0 =  Slave mode... based on your communication mode.
        SPI1CON1bits.MCLKEN     = 0;    // Peripheral clock is used
        SPI1CON1bits.ENHBUF     = 0;    // Normal buffer modes
        
        SPI1CON2Lbits.WLENGTH   = 0b00111;    // Variable world length 8-bits
        
        SPI1BRGLbits.BRG        = 1;    // Set Baud Rate at 4 Mhz, FPB=32 Mhz
        
        SPI1CON1bits.SPIEN      = 1;     // enable SPI port, clear status

     
    #9
    du00000001
    Just Some Member
    • Total Posts : 3065
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 11:26:01 (permalink)
    0
    I can see the Interface for the SD card  :)
     
    Re faster: what happens if you set .BRG to 0?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #10
    LdB_ECM
    Senior Member
    • Total Posts : 148
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 11:43:03 (permalink)
    0
    Yes the SD card interface is there but no chip ... I was spewing :-(
    https://www.ebay.com/itm/...-Arduino-/163356024114
    Might be an option if I can work out what it is :-)
     
    Display dies when I set 0 on .BRG ... but that is a point I didn't check it with scope let me check.
    #11
    du00000001
    Just Some Member
    • Total Posts : 3065
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 11:53:52 (permalink)
    +1 (1)
    If this chip is connected to MISO: level shifter.
    SDs usually run on 3.3 V, the Arduino on 5 V. I didn't check what your PIC24 is running from: if it's 3.3 V, you simply have to bridge the SD's MISO to the connector's MISO.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #12
    LdB_ECM
    Senior Member
    • Total Posts : 148
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 19:14:10 (permalink)
    0
    Thanks for info will try that as yes I am on 3v.
    Now to try and find an easy spare pin to use as the CS line :-)
    #13
    du00000001
    Just Some Member
    • Total Posts : 3065
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Anyone done scalable fonts on the PIC 16 bits? 2019/06/25 23:57:24 (permalink)
    0
    The extreme way - provided you have only the display and the SD card on this SPI: use an inverter and tap the display's #CS.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5