Parallax Font on ST7735 TFT
I recently purchased some 128x128 ST7735 color TFT displays from Adafruit:
I got these because there is Spin code available to drive them:
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:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 ' I/O pins CS_PIN = 0 SCK_PIN = 1 SDA_PIN = 2 DC_PIN = 3 RESET_PIN = 4 ' display dimensions WIDTH = 128 HEIGHT = 128 OBJ dsp: "st7735" PUB Start setup dsp.mirrorh(TRUE) ' change these to suit the dsp.mirrorv(TRUE) ' orientation of your display dsp.bg_color(dsp#BLACK) dsp.clear dsp.set_font(dsp#FONT8x16) dsp.fg_color(dsp#CYAN) dsp.pix_position(64, 0) dsp.ctr_str(string("FONT8x16")) dsp.set_font(dsp#FONT16x16) dsp.fg_color(dsp#YELLOW) dsp.pix_position(64, 16) dsp.ctr_str(string("16x16")) dsp.set_font(dsp#FONT8x32) dsp.fg_color(dsp#GREEN) dsp.pix_position(64, 32) dsp.ctr_str(string("FONT8x32")) dsp.set_font(dsp#FONT16x32) dsp.fg_color(dsp#MAGENTA) dsp.pix_position(64, 64) dsp.ctr_str(string("16x32")) dsp.set_font(dsp#FONT32x32) dsp.fg_color(dsp#ORANGE) dsp.pix_position(64, 96) dsp.ctr_str(string("3232")) repeat PUB setup dsp.startx(CS_PIN, SCK_PIN, SDA_PIN, DC_PIN, RESET_PIN, WIDTH, HEIGHT)
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.
The object, with the PASM character driver, and its sub_objects are attached here.