Printing special characters on a TFT display


Let's talk about the 1.8" display offering 160 x 128 pixels controlled by the Sitronix ST7735 using the standard TFT library (Adafruit-ST7735-Library). The size of the display enables you to print the entire character set on one screen.

Off By One

Actually, if you compare this with the Standard code page 437 you will realize some differences.

Code page 437 Sitronix ST7735

If you are looking for  μ  e.g. on 437 it is code 0xE6 while on the TFT it is 0xE5. To enter a  μ  in a string just use the octal representation i.e. \345.

Or if you are dealing with temperature or angles you might want to display  °  which is 0xF8 on 437 and 0xF7 on TFT, octal: \367.

So, whoever wrote that library, he or she must have had a bad day.

If you are using a different library you might use this program to display yours:

#include <TFT.h>  // Arduino LCD library

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8

TFT TFTscreen = TFT(cs, dc, rst);

void setup() {
  TFTscreen.begin();
  TFTscreen.background(0, 0, 0);
  int x = 0;
  int y = 10;
  int A, B;
  for (int i = 0; i <= 255; i++) {
    TFTscreen.stroke(A, B, 255);
    char c[] = " \0";
    c[0] = i;
    TFTscreen.text(c, x, y);
    x = x + 5;
    B = 255 - B;
    if (x > 158) {
      y = y + 12;
      x = 0;
      A = 255 - A;
    }
  }
}
void loop() { }



contact: nji(at)gmx.de