Overwriting tft print value change from 3 -> 2 digits

Hi All

I am trying to work out how to overwrite a value on a tft screen. The issue is that when the value changes from, say 123 to 63, it then displays 633. if I change the tft.print(value,0) to ( value,1) it displays better, but shows the dec point, which I dont want. I just want to display the whole number without dec point.

I could do a fillRect(x,y, backgroundcolor ) but would rather not as there is already a lot of things going on regarding screen display updates

Yes, the code is not completed and will get cleaned up when I get it to where I want.

Eventually it will run on a Teensy4.0, so speed is not a problem

Below is a link to the virtual project -- first time using wokwi, and seems to work well


relevent code section here.

tft.setCursor(185, 100);
    tft.setFont();
    tft.setTextColor(ORANGE, BLACK);
    tft.setTextSize(2);
    tft.println(Voltage, 1);
    //tft.setTextSize(1);
    tft.setTextColor(ORANGE, GREY);
    tft.setCursor(51, 185);
    tft.print(TempVal, 0);

    tft.setCursor(173, 185);
    tft.println(TurboVal, 0);

    tft.setCursor(51, 274);
    tft.println(OilVal, 0);

    tft.setCursor(167, 274);
    tft.println(ExhaustVal, 0);

/*

https://javl.github.io/image2cpp/ - convert images to hex, generates arduino code

https://www.iconarchive.com/ - icons

https://www.pixilart.com/draw/96x64-bitmap-7012c32cc9


*/
// Credits to Bodmer on instrucatabls.com for the rainbow ring meter

#include "DHT.h"
#include <SPI.h>
#include "Adafruit_GFX.h"
#include <Fonts/FreeSansBoldOblique9pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Adafruit_ILI9341.h>
#include <ButtonDebounce.h>
DHT dht1(2, DHT22);
DHT dht2(3, DHT22);
DHT dht3(4, DHT22);
DHT dht4(5, DHT22);



#define TFT_CS 10
#define TFT_RST 6
#define TFT_DC 7
//Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

#define BLACK 0x0000
#define GRAY 0x8410  //lGRAY = light gray, GREY = dark grey  16bit colour
#define WHITE 0xFFFF
#define RED 0xF800
#define ORANGE 0xFDC0
#define YELLOW 0xFFE0
#define DENIM 0x03EE
#define GREEN 0x1781
#define DARKGREEN 0x2ce1
#define LIGHTGREEN 0xc781
#define CYAN 0x07FF
#define AQUA 0x04FF
#define BLUE 0x001F
#define MAGENTA 0xF81F
#define PINK 0xF8FF

#define WHITE2BLUE 0
#define GREEN2GREEN 1
#define BLUE2BLUE 2
#define BLUE2RED 3
#define GREEN2RED 4
#define RED2GREEN 5
#define YELLOW2RED 6
#define WHITE2BLUE 7
#define GREY 0x2104  // Dark grey 16 bit colour

float TempVal = 0;     //dht1.readTemperature();
float OilVal = 0;      //dht2.readTemperature();
float TurboVal = 0;    //dht3.readTemperature();
float ExhaustVal = 0;  //dht4.readTemperature();
float Voltage = 13.8;

ButtonDebounce GlowpluG(2, 50);  // ******* Just here for testing *****
ButtonDebounce HighbeaM(3, 50);
ButtonDebounce ParkbrakE(4, 50);
ButtonDebounce DifflocK(5, 50);
ButtonDebounce BatterY(6, 50);
ButtonDebounce ArroW(7, 50);

// 'Blank Battery', 60x60px
const unsigned char Battery[] PROGMEM = {

  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xf8, 0x03, 0xff, 0xfc, 0x01, 0xff, 0xf0,
  0xff, 0xf8, 0x03, 0xff, 0xfc, 0x01, 0xff, 0xf0, 0xff, 0xf8, 0x03, 0xff, 0xfc, 0x01, 0xff, 0xf0,
  0xff, 0xf8, 0x43, 0xff, 0xfc, 0x21, 0xff, 0xf0, 0xff, 0xf8, 0x43, 0xff, 0xfc, 0x21, 0xff, 0xf0,
  0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70,
  0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x70,
  0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70,
  0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0


};


