mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-06 22:24:44 +02:00
Update examples
Now compatible with ESP8266
This commit is contained in:
@@ -2,20 +2,32 @@
|
||||
//devised by the British mathematician John Horton Conway in 1970.
|
||||
// https://en.wikipedia.org/wiki/Conway's_Game_of_Life
|
||||
|
||||
// See license at end of file.
|
||||
|
||||
// Adapted by Bodmer
|
||||
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
#include <SPI.h>
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
#define GRIDX 32
|
||||
#define GRIDY 24
|
||||
#define CELLXY 5
|
||||
// Maximum number of generations until the screen is refreshed
|
||||
#define MAX_GEN_COUNT 500
|
||||
|
||||
#define GEN_DELAY 0
|
||||
// The ESP8266 has plenty of memory so we can create a large array
|
||||
// 2 x 2 pixel cells, array size = 5120 bytes per array, runs fast
|
||||
#define GRIDX 80
|
||||
#define GRIDY 64
|
||||
#define CELLXY 2
|
||||
|
||||
//Current grid
|
||||
// 1 x 1 pixel cells, array size = 20480 bytes per array
|
||||
//#define GRIDX 160
|
||||
//#define GRIDY 128
|
||||
//#define CELLXY 1
|
||||
|
||||
#define GEN_DELAY 10 // Set a delay between each generation to slow things down
|
||||
|
||||
//Current grid and newgrid arrays are needed
|
||||
uint8_t grid[GRIDX][GRIDY];
|
||||
|
||||
//The new grid for the next generation
|
||||
@@ -55,7 +67,7 @@ void loop() {
|
||||
|
||||
initGrid();
|
||||
|
||||
genCount = 300;
|
||||
genCount = MAX_GEN_COUNT;
|
||||
|
||||
drawGrid();
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
||||
#include <avr/pgmspace.h>
|
||||
#include <pgmspace.h>
|
||||
|
||||
// Icon width and height
|
||||
const uint16_t alertWidth = 32;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
||||
#include <avr/pgmspace.h>
|
||||
#include <pgmspace.h>
|
||||
|
||||
// Icon width and height
|
||||
const uint16_t closeWidth = 32;
|
||||
|
@@ -8,6 +8,7 @@
|
||||
// Icons are stored in tabs, e.g. Alert.h etc
|
||||
// more than one icon can be in a header file.
|
||||
|
||||
// Original sketch header follow:
|
||||
/*
|
||||
This sketch demonstrates loading images from arrays stored in program (FLASH) memory.
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// We need this header file to use FLASH as storage with PROGMEM directive:
|
||||
#include <avr/pgmspace.h>
|
||||
#include <pgmspace.h>
|
||||
|
||||
// Icon width and height
|
||||
const uint16_t infoWidth = 32;
|
||||
|
@@ -16,7 +16,7 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
|
||||
int16_t h = 128;
|
||||
int16_t w = 160;
|
||||
|
||||
int dly = 5;
|
||||
int dly = 10;
|
||||
|
||||
int16_t paddle_h = 25;
|
||||
int16_t paddle_w = 2;
|
||||
@@ -98,7 +98,7 @@ void initgame() {
|
||||
tft.fillRect(0,h-26,w,h-1,BLACK);
|
||||
|
||||
tft.setTextDatum(TC_DATUM);
|
||||
tft.setTextColor(WHITE,GREY);
|
||||
tft.setTextColor(WHITE);
|
||||
tft.drawString("TFT_eSPI example", w/2, h-26 , 2);
|
||||
}
|
||||
|
||||
|
@@ -1,41 +1,13 @@
|
||||
/*
|
||||
Display all the fonts.
|
||||
Display all the fast rendering fonts.
|
||||
|
||||
This sketch uses the GLCD (font 1) and fonts 2, 4, 6, 7, 8
|
||||
|
||||
Make sure all the required fonts are loaded by editting the
|
||||
User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
If using an UNO or Mega (ATmega328 or ATmega2560 processor) then for best
|
||||
performance use the F_AS_T option found in the User_Setup.h file in the
|
||||
TFT_eSPI library folder.
|
||||
|
||||
The library uses the hardware SPI pins only:
|
||||
For UNO, Nano, Micro Pro ATmega328 based processors
|
||||
MOSI = pin 11, SCK = pin 13
|
||||
For Mega:
|
||||
MOSI = pin 51, SCK = pin 52
|
||||
|
||||
The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST)
|
||||
signal lines to the TFT must also be defined in the library User_Setup.h file.
|
||||
|
||||
Sugested TFT connections for UNO and Atmega328 based boards
|
||||
sclk 13 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 11 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 10 // Chip select for TFT display
|
||||
dc 9 // Data/command line
|
||||
rst 7 // Reset, you could connect this to the Arduino reset pin
|
||||
|
||||
Suggested TFT connections for the MEGA and ATmega2560 based boards
|
||||
sclk 52 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 51 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 47 // TFT chip select line
|
||||
dc 48 // TFT data/command line
|
||||
rst 44 // you could alternatively connect this to the Arduino reset
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
|
@@ -143,7 +143,7 @@ void analogMeter()
|
||||
}
|
||||
|
||||
tft.drawString("%RH", M_SIZE*(3 + 230 - 40), M_SIZE*(119 - 20), 2); // Units at bottom right
|
||||
//tft.drawCentreString("%RH", M_SIZE*120, M_SIZE*75, 4); // Comment out to avoid font 4
|
||||
tft.drawCentreString("%RH", M_SIZE*120, M_SIZE*75, 4); // Comment out to avoid font 4
|
||||
tft.drawRect(1, M_SIZE*3, M_SIZE*236, M_SIZE*126, ST7735_BLACK); // Draw bezel line
|
||||
|
||||
plotNeedle(0, 0); // Put meter needle at 0
|
||||
@@ -187,7 +187,7 @@ void plotNeedle(int value, byte ms_delay)
|
||||
|
||||
// Re-plot text under needle
|
||||
tft.setTextColor(ST7735_BLACK, ST7735_WHITE);
|
||||
//tft.drawCentreString("%RH", M_SIZE*120, M_SIZE*75, 4); // // Comment out to avoid font 4
|
||||
tft.drawCentreString("%RH", M_SIZE*120, M_SIZE*75, 4); // // Comment out to avoid font 4
|
||||
|
||||
// Store new needle end coords for next erase
|
||||
ltx = tx;
|
||||
|
@@ -6,39 +6,14 @@
|
||||
|
||||
Needs fonts 2, 4, 6, 7 and 8
|
||||
|
||||
Make sure all the required fonts are loaded by editting the
|
||||
User_Setup.h file in the TFT_eSPI library folder.
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
If using an UNO or Mega (ATmega328 or ATmega2560 processor) then for best
|
||||
performance use the F_AS_T option found in the User_Setup.h file in the
|
||||
TFT_eSPI library folder.
|
||||
|
||||
The library uses the hardware SPI pins only:
|
||||
For UNO, Nano, Micro Pro ATmega328 based processors
|
||||
MOSI = pin 11, SCK = pin 13
|
||||
For Mega:
|
||||
MOSI = pin 51, SCK = pin 52
|
||||
|
||||
The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST)
|
||||
signal lines to the TFT must also be defined in the library User_Setup.h file.
|
||||
|
||||
Sugested TFT connections for UNO and Atmega328 based boards
|
||||
sclk 13 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 11 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 10 // Chip select for TFT display
|
||||
dc 9 // Data/command line
|
||||
rst 7 // Reset, you could connect this to the Arduino reset pin
|
||||
|
||||
Suggested TFT connections for the MEGA and ATmega2560 based boards
|
||||
sclk 52 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 51 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 47 // TFT chip select line
|
||||
dc 48 // TFT data/command line
|
||||
rst 44 // you could alternatively connect this to the Arduino reset
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
@@ -108,7 +83,7 @@ void loop() {
|
||||
drawTime = millis();
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
tft.drawNumber(i, 0, 0, 6);
|
||||
yield(); tft.drawNumber(i, 0, 0, 6);
|
||||
}
|
||||
|
||||
drawTime = millis() - drawTime;
|
||||
@@ -123,7 +98,7 @@ void loop() {
|
||||
drawTime = millis();
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
tft.drawNumber(i, 0, 0, 7);
|
||||
yield(); tft.drawNumber(i, 0, 0, 7);
|
||||
}
|
||||
|
||||
drawTime = millis() - drawTime;
|
||||
@@ -138,7 +113,7 @@ void loop() {
|
||||
drawTime = millis();
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
tft.drawNumber(i, 0, 0, 8);
|
||||
yield(); tft.drawNumber(i, 0, 0, 8);
|
||||
}
|
||||
|
||||
drawTime = millis() - drawTime;
|
||||
|
@@ -95,7 +95,7 @@ void loop() {
|
||||
if (omm != mm) { // Only redraw every minute to minimise flicker
|
||||
// Uncomment ONE of the next 2 lines, using the ghost image demonstrates text overlay as time is drawn over it
|
||||
tft.setTextColor(0x39C4, ST7735_BLACK); // Leave a 7 segment ghost image, comment out next line!
|
||||
//tft.setTextColor(ST7735_BLACK, ST7735_BLACK); // Set font colour to back to wipe image
|
||||
//tft.setTextColor(ST7735_BLACK, ST7735_BLACK); // Set font colour to black to wipe image
|
||||
// Font 7 is to show a pseudo 7 segment display.
|
||||
// Font 7 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : .
|
||||
tft.drawString("88:88",xpos,ypos,7); // Overwrite the text to clear it
|
||||
@@ -118,7 +118,7 @@ void loop() {
|
||||
else {
|
||||
tft.drawChar(':',xcolon,ypos,7);
|
||||
colour = random(0xFFFF);
|
||||
// Erase the text with a rectangle
|
||||
// Erase the old text with a rectangle, the disadvantage of this method is increased display flicker
|
||||
tft.fillRect (0, 64, 160, 20, ST7735_BLACK);
|
||||
tft.setTextColor(colour);
|
||||
tft.drawRightString("Colour",75,64,4); // Right justified string drawing to x position 75
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
An example analogue clock using a TFT LCD screen to show the time
|
||||
use of some of the drawing commands with the ST7735 library.
|
||||
|
||||
For a more accurate clock, it would be better to use the RTClib library.
|
||||
But this is just a demo.
|
||||
|
||||
This examples uses the hardware SPI only. Non-hardware SPI
|
||||
is just too slow (~8 times slower!)
|
||||
Uses compile time to set the time so a reset will start with the compile time again
|
||||
|
||||
Gilchrist 6/2/2014 1.0
|
||||
Updated by Bodmer
|
||||
@@ -21,7 +21,7 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
|
||||
float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0; // Saved H, M, S x & y multipliers
|
||||
float sdeg=0, mdeg=0, hdeg=0;
|
||||
uint16_t osx=64, osy=64, omx=64, omy=64, ohx=64, ohy=64; // Saved H, M, S x & y coords
|
||||
uint16_t x0=0, x1=0, y0=0, y1=0;
|
||||
uint16_t x0=0, x1=0, yy0=0, yy1=0;
|
||||
uint32_t targetTime = 0; // for next 1 second timeout
|
||||
|
||||
static uint8_t conv2d(const char* p) {
|
||||
@@ -50,11 +50,11 @@ void setup(void) {
|
||||
sx = cos((i-90)*0.0174532925);
|
||||
sy = sin((i-90)*0.0174532925);
|
||||
x0 = sx*57+64;
|
||||
y0 = sy*57+64;
|
||||
yy0 = sy*57+64;
|
||||
x1 = sx*50+64;
|
||||
y1 = sy*50+64;
|
||||
yy1 = sy*50+64;
|
||||
|
||||
tft.drawLine(x0, y0, x1, y1, ST7735_BLUE);
|
||||
tft.drawLine(x0, yy0, x1, yy1, ST7735_BLUE);
|
||||
}
|
||||
|
||||
// Draw 60 dots
|
||||
@@ -62,13 +62,13 @@ void setup(void) {
|
||||
sx = cos((i-90)*0.0174532925);
|
||||
sy = sin((i-90)*0.0174532925);
|
||||
x0 = sx*53+64;
|
||||
y0 = sy*53+64;
|
||||
yy0 = sy*53+64;
|
||||
|
||||
tft.drawPixel(x0, y0, ST7735_BLUE);
|
||||
if(i==0 || i==180) tft.fillCircle(x0, y0, 1, ST7735_CYAN);
|
||||
if(i==0 || i==180) tft.fillCircle(x0+1, y0, 1, ST7735_CYAN);
|
||||
if(i==90 || i==270) tft.fillCircle(x0, y0, 1, ST7735_CYAN);
|
||||
if(i==90 || i==270) tft.fillCircle(x0+1, y0, 1, ST7735_CYAN);
|
||||
tft.drawPixel(x0, yy0, ST7735_BLUE);
|
||||
if(i==0 || i==180) tft.fillCircle(x0, yy0, 1, ST7735_CYAN);
|
||||
if(i==0 || i==180) tft.fillCircle(x0+1, yy0, 1, ST7735_CYAN);
|
||||
if(i==90 || i==270) tft.fillCircle(x0, yy0, 1, ST7735_CYAN);
|
||||
if(i==90 || i==270) tft.fillCircle(x0+1, yy0, 1, ST7735_CYAN);
|
||||
}
|
||||
|
||||
tft.fillCircle(65, 65, 3, ST7735_RED);
|
||||
|
@@ -20,7 +20,7 @@ void loop() {
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Draw some random circles
|
||||
// Draw some random filled elipses
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
int rx = random(40);
|
||||
@@ -33,6 +33,7 @@ void loop() {
|
||||
delay(2000);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Draw some random outline elipses
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
int rx = random(40);
|
||||
|
@@ -3,35 +3,14 @@
|
||||
|
||||
This sketch used font 2, 4, 7
|
||||
|
||||
Make sure all the required fonts are loaded by editting the
|
||||
User_Setup.h file in the TFT_eSPI library folder.
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
The library uses the hardware SPI pins only:
|
||||
For UNO, Nano, Micro Pro ATmega328 based processors
|
||||
MOSI = pin 11, SCK = pin 13
|
||||
For Mega:
|
||||
MOSI = pin 51, SCK = pin 52
|
||||
|
||||
The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST)
|
||||
signal lines to the TFT must also be defined in the library User_Setup.h file.
|
||||
|
||||
Sugested TFT connections for UNO and Atmega328 based boards
|
||||
sclk 13 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 11 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 10 // Chip select for TFT display
|
||||
dc 9 // Data/command line
|
||||
rst 7 // Reset, you could connect this to the Arduino reset pin
|
||||
|
||||
Suggested TFT connections for the MEGA and ATmega2560 based boards
|
||||
sclk 52 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 51 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 47 // TFT chip select line
|
||||
dc 48 // TFT data/command line
|
||||
rst 44 // you could alternatively connect this to the Arduino reset
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
@@ -83,7 +62,8 @@ void loop() {
|
||||
tft.print("Float = "); tft.println(fnumber); // Print floating point number
|
||||
tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
|
||||
tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal
|
||||
while(1);
|
||||
|
||||
while(1) yield(); // We must yield() to stop a watchdog timeout.
|
||||
}
|
||||
|
||||
|
||||
|
@@ -2,27 +2,15 @@
|
||||
An example showing rainbow colours on a 1.8" TFT LCD screen
|
||||
and to show a basic example of font use.
|
||||
|
||||
This examples uses the hardware SPI only. Non-hardware SPI
|
||||
is just too slow (~8 times slower!)
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
Updated by Bodmer
|
||||
|
||||
Colours:
|
||||
|
||||
code color
|
||||
0x0000 Black
|
||||
0xFFFF White
|
||||
0xBDF7 Light Gray
|
||||
0x7BEF Dark Gray
|
||||
0xF800 Red
|
||||
0xFFE0 Yellow
|
||||
0xFBE0 Orange
|
||||
0x79E0 Brown
|
||||
0x7E0 Green
|
||||
0x7FF Cyan
|
||||
0x1F Blue
|
||||
0xF81F Pink
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
|
||||
@@ -49,6 +37,8 @@ void loop() {
|
||||
|
||||
if (targetTime < millis()) {
|
||||
targetTime = millis() + 10000;
|
||||
|
||||
// Colour changing state machine
|
||||
for (int i = 0; i < 160; i++) {
|
||||
tft.drawFastVLine(i, 0, tft.height(), colour);
|
||||
switch (state) {
|
||||
@@ -98,20 +88,26 @@ void loop() {
|
||||
colour = red << 11 | green << 5 | blue;
|
||||
}
|
||||
|
||||
// The standard ADAFruit font still works as berfore
|
||||
tft.setTextColor(ST7735_BLACK, ST7735_BLACK); // Note these fonts do not plot the background colour
|
||||
// The standard ADAFruit font still works as before
|
||||
tft.setTextColor(ST7735_BLACK);
|
||||
tft.setCursor (12, 5);
|
||||
tft.print("Original ADAfruit font!");
|
||||
|
||||
// The new larger fonts do not use the .setCursor call, coords are embedded
|
||||
tft.setTextColor(ST7735_BLACK, ST7735_BLACK); // Do not plot the background colour
|
||||
|
||||
// Overlay the black text on top of the rainbow plot (the advantage of not drawing the backgorund colour!)
|
||||
tft.drawCentreString("Font size 2", 80, 14, 2); // Draw text centre at position 80, 12 using font 2
|
||||
|
||||
//tft.drawCentreString("Font size 2",81,12,2); // Draw text centre at position 80, 12 using font 2
|
||||
|
||||
tft.drawCentreString("Font size 4", 80, 30, 4); // Draw text centre at position 80, 24 using font 4
|
||||
|
||||
tft.drawCentreString("12.34", 80, 54, 6); // Draw text centre at position 80, 24 using font 6
|
||||
|
||||
tft.drawCentreString("12.34 is in font size 6", 80, 92, 2); // Draw text centre at position 80, 90 using font 2
|
||||
// Note the x position is the top of the font!
|
||||
|
||||
// Note the x position is the top left of the font!
|
||||
|
||||
// draw a floating point number
|
||||
float pi = 3.14159; // Value to print
|
||||
|
@@ -1,38 +1,16 @@
|
||||
/*
|
||||
Adapted from the Adafruit and Xark's PDQ graphicstest sketch.
|
||||
|
||||
This sketch uses the GLCD font only. Disable other fonts to make
|
||||
the sketch fit in an UNO!
|
||||
This sketch uses the GLCD font only.
|
||||
|
||||
Make sure all the required fonts are loaded by editting the
|
||||
User_Setup.h file in the TFT_eSPI library folder.
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
The library uses the hardware SPI pins only:
|
||||
For UNO, Nano, Micro Pro ATmega328 based processors
|
||||
MOSI = pin 11, SCK = pin 13
|
||||
For Mega:
|
||||
MOSI = pin 51, SCK = pin 52
|
||||
|
||||
The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST)
|
||||
signal lines to the TFT must also be defined in the library User_Setup.h file.
|
||||
|
||||
Sugested TFT connections for UNO and Atmega328 based boards
|
||||
sclk 13 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 11 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 10 // Chip select for TFT display
|
||||
dc 9 // Data/command line
|
||||
rst 7 // Reset, you could connect this to the Arduino reset pin
|
||||
|
||||
Suggested TFT connections for the MEGA and ATmega2560 based boards
|
||||
sclk 52 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 51 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 47 // TFT chip select line
|
||||
dc 48 // TFT data/command line
|
||||
rst 44 // you could alternatively connect this to the Arduino reset
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
@@ -61,10 +39,12 @@ void setup()
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
|
||||
Serial.print(F(__DATE__ " " __TIME__ " - Flash=0x"));
|
||||
Serial.print((uint16_t)__data_load_end, HEX);
|
||||
Serial.print(F(" RAM=0x"));
|
||||
Serial.println((uint16_t)_end - (uint16_t)__data_start, HEX);
|
||||
// These are not compatible with the ESP8266 core library
|
||||
//Serial.print((uint16_t)__data_load_end, HEX);
|
||||
//Serial.print(F(" RAM=0x"));
|
||||
//Serial.println((uint16_t)_end - (uint16_t)__data_start, HEX);
|
||||
Serial.println(F("Benchmark Time (microseconds)"));
|
||||
|
||||
uint32_t usecHaD = testHaD();
|
||||
@@ -159,17 +139,16 @@ void loop(void)
|
||||
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.print(F("SPI LCD on 328p"));
|
||||
tft.setTextColor(TFT_YELLOW);
|
||||
tft.print(F("@"));
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.print(F("16MHz"));
|
||||
tft.println(F("SPI TFT on ESP8266"));
|
||||
tft.println(F(""));
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(tft.color565(0x80, 0x80, 0x80));
|
||||
tft.print(F("Flash=0x"));
|
||||
tft.print((uint16_t)__data_load_end, HEX);
|
||||
tft.print(F(" RAM=0x"));
|
||||
tft.print((uint16_t)_end - (uint16_t)__data_start, HEX);
|
||||
|
||||
// These are not compatible with the ESP8266 core library
|
||||
//tft.print(F("Flash=0x"));
|
||||
//tft.print((uint16_t)__data_load_end, HEX);
|
||||
//tft.print(F(" RAM=0x"));
|
||||
//tft.print((uint16_t)_end - (uint16_t)__data_start, HEX);
|
||||
|
||||
tft.setTextColor(TFT_GREEN);
|
||||
tft.print(F("Benchmark usec"));
|
||||
|
@@ -4,39 +4,14 @@
|
||||
This sketch uses the GLCD font (font 1) only. Disable other fonts to make
|
||||
the sketch fit in an UNO!
|
||||
|
||||
Make sure all the required fonts are loaded by editting the
|
||||
User_Setup.h file in the TFT_eSPI library folder.
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
If using an UNO or Mega (ATmega328 or ATmega2560 processor) then for best
|
||||
performance use the F_AS_T option found in the User_Setup.h file in the
|
||||
TFT_eSPI library folder.
|
||||
|
||||
The library uses the hardware SPI pins only:
|
||||
For UNO, Nano, Micro Pro ATmega328 based processors
|
||||
MOSI = pin 11, SCK = pin 13
|
||||
For Mega:
|
||||
MOSI = pin 51, SCK = pin 52
|
||||
|
||||
The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST)
|
||||
signal lines to the TFT must also be defined in the library User_Setup.h file.
|
||||
|
||||
Sugested TFT connections for UNO and Atmega328 based boards
|
||||
sclk 13 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 11 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 10 // Chip select for TFT display
|
||||
dc 9 // Data/command line
|
||||
rst 7 // Reset, you could connect this to the Arduino reset pin
|
||||
|
||||
Suggested TFT connections for the MEGA and ATmega2560 based boards
|
||||
sclk 52 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 51 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 47 // TFT chip select line
|
||||
dc 48 // TFT data/command line
|
||||
rst 44 // you could alternatively connect this to the Arduino reset
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
|
@@ -4,38 +4,16 @@
|
||||
//
|
||||
/*
|
||||
|
||||
This sketch uses the GLCD and font 2 only. Disable other fonts to make
|
||||
the sketch fit in an UNO!
|
||||
This sketch uses the GLCD and font 2 only.
|
||||
|
||||
Make sure all the required fonts are loaded by editting the
|
||||
User_Setup.h file in the TFT_eSPI library folder.
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
The library uses the hardware SPI pins only:
|
||||
For UNO, Nano, Micro Pro ATmega328 based processors
|
||||
MOSI = pin 11, SCK = pin 13
|
||||
For Mega:
|
||||
MOSI = pin 51, SCK = pin 52
|
||||
|
||||
The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST)
|
||||
signal lines to the TFT must also be defined in the library User_Setup.h file.
|
||||
|
||||
Sugested TFT connections for UNO and Atmega328 based boards
|
||||
sclk 13 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 11 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 10 // Chip select for TFT display
|
||||
dc 9 // Data/command line
|
||||
rst 7 // Reset, you could connect this to the Arduino reset pin
|
||||
|
||||
Suggested TFT connections for the MEGA and ATmega2560 based boards
|
||||
sclk 52 // Don't change, this is the hardware SPI SCLK line
|
||||
mosi 51 // Don't change, this is the hardware SPI MOSI line
|
||||
cs 47 // TFT chip select line
|
||||
dc 48 // TFT data/command line
|
||||
rst 44 // you could alternatively connect this to the Arduino reset
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
@@ -54,10 +32,6 @@ unsigned long runTime = 0;
|
||||
void setup()
|
||||
{
|
||||
randomSeed(analogRead(A0));
|
||||
pinMode(7, OUTPUT);
|
||||
digitalWrite(7, LOW);
|
||||
delay(10);
|
||||
digitalWrite(7, HIGH);
|
||||
// Setup the LCD
|
||||
myGLCD.init();
|
||||
myGLCD.setRotation(1);
|
||||
@@ -65,8 +39,8 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
randomSeed(millis());
|
||||
//randomSeed(1234); // This ensure test is repeatable with exact same draws each loop
|
||||
//randomSeed(millis());
|
||||
randomSeed(1234); // This ensure test is repeatable with exact same draws each loop
|
||||
int buf[TFT_W - 2];
|
||||
int x, x2;
|
||||
int y, y2;
|
||||
@@ -330,20 +304,25 @@ int col = 0;
|
||||
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// This test has been modified as it takes more time to calculate the random numbers
|
||||
// than to draw the pixels (3 seconds to produce 30,000 randoms)!
|
||||
//for (int i=0; i<10000; i++)
|
||||
//{
|
||||
// myGLCD.drawPixel(2+random(316), 16+random(209),random(0xFFFF));
|
||||
//}
|
||||
#define RANDOM
|
||||
|
||||
// Draw 10,000 pixels to fill a 100x100 pixel box
|
||||
#ifdef RANDOM
|
||||
// Draw 10,000 pixels
|
||||
// It takes 30ms to calculate the 30,000 random numbers so this is not a true drawPixel speed test
|
||||
for (int i=0; i<10000; i++)
|
||||
{
|
||||
myGLCD.drawPixel(2+random(316), 16+random(209),random(0xFFFF));
|
||||
}
|
||||
#else
|
||||
// Draw 10,000 pixels to fill a 100x100 pixel box, better drawPixel speed test
|
||||
// use the coords as the colour to produce the banding
|
||||
byte i = 100;
|
||||
while (i--) {
|
||||
byte j = 100;
|
||||
while (j--) myGLCD.drawPixel(i + TFT_W / 2 - 50, j + TFT_H / 2 - 50, i + j);
|
||||
}
|
||||
#endif
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillScreen(TFT_BLUE);
|
||||
|
Reference in New Issue
Block a user