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++;
}
}