// 'Pictogrammers-Material-Car-brake-parking', 60x60px
const unsigned char ParkBrake[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xfe, 0x00, 0x07, 0xff, 0xff, 0xf0, 0xff, 0x3f, 0xf8, 0x00, 0x01, 0xff, 0xcf, 0xf0,
  0xfe, 0x1f, 0xe0, 0x00, 0x00, 0x7f, 0x87, 0xf0, 0xfc, 0x1f, 0x80, 0x00, 0x00, 0x1f, 0x83, 0xf0,
  0xfc, 0x1f, 0x00, 0x00, 0x00, 0x0f, 0x83, 0xf0, 0xf8, 0x3e, 0x00, 0xff, 0xf0, 0x07, 0xc1, 0xf0,
  0xf0, 0x7c, 0x03, 0xff, 0xfc, 0x03, 0xe0, 0xf0, 0xf0, 0xf8, 0x0f, 0xff, 0xff, 0x01, 0xf0, 0xf0,
  0xe0, 0xf0, 0x1f, 0xff, 0xff, 0x80, 0xf0, 0x70, 0xe1, 0xe0, 0x3f, 0x00, 0x3f, 0xc0, 0x78, 0x70,
  0xc3, 0xe0, 0x7f, 0x00, 0x07, 0xe0, 0x7c, 0x30, 0xc3, 0xc0, 0xff, 0x00, 0x03, 0xf0, 0x3c, 0x30,
  0xc3, 0xc1, 0xff, 0x00, 0x03, 0xf8, 0x3c, 0x30, 0x87, 0x81, 0xff, 0x00, 0x01, 0xf8, 0x1e, 0x10,
  0x87, 0x83, 0xff, 0x00, 0x01, 0xfc, 0x1e, 0x10, 0x87, 0x03, 0xff, 0x07, 0xc1, 0xfc, 0x0e, 0x10,
  0x0f, 0x07, 0xff, 0x07, 0xc1, 0xfe, 0x0f, 0x00, 0x0f, 0x07, 0xff, 0x07, 0xc1, 0xfe, 0x0f, 0x00,
  0x0f, 0x07, 0xff, 0x07, 0xc1, 0xfe, 0x0f, 0x00, 0x0f, 0x07, 0xff, 0x07, 0xc1, 0xfe, 0x0f, 0x00,
  0x0f, 0x07, 0xff, 0x00, 0x01, 0xfe, 0x0f, 0x00, 0x0f, 0x07, 0xff, 0x00, 0x03, 0xfe, 0x0f, 0x00,
  0x0f, 0x07, 0xff, 0x00, 0x03, 0xfe, 0x0f, 0x00, 0x0f, 0x07, 0xff, 0x00, 0x07, 0xfe, 0x0f, 0x00,
  0x0f, 0x07, 0xff, 0x07, 0xff, 0xfe, 0x0f, 0x00, 0x0f, 0x07, 0xff, 0x07, 0xff, 0xfe, 0x0f, 0x00,
  0x0f, 0x07, 0xff, 0x07, 0xff, 0xfe, 0x0f, 0x00, 0x0f, 0x07, 0xff, 0x07, 0xff, 0xfe, 0x0f, 0x00,
  0x87, 0x03, 0xff, 0x07, 0xff, 0xfc, 0x0e, 0x10, 0x87, 0x83, 0xff, 0x07, 0xff, 0xfc, 0x1e, 0x10,
  0x87, 0x81, 0xff, 0x07, 0xff, 0xf8, 0x1e, 0x10, 0xc3, 0xc1, 0xff, 0x07, 0xff, 0xf8, 0x3c, 0x30,
  0xc3, 0xc0, 0xff, 0x07, 0xff, 0xf0, 0x3c, 0x30, 0xc3, 0xe0, 0x7f, 0x07, 0xff, 0xe0, 0x7c, 0x30,
  0xe1, 0xe0, 0x3f, 0x07, 0xff, 0xc0, 0x78, 0x70, 0xe0, 0xf0, 0x1f, 0xff, 0xff, 0x80, 0xf0, 0x70,
  0xf0, 0xf8, 0x0f, 0xff, 0xff, 0x01, 0xf0, 0xf0, 0xf0, 0x7c, 0x03, 0xff, 0xfc, 0x03, 0xe0, 0xf0,
  0xf8, 0x3e, 0x00, 0xff, 0xf0, 0x07, 0xc1, 0xf0, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x0f, 0x83, 0xf0,
  0xfc, 0x1f, 0x80, 0x00, 0x00, 0x1f, 0x83, 0xf0, 0xfe, 0x1f, 0xe0, 0x00, 0x00, 0x7f, 0xc7, 0xf0,
  0xff, 0x3f, 0xf8, 0x00, 0x01, 0xff, 0xef, 0xf0, 0xff, 0xff, 0xfe, 0x00, 0x07, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0
};

// 'car-repair', 60x60px
const unsigned char DiffLock[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0x0f, 0xf0, 0xff, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x0f, 0xf0,
  0xfe, 0x00, 0x1f, 0xe0, 0x7f, 0x80, 0x07, 0xf0, 0xfe, 0x00, 0x1f, 0xc0, 0x3f, 0x80, 0x07, 0xf0,
  0xfe, 0x1e, 0x1f, 0x80, 0x1f, 0x87, 0x87, 0xf0, 0xfe, 0x1e, 0x00, 0x06, 0x00, 0x07, 0x87, 0xf0,
  0xfe, 0x1e, 0x00, 0x0f, 0x00, 0x07, 0x87, 0xf0, 0xfe, 0x1e, 0x00, 0x0f, 0x00, 0x07, 0x87, 0xf0,
  0xfe, 0x1e, 0x00, 0x06, 0x00, 0x07, 0x87, 0xf0, 0xfe, 0x1e, 0x1f, 0x80, 0x1f, 0x87, 0x87, 0xf0,
  0xfe, 0x1e, 0x1f, 0x80, 0x1f, 0x87, 0x87, 0xf0, 0xfe, 0x00, 0x1f, 0xc0, 0x3f, 0x80, 0x07, 0xf0,
  0xfe, 0x00, 0x1f, 0xf0, 0xff, 0x80, 0x07, 0xf0, 0xff, 0x00, 0x1f, 0xf0, 0xff, 0x80, 0x0f, 0xf0,
  0xff, 0x00, 0x3f, 0xf0, 0xff, 0xc0, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xff, 0x00, 0x3f, 0xf0, 0xff, 0xc0, 0x0f, 0xf0,
  0xff, 0x00, 0x1f, 0xf0, 0xff, 0x80, 0x0f, 0xf0, 0xfe, 0x00, 0x1f, 0xf0, 0xff, 0x80, 0x07, 0xf0,
  0xfe, 0x00, 0x1f, 0xc0, 0x3f, 0x80, 0x07, 0xf0, 0xfe, 0x1e, 0x1f, 0x80, 0x1f, 0x87, 0x87, 0xf0,
  0xfe, 0x1e, 0x1f, 0x80, 0x1f, 0x87, 0x87, 0xf0, 0xfe, 0x1e, 0x00, 0x06, 0x00, 0x07, 0x87, 0xf0,
  0xfe, 0x1e, 0x00, 0x0f, 0x00, 0x07, 0x87, 0xf0, 0xfe, 0x1e, 0x00, 0x0f, 0x00, 0x07, 0x87, 0xf0,
  0xfe, 0x1e, 0x00, 0x06, 0x00, 0x07, 0x87, 0xf0, 0xfe, 0x1e, 0x1f, 0x80, 0x1f, 0x87, 0x87, 0xf0,
  0xfe, 0x00, 0x1f, 0xc0, 0x3f, 0x80, 0x07, 0xf0, 0xfe, 0x00, 0x1f, 0xe0, 0x7f, 0x80, 0x07, 0xf0,
  0xff, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x0f, 0xf0, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0x0f, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0
};

