
Originally Posted by
KurtE
I will take a look - Any hints? Which type of font? That is there are probably 6 different output functions, depending on which type of font (built in, GFX, or ILI...) And then there is in most cases Opaque versus Transparent (i.e. setTextColor do you specify one or two colors?)
Again it would help to know the whole program... But the library was made to not directly rely on Adafruit_GFX library.
So you might try adding: #include <Adafruit_GFX.h>
before your try to include the font file and see if that helps.
@mjs513 may be able to answer more about the font positioning. I know there was some work done to try to make the positioning of fonts more consistent.
Program to illustrate the error:
Code:
#include <Adafruit_GFX.h> // Core graphics library
#include <ST7735_t3.h>
#include <SPI.h>
#include <Fonts/FreeSansBold9pt7b.h>
// OLED spi pin definitions
#define TFT_SCLK 13 // SCLK can also use pin 14
#define TFT_MOSI 11 // MOSI can also use pin 7
#define TFT_CS 10 // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define TFT_DC 9 // but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define TFT_RST 8 // RST can use any pin
// colors in GBR format
#define ST7735I_BLACK 0x0000 // no change needed
#define ST7735I_WHITE 0xFFFF // no change needed
#define ST7735I_RED 0x001F // 0000000000011111 was 0xF800
#define ST7735I_GREEN 0x07E0 // no change needed
#define ST7735I_BLUE 0xF800 // 1111100000000000 was 0x001F
#define ST7735I_CYAN 0xFFE0 // 1111111111100000 was 0x07FF
#define ST7735I_MAGENTA 0xF81F // no change needed
#define ST7735I_YELLOW 0x07FF // 0000011111111111 was 0xFFE0
#define ST7735I_ORANGE 0x041f // 0000010000011111 was 0xFC00
ST7735_t3 tft = ST7735_t3(TFT_CS, TFT_DC, TFT_RST);
void setup() {
tft.initR(INITR_MINI160x80);
tft.invertDisplay(true);
tft.setRotation(3);
tft.setFont(&FreeSansBold9pt7b);
tft.fillScreen(ST7735I_WHITE);
tft.setTextColor(ST7735I_BLACK);
tft.setTextSize(3);
}
void draw_top_screen() {
tft.drawLine(0, 0, 160, 0, ST7735I_ORANGE);
tft.drawLine(0, 1, 160, 1, ST7735I_ORANGE);
tft.drawLine(0, 29, 160, 29, ST7735I_ORANGE);
tft.drawLine(0, 30, 160, 30, ST7735I_ORANGE);
tft.drawLine(0, 1, 0, 28, ST7735I_ORANGE);
tft.drawLine(1, 1, 1, 28, ST7735I_ORANGE);
tft.drawLine(159, 2, 159, 28, ST7735I_ORANGE);
tft.drawLine(158, 2, 158, 28, ST7735I_ORANGE);
tft.fillRect(2, 2, 156, 27, ST7735I_CYAN);
tft.setTextColor(ST7735I_BLUE);
tft.setCursor(37, 10);
tft.setTextSize(1);
tft.println("CO [ppm]");
//tft.println("CO");
//tft.setCursor(69, 10);
//tft.println("[ppm]");
}
void loop() {
draw_top_screen();
while(1);
}
Screenshot of ignored space:

Code to avoid printing spaces in tft.println
Code:
#include <Adafruit_GFX.h> // Core graphics library
#include <ST7735_t3.h>
#include <SPI.h>
#include <Fonts/FreeSansBold9pt7b.h>
// OLED spi pin definitions
#define TFT_SCLK 13 // SCLK can also use pin 14
#define TFT_MOSI 11 // MOSI can also use pin 7
#define TFT_CS 10 // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define TFT_DC 9 // but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define TFT_RST 8 // RST can use any pin
// colors in GBR format
#define ST7735I_BLACK 0x0000 // no change needed
#define ST7735I_WHITE 0xFFFF // no change needed
#define ST7735I_RED 0x001F // 0000000000011111 was 0xF800
#define ST7735I_GREEN 0x07E0 // no change needed
#define ST7735I_BLUE 0xF800 // 1111100000000000 was 0x001F
#define ST7735I_CYAN 0xFFE0 // 1111111111100000 was 0x07FF
#define ST7735I_MAGENTA 0xF81F // no change needed
#define ST7735I_YELLOW 0x07FF // 0000011111111111 was 0xFFE0
#define ST7735I_ORANGE 0x041f // 0000010000011111 was 0xFC00
ST7735_t3 tft = ST7735_t3(TFT_CS, TFT_DC, TFT_RST);
void setup() {
tft.initR(INITR_MINI160x80);
tft.invertDisplay(true);
tft.setRotation(3);
tft.setFont(&FreeSansBold9pt7b);
tft.fillScreen(ST7735I_WHITE);
tft.setTextColor(ST7735I_BLACK);
tft.setTextSize(3);
}
void draw_top_screen() {
tft.drawLine(0, 0, 160, 0, ST7735I_ORANGE);
tft.drawLine(0, 1, 160, 1, ST7735I_ORANGE);
tft.drawLine(0, 29, 160, 29, ST7735I_ORANGE);
tft.drawLine(0, 30, 160, 30, ST7735I_ORANGE);
tft.drawLine(0, 1, 0, 28, ST7735I_ORANGE);
tft.drawLine(1, 1, 1, 28, ST7735I_ORANGE);
tft.drawLine(159, 2, 159, 28, ST7735I_ORANGE);
tft.drawLine(158, 2, 158, 28, ST7735I_ORANGE);
tft.fillRect(2, 2, 156, 27, ST7735I_CYAN);
tft.setTextColor(ST7735I_BLUE);
tft.setCursor(37, 10);
tft.setTextSize(1);
//tft.println("CO [ppm]");
tft.println("CO");
tft.setCursor(69, 10);
tft.println("[ppm]");
}
void loop() {
draw_top_screen();
while(1);
}
Screenshot correcting problem by setting the cursor position instead of tft.println with spaces in the string:

Edited to add: Please do not get hung up on the #defined GBR colors. You can replace them with the ones that are pre-defined. They have nothing to do with it.