Shop Learn
Propeller Font on ST7735 TFT — Parallax Forums

Propeller Font on ST7735 TFT

I recently purchased some 128x128 ST7735 color TFT displays from Adafruit:

https://www.adafruit.com/product/2088

I got these because there is Spin code available to drive them:

https://github.com/avsa242/st7735-spin

The code is rife with pre-processor stuff, and I tried it on both FlexProp and PropellerIDE, since both have compilers that support pre-processors. But I wasn't too happy with either option. As a consequence, I did the necessary pre-processing manually, stripping out all of the directives, so I could work with it on the good ol' Propeller Tool. Ahhh!

The only font that came with the software driver was a tiny 8x8 font that one would have to squint to see. For my app (more on that later), I needed a bigger font that could be read at a distance. The Parallax font built into the Propeller's ROM fit the bill perfectly. Plus, it can be scaled up and down quite readily.

So I wrote a driver in Spin that uses the Parallax font. Here's a photo of some sample output:

There's one more size (32x64) that takes up half the screen, but you get the idea.

Here's the front-end code that produces the above display:

PUB start

    setup

    dsp.mirrorh(TRUE)                          ' change these to suit the
    dsp.mirrorv(TRUE)                          ' orientation of your display
    dsp.bgcolor(dsp#BLACK)
    dsp.clear

    dsp.setfont(dsp#FONT8x16)
    dsp.fgcolor(dsp#CYAN)
    dsp.pixposition(64, 0)
    dsp.ctrstr(string("FONT8x16"))

    dsp.setfont(dsp#FONT16x16)
    dsp.fgcolor(dsp#YELLOW)
    dsp.pixposition(64, 16)
    dsp.ctrstr(string("16x16"))

    dsp.setfont(dsp#FONT8x32)
    dsp.fgcolor(dsp#GREEN)
    dsp.pixposition(64, 32)
    dsp.ctrstr(string("FONT8x32"))

    dsp.setfont(dsp#FONT16x32)
    dsp.fgcolor(dsp#MAGENTA)
    dsp.pixposition(64, 64)
    dsp.ctrstr(string("16x32"))

    dsp.setfont(dsp#FONT32x32)
    dsp.fgcolor(ORANGE)
    dsp.pixposition(64, 96)
    dsp.ctrstr(string("3232"))
    repeat

The Spin code that draws characters to the screen is painfully sloooow! So my next task is to convert my character generator to PASM. This will be done using a small hub-RAM buffer to hold the pixels for a character at a time, which can then be blasted to the ST7735 all at once.

More to come...

-Phil

Comments

  • Hi Phil,

    That looks great with the bigger fonts...I hadn't yet attempted to use the P1 ROM font. The main reason I went with the small font I found was so more could be displayed at once, but obviously that's dependent on the application.

    Yeah, graphics definitely are not my strong suit, and agreed on the Char() lack of speed...it is all in SPIN, so that's the one excuse I'll throw out there :smiley:
    I originally wrote it with buffered displays in mind, so it handles things like scrolling if trying to draw past the last row.
    It definitely wakes up (well, some) when built using FlexSpin's native code output, though.
    The preprocessed/conditionally built code is there so I could reuse the same terminal I/O library as any other driver (or serial), as well as use the same graphics code, rather than re-implementing it (and thus maintaining it) for every single driver.

    Cheers

  • Hi Jesse,

    I didn't find your 8x8 code to be slow at all. But with bigger characters and all the conditional checking my Char() routine has to do to deal with different font sizes, things really get bogged down.

    BTW, thanks for providing such a thorough driver for this display! It would've taken me months to start from scratch, and I sorta have a Christmas deadline. :)

    -Phil

  • Really? I thought it was pretty slow - lol! Thanks all the same, though. I know what you mean about the conditional code. Every time I look at it, I think maybe there's something I can forego checking, or something I can take out of the innermost loop.
    You're welcome, and good luck on the project. :)

    Cheers

  • Hi Phil,

    I have a similar but 128x160 pixels LCD on a robot, and I really want to have bigger fonts on it. Please share your spin1 code for the driver ( I'm using propeller tool) and I will be very grateful.

    Cheers

  • Will do. I've got some tidying up to do first, and hopefully I can make it obvious how to expand to your display size. This might take awhile, unfortunately. I was able to transfer the character display to PASM, however, and it's very fast.

    -Phil

  • No hurry. Good luck!

    -Stefan

Sign In or Register to comment.