// 'High Beam', 60x60px
const unsigned char HighBeam[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf0, 0xf8, 0x00, 0x01, 0xf8, 0x00, 0x7f, 0xff, 0xf0,
  0xf8, 0x00, 0x01, 0xf0, 0x00, 0x0f, 0xff, 0xf0, 0xf8, 0x00, 0x03, 0xf0, 0x00, 0x07, 0xff, 0xf0,
  0xf8, 0x00, 0x03, 0xe0, 0x00, 0x01, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xe0, 0xf8, 0x00, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xe0, 0xff, 0x00, 0x3f, 0xf0, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xc0, 0x1f, 0xf0,
  0xff, 0xff, 0xff, 0xc1, 0xff, 0xf0, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xf8, 0x0f, 0xf0,
  0xf8, 0x00, 0x0f, 0xc1, 0xff, 0xfe, 0x07, 0xf0, 0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x07, 0xf0,
  0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x03, 0xf0, 0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x83, 0xf0,
  0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x81, 0xf0, 0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0xc1, 0xf0,
  0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xc1, 0xf0, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xc1, 0xf0,
  0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xc1, 0xf0, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xc1, 0xf0,
  0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0xc1, 0xf0, 0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x81, 0xf0,
  0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x83, 0xf0, 0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x03, 0xf0,
  0xf8, 0x00, 0x0f, 0x83, 0xff, 0xff, 0x07, 0xf0, 0xf8, 0x00, 0x0f, 0xc1, 0xff, 0xfe, 0x07, 0xf0,
  0xff, 0xff, 0xff, 0xc1, 0xff, 0xf8, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xf0, 0x0f, 0xf0,
  0xff, 0xff, 0xff, 0xc1, 0xff, 0xc0, 0x1f, 0xf0, 0xff, 0xff, 0xff, 0xe0, 0xff, 0x00, 0x3f, 0xf0,
  0xff, 0xff, 0xff, 0xe0, 0xf8, 0x00, 0xff, 0xf0, 0xf8, 0x00, 0x03, 0xe0, 0x00, 0x01, 0xff, 0xf0,
  0xf8, 0x00, 0x03, 0xf0, 0x00, 0x07, 0xff, 0xf0, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x0f, 0xff, 0xf0,
  0xf8, 0x00, 0x01, 0xf8, 0x00, 0x7f, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0
};
// 'glowplug', 60x60px
const unsigned char GlowPlug[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x70, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x30,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x10,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00,
  0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x10, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x10,
  0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x70, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xe0, 0x00, 0x70,
  0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0x70, 0xff, 0xff, 0xff, 0xfe, 0x00, 0xf8, 0x00, 0x70,
  0xff, 0xff, 0xff, 0xfe, 0x00, 0x7c, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xfe, 0x18, 0xfe, 0x01, 0xf0,
  0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0x87, 0xf0,
  0xff, 0xff, 0xff, 0xc0, 0x1f, 0xff, 0x87, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x3f, 0xff, 0x87, 0xf0,
  0xff, 0xff, 0xfe, 0x03, 0xff, 0xf0, 0x07, 0xf0, 0xff, 0xfc, 0x7c, 0x0f, 0xff, 0xf0, 0x07, 0xf0,
  0xff, 0xf8, 0x38, 0x1f, 0xff, 0xf0, 0x0f, 0xf0, 0xff, 0xf0, 0x10, 0x7f, 0xff, 0xf8, 0x3f, 0xf0,
  0xff, 0xe0, 0x00, 0xff, 0xff, 0xf8, 0x7f, 0xf0, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xf8, 0x7f, 0xf0,
  0xff, 0x80, 0x03, 0xff, 0xff, 0x80, 0x7f, 0xf0, 0xff, 0x00, 0x01, 0xff, 0xff, 0x00, 0xff, 0xf0,
  0xfe, 0x00, 0x00, 0xff, 0xff, 0x01, 0xff, 0xf0, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0x07, 0xff, 0xf0,
  0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x0f, 0xff, 0xf0, 0xff, 0x00, 0x00, 0x1f, 0xfe, 0x1f, 0xff, 0xf0,
  0xff, 0x80, 0x00, 0x0f, 0xfc, 0x1f, 0xff, 0xf0, 0xff, 0xc0, 0x00, 0x07, 0xfc, 0x3f, 0xff, 0xf0,
  0xff, 0xe0, 0x00, 0x03, 0xf8, 0x3f, 0xff, 0xf0, 0xff, 0xf0, 0x00, 0x01, 0xf0, 0x7f, 0xff, 0xf0,
  0xff, 0xf8, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xf0, 0xff, 0xfc, 0x00, 0x00, 0x60, 0xff, 0xff, 0xf0,
  0xff, 0xfe, 0x00, 0x00, 0x01, 0xff, 0xff, 0xf0, 0xff, 0x3f, 0x00, 0x00, 0x03, 0xff, 0xff, 0xf0,
  0xfe, 0x1f, 0x80, 0x00, 0x07, 0xff, 0xff, 0xf0, 0xfc, 0x0f, 0xc0, 0x00, 0x07, 0xff, 0xff, 0xf0,
  0xf8, 0x07, 0xe0, 0x00, 0x03, 0xff, 0xff, 0xf0, 0xf0, 0x03, 0xf0, 0x00, 0x01, 0xff, 0xff, 0xf0,
  0xe0, 0x01, 0xf8, 0x00, 0x01, 0xff, 0xff, 0xf0, 0xc0, 0x00, 0xfc, 0x00, 0x01, 0xff, 0xff, 0xf0,
  0x80, 0x00, 0x7e, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x04, 0x00, 0x3f, 0x00, 0x07, 0xff, 0xff, 0xf0,
  0x0e, 0x00, 0x1f, 0x80, 0x0f, 0xff, 0xff, 0xf0, 0x1e, 0x00, 0x0f, 0xc0, 0x1f, 0xff, 0xff, 0xf0,
  0x1e, 0x00, 0x07, 0xe0, 0x3f, 0xff, 0xff, 0xf0, 0x1e, 0x00, 0x07, 0xf0, 0x7f, 0xff, 0xff, 0xf0,
  0x1e, 0x00, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0x1f, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0x8f, 0xf8, 0x3f, 0xff, 0xfe, 0xff, 0xff, 0xf0, 0x87, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xc3, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xe0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xf0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0
};

