#include "Free_Fonts.h"
#include <TFT_eSPI.h>
#include <SPI.h> // this is needed for display
// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 15
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_SCLK 18
float dispTemp = 22.3;
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library with default width and height
void setup(void) {
tft.begin();
tft.setRotation(0);
themeClockTFT(dispTemp, "TEMP", "`C", "88.8", "temp", 1);
}
void loop() {
int val = analogRead(D13);
print("Read Value: ");
println(val);
delay(1000);
}
void themeClockTFT(float value, const String& lable, const String& units, const String& valueSample, const String& valueType, unsigned int accuracy) {
int xpos = 10;
int ypos = 45;
int yPad = 0;
int padding = tft.textWidth(String(value, accuracy), FONT8);
tft.setTextDatum(TL_DATUM);
tft.drawString(lable, xpos, ypos, FONT4);
tft.setTextDatum(TR_DATUM);
tft.drawString(units, 240 - xpos, ypos, FONT4);
tft.setTextDatum(TL_DATUM);
tft.setTextPadding(padding);
ypos += tft.fontHeight(FONT8) / 2 + yPad;
tft.drawFloat(value, accuracy, (240 - padding) / 2, ypos, FONT8);
tft.setTextPadding(0);
}
Loading
ili9341-cap-touch
ili9341-cap-touch