#include "Free_Fonts.h"
#include <TFT_eSPI.h>
#include <SPI.h> // this is needed for display
unsigned long drawTime = 0;
// 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);
}
void loop()
{
int xpos = 0;
int ypos = 0;
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Select different fonts to draw on screen using the print class
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
tft.fillScreen(TFT_BLACK); // Clear screen to navy background
// header("Draw free fonts using print class");
// For comaptibility with Adafruit_GFX library the text background is not plotted when using the print class
// even if we specify it.
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_RED, TFT_BLACK);
// tft.setTextDatum(TC_DATUM); // Centre text on x,y position
xpos =0; //tft.width() / 2; // Half the screen width
ypos = 0;
tft.setFreeFont(FM12); // Select the font
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF); // Draw the text string in the selected GFX free font
ypos += tft.fontHeight(GFXFF); // Get the font height and move ypos down
tft.setFreeFont(FMB12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FMO12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FMBO12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSS12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSSB12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSSO12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSSBO12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FS12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSI12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF2);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF6);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
delay(1000);
xpos =0; //tft.width() / 2; // Half the screen width
ypos = 0;
tft.fillScreen(TFT_BLACK);
tft.setFreeFont(FMBO12); // Select the font
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF); // Draw the text string in the selected GFX free font
ypos += tft.fontHeight(GFXFF); // Get the font height and move ypos down
tft.setFreeFont(FSSO12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSSBO12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSB12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FSBI12);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF10);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF14);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF18);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF22);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF26);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF30);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
tft.setFreeFont(FF34);
tft.drawString("AB 07.03.2024", xpos, ypos, GFXFF);
ypos += tft.fontHeight(GFXFF);
delay(1000);
// Set text padding to 120 pixels wide area to over-write old values on screen
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
tft.setCursor(xpos, ypos); // Set cursor near top left corner of screen
tft.setTextFont(GLCD); // Select the orginal small GLCD font by using NULL or GLCD
// Move cursor down a line
tft.print("Original GLCD font"); // Print the font name onto the TFT screen
tft.println();
tft.setFreeFont(FSB9); // Select Free Serif 9 point font, could use:
// tft.setFreeFont(&FreeSerif9pt7b);
tft.println(); // Free fonts plot with the baseline (imaginary line the letter A would sit on)
// as the datum, so we must move the cursor down a line from the 0,0 position
tft.print("Serif Bold 9pt"); // Print the font name onto the TFT screen
tft.setFreeFont(FM12); // Select Free Serif 12 point font
tft.println(); // Move cursor down a line
tft.print("Serif Bold 12pt"); // Print the font name onto the TFT screen
tft.setFreeFont(FMB18); // Select Free Serif 12 point font
tft.println(); // Move cursor down a line
tft.print("Serif Bold 18pt"); // Print the font name onto the TFT screen
tft.setFreeFont(FSB24); // Select Free Serif 24 point font
tft.println(); // Move cursor down a line
tft.print("Serif Bold 24pt"); // Print the font name onto the TFT screen
tft.setTextPadding(120);
for (int i = 0; i <= 20; i++) {
tft.drawFloat(i / 10.0, 1, xpos, ypos, GFXFF);
delay (10);
}
}
// Print the header for a display screen
Loading
ili9341-cap-touch
ili9341-cap-touch