// 'Arrow', 60x60px
// 'Arrow', 60x60px
const unsigned char Arrow[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xef, 0xff, 0xff, 0x7f, 0xff, 0xf0,
  0xff, 0xff, 0xef, 0xff, 0xff, 0x7f, 0xff, 0xf0, 0xff, 0xff, 0x8f, 0xff, 0xff, 0x1f, 0xff, 0xf0,
  0xff, 0xff, 0x8f, 0xff, 0xff, 0x1f, 0xff, 0xf0, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0x07, 0xff, 0xf0,
  0xff, 0xfe, 0x0f, 0xff, 0xff, 0x07, 0xff, 0xf0, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0x01, 0xff, 0xf0,
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0x00, 0xff, 0xf0, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0x00, 0x7f, 0xf0,
  0xff, 0xc0, 0x0f, 0xff, 0xff, 0x00, 0x3f, 0xf0, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0,
  0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0,
  0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0,
  0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0,
  0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0,
  0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0xff, 0xc0, 0x0f, 0xff, 0xff, 0x00, 0x3f, 0xf0,
  0xff, 0xe0, 0x0f, 0xff, 0xff, 0x00, 0x7f, 0xf0, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0x01, 0xff, 0xf0,
  0xff, 0xf8, 0x0f, 0xff, 0xff, 0x01, 0xff, 0xf0, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0x07, 0xff, 0xf0,
  0xff, 0xfe, 0x0f, 0xff, 0xff, 0x07, 0xff, 0xf0, 0xff, 0xff, 0x8f, 0xff, 0xff, 0x1f, 0xff, 0xf0,
  0xff, 0xff, 0x8f, 0xff, 0xff, 0x1f, 0xff, 0xf0, 0xff, 0xff, 0xef, 0xff, 0xff, 0x7f, 0xff, 0xf0,
  0xff, 0xff, 0xef, 0xff, 0xff, 0x7f, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0
};


const unsigned char Oil[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff,
  0xc0, 0x00, 0x1f, 0xc1, 0x93, 0xff, 0x80, 0x03, 0x37, 0xff, 0x8f, 0x0f, 0x37, 0xff, 0x9c, 0x3b,
  0x37, 0xff, 0x91, 0xf1, 0x37, 0xff, 0x87, 0xe4, 0x97, 0xff, 0x9f, 0xee, 0xc7, 0xff, 0x9f, 0xec,
  0xf7, 0xff, 0x9f, 0xe1, 0xf0, 0x00, 0x1f, 0xff, 0xf0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};


// '32pix_TempIcon', 32x32px
const unsigned char Temp[] PROGMEM = {
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xf9, 0x9f, 0xff, 0xff, 0xfb, 0xdf, 0xff,
  0xff, 0xfa, 0x5f, 0xff, 0xff, 0xfa, 0x5f, 0xff, 0xff, 0xfa, 0x47, 0xff, 0xff, 0xfa, 0x47, 0xff,
  0xff, 0xfa, 0x4f, 0xff, 0xff, 0xfa, 0x47, 0xff, 0xff, 0xfa, 0x4f, 0xff, 0xff, 0xfa, 0x47, 0xff,
  0xff, 0xfa, 0x47, 0xff, 0xff, 0xfa, 0x5f, 0xff, 0xff, 0xfa, 0x5f, 0xff, 0xff, 0xfa, 0x5f, 0xff,
  0xff, 0xfa, 0x5f, 0xff, 0xff, 0xfa, 0x5f, 0xff, 0xff, 0xfa, 0x5f, 0xff, 0xff, 0xf2, 0x4f, 0xff,
  0xff, 0xe6, 0x67, 0xff, 0xff, 0xcc, 0x33, 0xff, 0xff, 0xd9, 0x9b, 0xff, 0xff, 0x93, 0xc9, 0xff,
  0xff, 0x97, 0xe9, 0xff, 0xff, 0x93, 0xc9, 0xff, 0xff, 0x93, 0xc9, 0xff, 0xff, 0xd8, 0x1b, 0xff,
  0xff, 0xcc, 0x33, 0xff, 0xff, 0xe3, 0xc7, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xfc, 0x3f, 0xff
};

// 'Turbo', 32x32px
const unsigned char Turbo[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xe3, 0xc0, 0x00, 0x00,
  0xc0, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0xff, 0xfc, 0xc0, 0xff, 0xff, 0xfc, 0xe3, 0xff, 0xff, 0xfc,
  0xe7, 0xff, 0xff, 0xfc, 0xcf, 0xff, 0xff, 0xfc, 0xcf, 0xf8, 0x00, 0x00, 0x9f, 0xc0, 0x00, 0x00,
  0x9f, 0x81, 0x1f, 0x8c, 0x3f, 0x13, 0x0f, 0xcc, 0x3f, 0x10, 0x0f, 0xcf, 0x3f, 0x00, 0x4f, 0xcf,
  0x3f, 0x06, 0x67, 0xcf, 0x3f, 0x66, 0x07, 0xcf, 0x3f, 0x20, 0x0f, 0xcf, 0x3f, 0x00, 0xcf, 0xcf,
  0x3f, 0x8c, 0x8f, 0xcf, 0x9f, 0x80, 0x1f, 0x9f, 0x9f, 0xe0, 0x3f, 0x9f, 0xcf, 0xff, 0xff, 0x3f,
  0xc7, 0xff, 0xff, 0x3f, 0xe7, 0xff, 0xfe, 0x7f, 0xc1, 0xff, 0xfc, 0x3f, 0xc8, 0xff, 0xf1, 0x3f,
  0xc8, 0x3f, 0xc1, 0x3f, 0xc1, 0x00, 0x08, 0x3f, 0xe3, 0xc0, 0x3c, 0x7f, 0xff, 0xff, 0xff, 0xff


};
// 'exhaust', 32x32px
const unsigned char Exhaust[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xe3, 0xff, 0xc1, 0xc0, 0x1c, 0x1f,
  0xbf, 0x7f, 0xf7, 0xef, 0xa0, 0x82, 0x08, 0x2f, 0xae, 0xba, 0xeb, 0xaf, 0xae, 0xba, 0xeb, 0xaf,
  0xae, 0xba, 0xeb, 0xaf, 0xae, 0xba, 0xeb, 0xaf, 0xce, 0x38, 0xe3, 0x9f, 0xee, 0xba, 0xeb, 0xbf,
  0xee, 0xba, 0xeb, 0xbf, 0xee, 0xba, 0xeb, 0xbf, 0xee, 0xba, 0xeb, 0xbf, 0xef, 0x5d, 0x75, 0xdf,
  0xf7, 0x6e, 0xba, 0xef, 0xf7, 0x87, 0x5d, 0x77, 0xfb, 0xe3, 0x8e, 0x39, 0xfd, 0xff, 0xff, 0xfd,
  0xfe, 0x7f, 0xff, 0xfd, 0xff, 0x80, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};

void setup() {
  Serial.begin(9600);
  Serial.print(("Oih !"));

  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);

  tft.initSPI(320, 240);  // Init ST7789 240x320  // Use this initializer (uncomment) if using a 1.3" or 1.54" 240x240 240x320 TFT etc:
  tft.fillScreen(BLACK);
  tft.setRotation(0);
  tft.setFont(&FreeSansBoldOblique9pt7b);
  tft.setCursor(80, 100);
  tft.setTextSize(1);
  tft.println("T.I.S.M");

  delay(2000);

  tft.fillScreen(GREY);
  tft.invertDisplay(0);
  tft.setCursor(50, 210);
  tft.setTextSize(1);

  tft.fillRoundRect(2, 2, 60, 60, 5, BLACK);
  tft.fillRoundRect(90, 2, 60, 60, 5, BLACK);
  tft.fillRoundRect(178, 2, 60, 60, 5, BLACK);
  tft.fillRoundRect(2, 75, 60, 60, 5, BLACK);
  tft.fillRoundRect(90, 75, 60, 60, 5, BLACK);
  tft.fillRoundRect(178, 75, 60, 60, 5, BLACK);

  tft.drawBitmap(45, 200, Temp, 32, 32, GREY, AQUA);        // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
  tft.drawBitmap(47, 285, Oil, 32, 32, GREY, YELLOW);       // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
  tft.drawBitmap(170, 205, Turbo, 32, 32, GREY, BLUE);      // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
  tft.drawBitmap(170, 285, Exhaust, 32, 32, GREY, ORANGE);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)

  display_meter1();
  display_meter2();
  display_meter3();
  display_meter4();

  battery();
}

void glowplug() {
  Serial.println("Glowplug void");
  tft.drawBitmap(2, 2, GlowPlug, 60, 60, BLACK, ORANGE);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
}
void arrow() {
  tft.drawBitmap(90, 2, Arrow, 60, 60, BLACK, GREEN);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
}
void highbeam() {
  tft.drawBitmap(178, 2, HighBeam, 60, 60, BLACK, BLUE);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
}
void difflock() {
  tft.drawBitmap(2, 75, DiffLock, 60, 60, BLACK, DARKGREEN);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
}
void parkbrake() {
  tft.drawBitmap(90, 75, ParkBrake, 60, 60, BLACK, RED);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
}
void battery() {
  tft.drawBitmap(178, 75, Battery, 60, 60, BLACK, RED);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
}

void loop() {
  {
    int r1 = random(45, 150);  // *** here for testing meter displays
    int r2 = random(5, 15);
    int r3 = random(0, 75);
    int r4 = random(300, 900);
    int r5 = random(9, 14);

    float TempVal = r1;  // These are to be replaced by sensor values
    float OilVal = r3;
    float TurboVal = r2;
    float ExhaustVal = r4;
    float Voltage = r5;

    GlowpluG.update();
    if (GlowpluG.state() == HIGH) {
      Serial.println("glowplug");
      glowplug();
    } else tft.fillRoundRect(2, 2, 60, 60, 5, BLACK);

    ArroW.update();
    if (ArroW.state() == HIGH) {
      Serial.println("arrow");
      arrow();
    } else tft.fillRoundRect(90, 2, 60, 60, 5, BLACK);

    HighbeaM.update();
    if (HighbeaM.state() == HIGH) {
      Serial.println("Highbeam");
      highbeam();
    } else tft.fillRoundRect(178, 2, 60, 60, 5, BLACK);

    DifflocK.update();
    if (DifflocK.state() == HIGH) {
      Serial.println("Difflock");
      difflock();
    } else tft.fillRoundRect(2, 75, 60, 60, 5, BLACK);

    ParkbrakE.update();
    if (ParkbrakE.state() == HIGH) {
      Serial.println("parkebrake");
      parkbrake();
    } else tft.fillRoundRect(90, 75, 60, 60, 5, BLACK);

    BatterY.update();
    if (BatterY.state() == HIGH) {
      Serial.println("battery");
      battery();
    } else tft.drawBitmap(178, 75, Battery, 60, 60, BLACK, WHITE);  // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
    ;

    //battery();

    tft.setCursor(185, 100);
    tft.setFont();
    tft.setTextColor(ORANGE, BLACK);
    tft.setTextSize(2);
    tft.println(Voltage, 1);
    //tft.setTextSize(1);
    tft.setTextColor(ORANGE, GREY);
    tft.setCursor(51, 185);
    tft.print(TempVal, 0);

    tft.setCursor(173, 185);
    tft.println(TurboVal, 0);

    tft.setCursor(51, 274);
    tft.println(OilVal, 0);

    tft.setCursor(167, 274);
    tft.println(ExhaustVal, 0);


    // Set the the position, gap between meters, and inner radius of the meters
    int xpos = 0, ypos = 0, gap = 0, radius = 0;

    // Draw temp1
    xpos = 0, ypos = 160, gap = 0, radius = 60;                                          //sets size and position on screen
    xpos = gap + ringMeter1((int)TempVal, -10, 150, xpos, ypos, radius, 2, YELLOW2RED);  //0, 50 are range off meter ie 0-50 oilPSI

    // Draw temp2
    xpos = 120, ypos = 160, gap = 0, radius = 60;                                     //sets size and position on screen
    xpos = gap + ringMeter1((int)TurboVal, 0, 30, xpos, ypos, radius, 2, GREEN2RED);  //0, 120 are range off meter ie 0-120*c

    //Draw temp3
    xpos = 0, ypos = 250, gap = 0, radius = 60;                                     //sets size and position on screen
    xpos = gap + ringMeter1((int)OilVal, 0, 75, xpos, ypos, radius, 2, RED2GREEN);  //0, 750 are range off meter ie 0-750*c EGT Temp

    // Draw temp4
    xpos = 120, ypos = 250, gap = 0, radius = 60;                                        //sets size and position on screen
    xpos = gap + ringMeter1((int)ExhaustVal, 0, 900, xpos, ypos, radius, 2, GREEN2RED);  //0, 30 are range off meter ie 0-30psi boost*c
  }
}
// #########################################################################
//  Draw the meters on the screen, returns x coord of righthand side
// #########################################################################


int ringMeter1(int temp, int vmin, int vmax, int x, int y, int r, int thick, byte scheme) {
  x += r;
  y += r;  // Calculate coords of centre of ring

  int w = r / 4;  // Width of outer ring is 1/4 of radius

  int angle = 60;  // Half the sweep angle of meter (300 degrees)

  int text_colour = 0;  // To hold the text colour

  int v = map(temp, vmin, vmax, -angle, angle);  // Map the value to an angle v

  byte seg = 5;  // Segments are 5 degrees wide = 60 segments for 300 degrees - influences needle thicknes
  byte inc = 5;  // Draw segments every 5 degrees, increase to 10 for segmented ring

  // Draw colour blocks every inc degrees
  for (int i = -angle; i < angle; i += inc) {

    // Choose colour from scheme
    int colour = 0;
    switch (scheme) {
        /*   **You will appreciate this being here **
#define RED 0
#define GREEN 1
#define BLUE 2
#define BLUE2RED 3
#define GREEN2RED 4
#define RED2GREEN 5
#define YELLOW2RED 6
#define WHITE2BLUE 7
#define ST77XX_GREY 0x2104  // Dark grey 16 bit colour
*/
      case 0: colour = RED; break;    // Fixed colour
      case 1: colour = GREEN; break;  // Fixed colour
      case 2: colour = BLUE; break;
      case 3: colour = rainbow(map(i, -angle, angle, 0, 127)); break;   // Full spectrum BLUE2RED 0=BLUE 63=GREEN 127=RED
      case 4: colour = rainbow(map(i, -angle, angle, 63, 127)); break;  // GREEN2RED
      case 5: colour = rainbow(map(i, -angle, angle, 127, 63)); break;  // RED2GREEN
      case 6: colour = rainbow(map(i, -angle, angle, 90, 127)); break;  // YELLOW2RED
      case 7: colour = rainbow(map(i, -angle, angle, 40, 0)); break;    // WHITE2BLUE
      default: colour = WHITE; break;                                   // Fixed colour
    }

    // Calculate pair of coordinates for segment start
    float sx = cos((i - 90) * 0.0175);
    float sy = sin((i - 90) * 0.0175);

    uint16_t x0 = sx * (r - w) + x;
    uint16_t y0 = sy * (r - w) + y;
    uint16_t x1 = sx * r + x;
    uint16_t y1 = sy * r + y;

    // Calculate pair of coordinates for segment end
    float sx2 = cos((i + seg - 90) * 0.0175);
    float sy2 = sin((i + seg - 90) * 0.0175);

    int x2 = sx2 * (r - w) + x;
    int y2 = sy2 * (r - w) + y;
    int x3 = sx2 * r + x;
    int y3 = sy2 * r + y;
    // ****** Use this for needle display

    //if (i >= (v - inc) && (i < v)) {  // Fill in coloured segments with 2 triangles
    //tft.fillTriangle(x0, y0, x1, y1, x2, y2, colour);
    //tft.fillTriangle(x1, y1, x2, y2, x3, y3, colour);
    //text_colour = colour;  // Save the last colour drawn
    //}


    // *** Changes from a needle to a filled arc ***
    if (i < v) {  // Fill in coloured segments with 2 triangles
      tft.fillTriangle(x0, y0, x1, y1, x2, y2, colour);
      tft.fillTriangle(x1, y1, x2, y2, x3, y3, colour);
      text_colour = colour;  // Save the last colour drawn
    }


    else  // Fill in blank segments
    {

      tft.fillTriangle(x0, y0, x1, y1, x2, y2, BLACK);
      tft.fillTriangle(x1, y1, x2, y2, x3, y3, BLACK);
    }
  }



  return x + r;
}

// #########################################################################
// Return a 16 bit rainbow colour
// #########################################################################

unsigned int rainbow(byte value) {
  // Value is expected to be in range 0-127
  // The value is converted to a spectrum colour from 0 = blue through to 127 = red

  byte red = 0;    // Red is the top 5 bits of a 16 bit colour value
  byte green = 0;  // Green is the middle 6 bits
  byte blue = 0;   // Blue is the bottom 5 bits

  byte quadrant = value / 32;

  if (quadrant == 0) {
    blue = 31;
    green = 2 * (value % 32);
    red = 0;
  }
  if (quadrant == 1) {
    blue = 31 - (value % 32);
    green = 63;
    red = 0;
  }
  if (quadrant == 2) {
    blue = 0;
    green = 63;
    red = value % 32;
  }
  if (quadrant == 3) {
    blue = 0;
    green = 63 - 2 * (value % 32);
    red = 31;
  }
  return (red << 11) + (green << 5) + blue;
}

void display_meter1() {
  float start_angle = -2.6, end_angle = -0.62, last_value = -1, input_value = 0.00;
  int x = 60, y = 220, r = 62, scale = 0;  // Meter needle X,Y coordinates plus radius all in pixels, values are for a 320x240 screen

  // Now draw the meter using a two pixel line to emphasise it
  for (float i = start_angle; i < end_angle; i = i + 0.01) {
    tft.drawPixel(x + cos(i) * r, y + sin(i) * r, ILI9341_WHITE);  // center point is (x,y)
    tft.drawPixel(x + cos(i) * r * 1.01, y + sin(i) * r * 1.01, ILI9341_WHITE);
  }
  //  0 = start_angle
  // 10 = end_angle
  // per-unit step = start_angle + (end_angle-start_angle)*major_graduations) * value to be displayed
  // Now draw the graduations and scale
  for (float i = start_angle; i < end_angle; i = i + (end_angle - start_angle) * 0.18)  //major_graduations)
  {
    tft.drawLine(x + cos(i) * r, y + sin(i) * r, x + cos(i) * r * 1.1, y + sin(i) * r * 1.1, ILI9341_WHITE);
    tft.setCursor(x + cos(i) * r * 1.16 - 3, y + sin(i) * r * 1.16);
    tft.setTextSize(0);
    //tft.println(scale*10,0);
    scale++;
  }
}
void display_meter2() {
  float start_angle = -2.6, end_angle = -0.62, last_value = -1, input_value = 0.00;
  int x = 180, y = 220, r = 62, scale = 0;  // Meter needle X,Y coordinates plus radius all in pixels, values are for a 320x240 screen

  // Now draw the meter using a two pixel line to emphasise it
  for (float i = start_angle; i < end_angle; i = i + 0.01) {
    tft.drawPixel(x + cos(i) * r, y + sin(i) * r, ILI9341_WHITE);  // center point is (x,y)
    tft.drawPixel(x + cos(i) * r * 1.01, y + sin(i) * r * 1.01, ILI9341_WHITE);
  }
  //  0 = start_angle
  // 10 = end_angle
  // per-unit step = start_angle + (end_angle-start_angle)*major_graduations) * value to be displayed
  // Now draw the graduations and scale
  for (float i = start_angle; i < end_angle; i = i + (end_angle - start_angle) * 0.18)  //major_graduations)
  {
    tft.drawLine(x + cos(i) * r, y + sin(i) * r, x + cos(i) * r * 1.1, y + sin(i) * r * 1.1, ILI9341_WHITE);
    tft.setCursor(x + cos(i) * r * 1.16 - 3, y + sin(i) * r * 1.16);
    tft.setTextSize(0);
    //tft.println(scale*10,0);
    scale++;
  }
}
void display_meter3() {
  float start_angle = -2.6, end_angle = -0.62, last_value = -1, input_value = 0.00;
  int x = 60, y = 310, r = 62, scale = 0;  // Meter needle X,Y coordinates plus radius all in pixels, values are for a 320x240 screen

  // Now draw the meter using a two pixel line to emphasise it
  for (float i = start_angle; i < end_angle; i = i + 0.01) {
    tft.drawPixel(x + cos(i) * r, y + sin(i) * r, ILI9341_WHITE);  // center point is (x,y)
    tft.drawPixel(x + cos(i) * r * 1.01, y + sin(i) * r * 1.01, ILI9341_WHITE);
  }
  //  0 = start_angle
  // 10 = end_angle
  // per-unit step = start_angle + (end_angle-start_angle)*major_graduations) * value to be displayed
  // Now draw the graduations and scale
  for (float i = start_angle; i < end_angle; i = i + (end_angle - start_angle) * 0.18)  //major_graduations)
  {
    tft.drawLine(x + cos(i) * r, y + sin(i) * r, x + cos(i) * r * 1.1, y + sin(i) * r * 1.1, ILI9341_WHITE);
    tft.setCursor(x + cos(i) * r * 1.16 - 3, y + sin(i) * r * 1.16);
    tft.setTextSize(0);
    //tft.println(scale*10,0);
    scale++;
  }
}
void display_meter4() {
  float start_angle = -2.6, end_angle = -0.62, last_value = -1, input_value = 0.00;
  int x = 180, y = 310, r = 62, scale = 0;  // Meter needle X,Y coordinates plus radius all in pixels, values are for a 320x240 screen

  // Now draw the meter using a two pixel line to emphasise it
  for (float i = start_angle; i < end_angle; i = i + 0.01) {
    tft.drawPixel(x + cos(i) * r, y + sin(i) * r, ILI9341_WHITE);  // center point is (x,y)
    tft.drawPixel(x + cos(i) * r * 1.01, y + sin(i) * r * 1.01, ILI9341_WHITE);
  }
  //  0 = start_angle
  // 10 = end_angle
  // per-unit step = start_angle + (end_angle-start_angle)*major_graduations) * value to be displayed
  // Now draw the graduations and scale
  for (float i = start_angle; i < end_angle; i = i + (end_angle - start_angle) * 0.18)  //major_graduations)
  {
    tft.drawLine(x + cos(i) * r, y + sin(i) * r, x + cos(i) * r * 1.1, y + sin(i) * r * 1.1, ILI9341_WHITE);
    tft.setCursor(x + cos(i) * r * 1.16 - 3, y + sin(i) * r * 1.16);
    tft.setTextSize(0);
    //tft.println(scale*10,0);
    scale++;
  }
}

You need to either clear the area before you update the text or use a string formatter like sprintf(buffer, ā€œ%03dā€, myValue); this will add leading zeros to your number. Make sure buffer is big enough for 4 characters because it also needs a terminating character at the end.

2 Likes

Typical method is to save the previous value, then when the value changes, display the previous value with the text color set to the background color, then display the new value with the text set to the desired text color.

Generally better to only update the value on the display when it changes, constantly rewriting the same value can cause flicker, and slows down the code.

4 Likes

Using the default font in the Adafruit GFX library, with the background color specified in the setFontColor() function, you should be able to use leading spaces. This will only work with the default font, the background color is ignored on all other fonts.

The Adafruit_GFX library also inherits from the Print library so if you use setCursor(x,y) and the printf("%3d", value); Assuming you can use printf that is...

Otherwise just clearing that section before you update the text would be the better approach.

Doesnt look like the LIL9341 has "printf" or "sprintf"

I am going to convert this over to a Teensy4 with a 4" 480,320 tft using ST7796 lib. So maybe it will work with it

The teensy board package supports printf, so that should work if the ST7796 library you use inherits from print. You may run into the problem of the fonts being transparent - the previous characters are not overwritten, but instead remain on the screen with the new characters merged with them. Also be careful of proportional spaced fonts.

Yeah, I am hoping that Teensy will solve a few problems.

Getting the proportions and spacing is tricky, bit of a trial and error.

I am hoping to use customs ( so it looks nicer ) so will probably have to do "printfillrect" and over write...although it will prob flicker

No, it doesn't, even on Teensy, but don't worry:

The printf() function isn't part of the GFX library but it will be inherited from the boards package if available. On, say, Uno, the board package doesn't support printf(), so the GFX library won't have it either. On Teensy, if the boards package has printf() then the GFX library will also inherit that function.

The sprintf() function is different. it's available on most boards packages, including Uno, but it's not an inheritable so can't be directly used by any library. sprintf() prints to a string variable (a null-terminated character array). It's a 2-step process: you print the value to the string, then you print that string to the display using the .print() function.

But there may be another problem: even on Teensy, .printf() and sprintf() may not support printing float/double variables. You may need to use the dtostrf() function for that.

I'm using a Mega2560 and 3.5" LCD, so some different libraries to yours, but I hope I can help with the method of blanking out the extra digit.

I am using a very large "7 segment" font that has only digits, not even a space.
I over-wrote any undesired leading digit with a black digit 8, then printed the desired double-digits shifted to the right some pixels (the size of a digit) so the right-most digit always stays in the same position.
I only over-write the third digit if the new value is not three digits.
I did not worry about doing the same for single digit values, a leading zero is OK.
I tried to minimise the amount of drawing to the LCD to improve loop rate and minimise flickering.

The integer print command format is: printNumI( Int , X , Y , length , 'filler' , {base 8|10|16} ) and the base is optional, default is 10.
Code snippet only - not the complete sketch.

#include <UTFT.h>
UTFT          myGLCD(ILI9481, 38, 39, 40, 41);
UTFT_Geometry geo(&myGLCD);
.
.
.

    myGLCD.setFont(font7L);
    myGLCD.setBackColor(VGA_BLACK);
    if (vspeed <= 99)
        {
        // Print a black digit 8 where a rogue digit would be
        // because this large font only has digits, no space char
        if (last_vspeed > 99)
            {
            myGLCD.setColor(VGA_BLACK);
            myGLCD.printNumI(8, speed_x, speed_y, 1, '0');
            }
        // Print the 2 digit speed
        myGLCD.setColor(text_colour1);
        myGLCD.printNumI(vspeed, speed_x + 96, speed_y, 2, '0');
        }
    else
        {
        // Print the 3 digit speed
        myGLCD.setColor(text_colour1);
        myGLCD.printNumI(vspeed, speed_x, speed_y, 3, '0');
        }

You could even throw in a
if (vspeed != last_vspeed )
around the whole thing to further reduce time wasted drawing to LCD, but I seem to remember in my case the loop time and update rate wasnt affected too much anyway.

I think this is mostly what others have been saying, hope it helps.

That can quite easily be changed though. The only reason for it is that if the font doesn't have a fixed width, this might cause some problem, so within the library there is a test for the default font, and if it isn't the background color is ignored.
from Adafruit_GFX.cpp

/**************************************************************************/
/*!
   @brief   Draw a single character
    @param    x   Bottom left corner x coordinate
    @param    y   Bottom left corner y coordinate
    @param    c   The 8-bit font-indexed character (likely ascii)
    @param    color 16-bit 5-6-5 Color to draw chraracter with
    @param    bg 16-bit 5-6-5 Color to fill background with (if same as color,
   no background)
    @param    size_x  Font magnification level in X-axis, 1 is 'original' size
    @param    size_y  Font magnification level in Y-axis, 1 is 'original' size
*/
/**************************************************************************/
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
                            uint16_t color, uint16_t bg, uint8_t size_x,
                            uint8_t size_y) {

  if (!gfxFont) { // 'Classic' built-in font

    if ((x >= _width) ||              // Clip right
        (y >= _height) ||             // Clip bottom
        ((x + 6 * size_x - 1) < 0) || // Clip left
        ((y + 8 * size_y - 1) < 0))   // Clip top
      return;

    if (!_cp437 && (c >= 176))
      c++; // Handle 'classic' charset behavior

    startWrite();
    for (int8_t i = 0; i < 5; i++) { // Char bitmap = 5 columns
      uint8_t line = pgm_read_byte(&font[c * 5 + i]);
      for (int8_t j = 0; j < 8; j++, line >>= 1) {
        if (line & 1) {
          if (size_x == 1 && size_y == 1)
            writePixel(x + i, y + j, color);
          else
            writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y,
                          color);
        } else if (bg != color) {
          if (size_x == 1 && size_y == 1)
            writePixel(x + i, y + j, bg);
          else
            writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y, bg);
        }
      }
    }
    if (bg != color) { // If opaque, draw vertical line for last column
      if (size_x == 1 && size_y == 1)
        writeFastVLine(x + 5, y, 8, bg);
      else
        writeFillRect(x + 5 * size_x, y, size_x, 8 * size_y, bg);
    }
    endWrite();

  } else { // Custom font

    // Character is assumed previously filtered by write() to eliminate
    // newlines, returns, non-printable characters, etc.  Calling
    // drawChar() directly with 'bad' characters of font may cause mayhem!

    c -= (uint8_t)pgm_read_byte(&gfxFont->first);
    GFXglyph *glyph = pgm_read_glyph_ptr(gfxFont, c);
    uint8_t *bitmap = pgm_read_bitmap_ptr(gfxFont);

    uint16_t bo = pgm_read_word(&glyph->bitmapOffset);
    uint8_t w = pgm_read_byte(&glyph->width), h = pgm_read_byte(&glyph->height);
    int8_t xo = pgm_read_byte(&glyph->xOffset),
           yo = pgm_read_byte(&glyph->yOffset);
    uint8_t xx, yy, bits = 0, bit = 0;
    int16_t xo16 = 0, yo16 = 0;

    if (size_x > 1 || size_y > 1) {
      xo16 = xo;
      yo16 = yo;
    }

    // Todo: Add character clipping here

    // NOTE: THERE IS NO 'BACKGROUND' COLOR OPTION ON CUSTOM FONTS.
    // THIS IS ON PURPOSE AND BY DESIGN.  The background color feature
    // has typically been used with the 'classic' font to overwrite old
    // screen contents with new data.  This ONLY works because the
    // characters are a uniform size; it's not a sensible thing to do with
    // proportionally-spaced fonts with glyphs of varying sizes (and that
    // may overlap).  To replace previously-drawn text when using a custom
    // font, use the getTextBounds() function to determine the smallest
    // rectangle encompassing a string, erase the area with fillRect(),
    // then draw new text.  This WILL infortunately 'blink' the text, but
    // is unavoidable.  Drawing 'background' pixels will NOT fix this,
    // only creates a new set of problems.  Have an idea to work around
    // this (a canvas object type for MCUs that can afford the RAM and
    // displays supporting setAddrWindow() and pushColors()), but haven't
    // implemented this yet.

    startWrite();
    for (yy = 0; yy < h; yy++) {
      for (xx = 0; xx < w; xx++) {
        if (!(bit++ & 7)) {
          bits = pgm_read_byte(&bitmap[bo++]);
        }
        if (bits & 0x80) {
          if (size_x == 1 && size_y == 1) {
            writePixel(x + xo + xx, y + yo + yy, color);
          } else {
            writeFillRect(x + (xo16 + xx) * size_x, y + (yo16 + yy) * size_y,
                          size_x, size_y, color);
          }
        }
        bits <<= 1;
      }
    }
    endWrite();

  } // End classic vs custom font

so as long if your font isn't proportionally-spaced, no issues are expected (even when it is, it may still do the trick for you)
In that case you could just print a space before the value if it is smaller than 100, but in some ways a filled rectangle makes just as much sense, since in the end, that is what printing a space is.
On second thought, you could also add a leading '0' but that might not be the look you want.

Of course....then you just format the string

I think that could work....

You did not post all the code so I presume "value" is float
Change value from float to int.

The try the first method I suggested. When you print a value, save that value to a variable. Whenever you want to print a new value, first print the old value with the text color set to the background color, and second print the new value with the desired text color. Printing the old value in the background color erases that value from the display, and is a bit quicker than writing an entire rectangular area.

Having the previous value saved in a variable also lets you compare with the new value, and only print to the display when the value has changed.

I did post the full code

Ok sorry found it.

Yes, a print only if value changes is a good option, considering that the values in real life change very slowly....I was also looking at doing an average for each value, which slows down the refresh rate, but wont help the initial problem.

Ultimately, I am asking for the impossible. But it is good to share ideas