mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-06 06:04:42 +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.
|
||||
|
||||
@@ -42,7 +43,7 @@ void setup()
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Draw the icons
|
||||
drawIcon(info, (tft.width() - infoWidth)/2 - 50, (tft.height() - infoHeight)/2, infoWidth, infoHeight);
|
||||
drawIcon(info, (tft.width() - infoWidth)/2 - 50, (tft.height() - infoHeight)/2, infoWidth, infoHeight);
|
||||
drawIcon(alert, (tft.width() - alertWidth)/2, (tft.height() - alertHeight)/2, alertWidth, alertHeight);
|
||||
drawIcon(close, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight);
|
||||
|
||||
@@ -54,7 +55,7 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
// Loop filling and clearing screen
|
||||
drawIcon(info, random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight);
|
||||
drawIcon(info, random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight);
|
||||
drawIcon(alert, random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight);
|
||||
drawIcon(close, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight);
|
||||
|
||||
|
@@ -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,43 +1,15 @@
|
||||
/*
|
||||
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.
|
||||
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
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
*/
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
// New background colour
|
||||
#define TFT_BROWN 0x38E0
|
||||
|
@@ -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,40 +6,15 @@
|
||||
|
||||
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.
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
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
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
|
||||
@@ -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
|
||||
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);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Ellipse drawing example
|
||||
|
||||
|
||||
This sketch does not use any fonts.
|
||||
*/
|
||||
|
||||
@@ -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,36 +3,15 @@
|
||||
|
||||
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
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
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
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,29 +1,17 @@
|
||||
/*
|
||||
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!)
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
An example showing rainbow colours on a 1.8" TFT LCD screen
|
||||
and to show a basic example of font use.
|
||||
|
||||
Make sure all the display driver and pin comnenctions are correct by
|
||||
editting the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
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
|
||||
#include <SPI.h>
|
||||
@@ -42,85 +30,93 @@ void setup(void) {
|
||||
tft.setRotation(1);
|
||||
tft.fillScreen(ST7735_BLACK);
|
||||
|
||||
targetTime = millis() + 1000;
|
||||
targetTime = millis() + 1000;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (targetTime < millis()) {
|
||||
targetTime = millis()+10000;
|
||||
for (int i = 0; i<160; i++) {
|
||||
targetTime = millis() + 10000;
|
||||
|
||||
// Colour changing state machine
|
||||
for (int i = 0; i < 160; i++) {
|
||||
tft.drawFastVLine(i, 0, tft.height(), colour);
|
||||
switch (state) {
|
||||
case 0:
|
||||
green +=2;
|
||||
if (green == 64) {
|
||||
green=63;
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
red--;
|
||||
if (red == 255) {
|
||||
red = 0;
|
||||
state = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
blue ++;
|
||||
if (blue == 32) {
|
||||
blue=31;
|
||||
state = 3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
green -=2;
|
||||
if (green ==255) {
|
||||
green=0;
|
||||
state = 4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
red ++;
|
||||
if (red == 32) {
|
||||
red = 31;
|
||||
state = 5;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
blue --;
|
||||
if (blue == 255) {
|
||||
blue = 0;
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
green += 2;
|
||||
if (green == 64) {
|
||||
green = 63;
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
red--;
|
||||
if (red == 255) {
|
||||
red = 0;
|
||||
state = 2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
blue ++;
|
||||
if (blue == 32) {
|
||||
blue = 31;
|
||||
state = 3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
green -= 2;
|
||||
if (green == 255) {
|
||||
green = 0;
|
||||
state = 4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
red ++;
|
||||
if (red == 32) {
|
||||
red = 31;
|
||||
state = 5;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
blue --;
|
||||
if (blue == 255) {
|
||||
blue = 0;
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
colour = red<<11 | green<<5 | blue;
|
||||
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", 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!
|
||||
|
||||
|
||||
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 left of the font!
|
||||
|
||||
// draw a floating point number
|
||||
float pi = 3.14159; // Value to print
|
||||
int precision = 3; // Number of digits after decimal point
|
||||
int xpos = 50; // x position
|
||||
int ypos = 110; // y position
|
||||
int font = 2; // font number only 2,4,6,7 valid. Font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : a p m
|
||||
xpos+=tft.drawFloat(pi,precision,xpos,ypos,font); // Draw rounded number and return new xpos delta for next print position
|
||||
tft.drawString(" is pi",xpos,ypos,font); // Continue printing from new x position
|
||||
xpos += tft.drawFloat(pi, precision, xpos, ypos, font); // Draw rounded number and return new xpos delta for next print position
|
||||
tft.drawString(" is pi", xpos, ypos, font); // Continue printing from new x position
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,39 +1,17 @@
|
||||
/*
|
||||
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
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
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
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,40 +4,15 @@
|
||||
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.
|
||||
Note that yield() or delay(0) must be called in long duration for/while
|
||||
loops to stop the ESP8266 watchdog triggering.
|
||||
|
||||
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
|
||||
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ######
|
||||
#########################################################################
|
||||
#########################################################################
|
||||
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -4,40 +4,18 @@
|
||||
//
|
||||
/*
|
||||
|
||||
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 ######
|
||||
#########################################################################
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
|
||||
#include <SPI.h>
|
||||
@@ -54,99 +32,95 @@ unsigned long runTime = 0;
|
||||
void setup()
|
||||
{
|
||||
randomSeed(analogRead(A0));
|
||||
pinMode(7, OUTPUT);
|
||||
digitalWrite(7, LOW);
|
||||
delay(10);
|
||||
digitalWrite(7, HIGH);
|
||||
// Setup the LCD
|
||||
// Setup the LCD
|
||||
myGLCD.init();
|
||||
myGLCD.setRotation(1);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
randomSeed(millis());
|
||||
//randomSeed(1234); // This ensure test is repeatable with exact same draws each loop
|
||||
int buf[TFT_W-2];
|
||||
//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;
|
||||
int r;
|
||||
runTime = millis();
|
||||
// Clear the screen and draw the frame
|
||||
// Clear the screen and draw the frame
|
||||
myGLCD.fillScreen(TFT_BLACK);
|
||||
|
||||
|
||||
myGLCD.fillRect(0, 0, TFT_W-1, 14,TFT_RED);
|
||||
myGLCD.fillRect(0, 0, TFT_W - 1, 14, TFT_RED);
|
||||
|
||||
myGLCD.fillRect(0, TFT_H-14, TFT_W-1, 14,TFT_GREY);
|
||||
myGLCD.fillRect(0, TFT_H - 14, TFT_W - 1, 14, TFT_GREY);
|
||||
|
||||
myGLCD.setTextColor(TFT_BLACK,TFT_RED);
|
||||
myGLCD.drawCentreString("* TFT_S6D02A1 *", TFT_W/2, 4, 1);
|
||||
myGLCD.setTextColor(TFT_YELLOW,TFT_GREY);
|
||||
myGLCD.drawCentreString("Adapted by Bodmer", TFT_W/2, TFT_H-12,1);
|
||||
myGLCD.setTextColor(TFT_BLACK, TFT_RED);
|
||||
myGLCD.drawCentreString("* TFT_S6D02A1 *", TFT_W / 2, 4, 1);
|
||||
myGLCD.setTextColor(TFT_YELLOW, TFT_GREY);
|
||||
myGLCD.drawCentreString("Adapted by Bodmer", TFT_W / 2, TFT_H - 12, 1);
|
||||
|
||||
myGLCD.drawRect(0, 14, TFT_W-1, TFT_H-28, TFT_BLUE);
|
||||
myGLCD.drawRect(0, 14, TFT_W - 1, TFT_H - 28, TFT_BLUE);
|
||||
|
||||
// Draw crosshairs
|
||||
myGLCD.drawLine(TFT_W/2-1, 15, TFT_W/2-1, TFT_H-16,TFT_BLUE);
|
||||
myGLCD.drawLine(1, TFT_H/2-1, TFT_W-2, TFT_H/2-1,TFT_BLUE);
|
||||
for (int i=9; i<TFT_W-1; i+=10)
|
||||
myGLCD.drawLine(i, TFT_H/2-3, i, TFT_H/2+1,TFT_BLUE);
|
||||
for (int i=19; i<TFT_H-20; i+=10)
|
||||
myGLCD.drawLine(TFT_W/2-3, i, TFT_W/2+1, i,TFT_BLUE);
|
||||
// Draw crosshairs
|
||||
myGLCD.drawLine(TFT_W / 2 - 1, 15, TFT_W / 2 - 1, TFT_H - 16, TFT_BLUE);
|
||||
myGLCD.drawLine(1, TFT_H / 2 - 1, TFT_W - 2, TFT_H / 2 - 1, TFT_BLUE);
|
||||
for (int i = 9; i < TFT_W - 1; i += 10)
|
||||
myGLCD.drawLine(i, TFT_H / 2 - 3, i, TFT_H / 2 + 1, TFT_BLUE);
|
||||
for (int i = 19; i < TFT_H - 20; i += 10)
|
||||
myGLCD.drawLine(TFT_W / 2 - 3, i, TFT_W / 2 + 1, i, TFT_BLUE);
|
||||
|
||||
// Draw sin-, cos- and tan-lines
|
||||
// Draw sin-, cos- and tan-lines
|
||||
myGLCD.setTextColor(TFT_CYAN);
|
||||
myGLCD.drawString("Sin", 5, 15,2);
|
||||
for (int i=1; i<TFT_W-2; i++)
|
||||
myGLCD.drawString("Sin", 5, 15, 2);
|
||||
for (int i = 1; i < TFT_W - 2; i++)
|
||||
{
|
||||
myGLCD.drawPixel(i,TFT_H/2-1+(sin(((i*2.26)*3.14)/180)*48),TFT_CYAN);
|
||||
myGLCD.drawPixel(i, TFT_H / 2 - 1 + (sin(((i * 2.26) * 3.14) / 180) * 48), TFT_CYAN);
|
||||
}
|
||||
myGLCD.setTextColor(TFT_RED);
|
||||
myGLCD.drawString("Cos", 5, 30,2);
|
||||
for (int i=1; i<TFT_W-2; i++)
|
||||
myGLCD.drawString("Cos", 5, 30, 2);
|
||||
for (int i = 1; i < TFT_W - 2; i++)
|
||||
{
|
||||
myGLCD.drawPixel(i,TFT_H/2-1+(cos(((i*2.26)*3.14)/180)*48),TFT_RED);
|
||||
myGLCD.drawPixel(i, TFT_H / 2 - 1 + (cos(((i * 2.26) * 3.14) / 180) * 48), TFT_RED);
|
||||
}
|
||||
myGLCD.setTextColor(TFT_YELLOW);
|
||||
myGLCD.drawString("Tan", 5, 45,2);
|
||||
for (int i=1; i<TFT_W-2; i++)
|
||||
myGLCD.drawString("Tan", 5, 45, 2);
|
||||
for (int i = 1; i < TFT_W - 2; i++)
|
||||
{
|
||||
myGLCD.drawPixel(i,TFT_H/2-1+(tan(((i*2.26)*3.14)/180)),TFT_YELLOW);
|
||||
myGLCD.drawPixel(i, TFT_H / 2 - 1 + (tan(((i * 2.26) * 3.14) / 180)), TFT_YELLOW);
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
myGLCD.drawLine(TFT_W/2-1, 15, TFT_W/2-1, TFT_H-16,TFT_BLUE);
|
||||
myGLCD.drawLine(1, TFT_H/2-1, TFT_W-2, TFT_H/2-1,TFT_BLUE);
|
||||
int col = 0;
|
||||
// Draw a moving sinewave
|
||||
x=1;
|
||||
for (int i=1; i<((TFT_W-3)*20); i++)
|
||||
myGLCD.drawLine(TFT_W / 2 - 1, 15, TFT_W / 2 - 1, TFT_H - 16, TFT_BLUE);
|
||||
myGLCD.drawLine(1, TFT_H / 2 - 1, TFT_W - 2, TFT_H / 2 - 1, TFT_BLUE);
|
||||
int col = 0;
|
||||
// Draw a moving sinewave
|
||||
x = 1;
|
||||
for (int i = 1; i < ((TFT_W - 3) * 20); i++)
|
||||
{
|
||||
x++;
|
||||
if (x==TFT_W-2)
|
||||
x=1;
|
||||
if (i>TFT_W-2)
|
||||
if (x == TFT_W - 2)
|
||||
x = 1;
|
||||
if (i > TFT_W - 2)
|
||||
{
|
||||
if ((x==TFT_W/2-1)||(buf[x-1]==TFT_H/2-1))
|
||||
if ((x == TFT_W / 2 - 1) || (buf[x - 1] == TFT_H / 2 - 1))
|
||||
col = TFT_BLUE;
|
||||
else
|
||||
myGLCD.drawPixel(x,buf[x-1],TFT_BLACK);
|
||||
myGLCD.drawPixel(x, buf[x - 1], TFT_BLACK);
|
||||
}
|
||||
y=TFT_H/2 +(sin(((i*2.2)*3.14)/180)*(49-(i / 100)));
|
||||
myGLCD.drawPixel(x,y,TFT_BLUE);
|
||||
buf[x-1]=y;
|
||||
y = TFT_H / 2 + (sin(((i * 2.2) * 3.14) / 180) * (49 - (i / 100)));
|
||||
myGLCD.drawPixel(x, y, TFT_BLUE);
|
||||
buf[x - 1] = y;
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// Draw some filled rectangles
|
||||
for (int i=1; i<6; i++)
|
||||
// Draw some filled rectangles
|
||||
for (int i = 1; i < 6; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
@@ -166,15 +140,15 @@ int col = 0;
|
||||
col = TFT_YELLOW;
|
||||
break;
|
||||
}
|
||||
myGLCD.fillRect(30+(i*10), 20+(i*10), 30, 30,col);
|
||||
myGLCD.fillRect(30 + (i * 10), 20 + (i * 10), 30, 30, col);
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// Draw some filled, rounded rectangles
|
||||
for (int i=1; i<6; i++)
|
||||
// Draw some filled, rounded rectangles
|
||||
for (int i = 1; i < 6; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
@@ -194,15 +168,15 @@ int col = 0;
|
||||
col = TFT_YELLOW;
|
||||
break;
|
||||
}
|
||||
myGLCD.fillRoundRect(TFT_W/2+20-(i*10), 20+(i*10), 30,30, 3,col);
|
||||
myGLCD.fillRoundRect(TFT_W / 2 + 20 - (i * 10), 20 + (i * 10), 30, 30, 3, col);
|
||||
}
|
||||
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// Draw some filled circles
|
||||
for (int i=1; i<6; i++)
|
||||
// Draw some filled circles
|
||||
for (int i = 1; i < 6; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
@@ -222,142 +196,147 @@ int col = 0;
|
||||
col = TFT_YELLOW;
|
||||
break;
|
||||
}
|
||||
myGLCD.fillCircle(45+(i*10),30+(i*10), 15,col);
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
|
||||
// Draw some lines in a pattern
|
||||
|
||||
for (int i=15; i<TFT_H-16; i+=5)
|
||||
{
|
||||
myGLCD.drawLine(1, i, (i*1.44)-10, TFT_H-17,TFT_RED);
|
||||
}
|
||||
|
||||
for (int i=TFT_H-17; i>15; i-=5)
|
||||
{
|
||||
myGLCD.drawLine(TFT_W-3, i, (i*1.44)-11, 15,TFT_RED);
|
||||
}
|
||||
|
||||
for (int i=TFT_H-17; i>15; i-=5)
|
||||
{
|
||||
myGLCD.drawLine(1, i, TFT_W+11-(i*1.44), 15,TFT_CYAN);
|
||||
}
|
||||
|
||||
for (int i=15; i<TFT_H-16; i+=5)
|
||||
{
|
||||
myGLCD.drawLine(TFT_W-3, i, TFT_W+10-(i*1.44), TFT_H-17,TFT_CYAN);
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
|
||||
// Draw some random circles
|
||||
for (int i=0; i<100; i++)
|
||||
{
|
||||
x=32+random(TFT_W-2-32-30);
|
||||
y=45+random(TFT_H-19-45-30);
|
||||
r=random(30);
|
||||
myGLCD.drawCircle(x, y, r,random(0xFFFF));
|
||||
myGLCD.fillCircle(45 + (i * 10), 30 + (i * 10), 15, col);
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// Draw some random rectangles
|
||||
for (int i=0; i<100; i++)
|
||||
// Draw some lines in a pattern
|
||||
|
||||
for (int i = 15; i < TFT_H - 16; i += 5)
|
||||
{
|
||||
x=2+random(TFT_W-4);
|
||||
y=16+random(TFT_H-33);
|
||||
x2=2+random(TFT_H-4);
|
||||
y2=16+random(TFT_H-33);
|
||||
if (x2<x) {
|
||||
r=x;x=x2;x2=r;
|
||||
myGLCD.drawLine(1, i, (i * 1.44) - 10, TFT_H - 17, TFT_RED);
|
||||
}
|
||||
|
||||
for (int i = TFT_H - 17; i > 15; i -= 5)
|
||||
{
|
||||
myGLCD.drawLine(TFT_W - 3, i, (i * 1.44) - 11, 15, TFT_RED);
|
||||
}
|
||||
|
||||
for (int i = TFT_H - 17; i > 15; i -= 5)
|
||||
{
|
||||
myGLCD.drawLine(1, i, TFT_W + 11 - (i * 1.44), 15, TFT_CYAN);
|
||||
}
|
||||
|
||||
for (int i = 15; i < TFT_H - 16; i += 5)
|
||||
{
|
||||
myGLCD.drawLine(TFT_W - 3, i, TFT_W + 10 - (i * 1.44), TFT_H - 17, TFT_CYAN);
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// Draw some random circles
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
x = 32 + random(TFT_W - 2 - 32 - 30);
|
||||
y = 45 + random(TFT_H - 19 - 45 - 30);
|
||||
r = random(30);
|
||||
myGLCD.drawCircle(x, y, r, random(0xFFFF));
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// Draw some random rectangles
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
x = 2 + random(TFT_W - 4);
|
||||
y = 16 + random(TFT_H - 33);
|
||||
x2 = 2 + random(TFT_H - 4);
|
||||
y2 = 16 + random(TFT_H - 33);
|
||||
if (x2 < x) {
|
||||
r = x; x = x2; x2 = r;
|
||||
}
|
||||
if (y2<y) {
|
||||
r=y;y=y2;y2=r;
|
||||
if (y2 < y) {
|
||||
r = y; y = y2; y2 = r;
|
||||
}
|
||||
myGLCD.drawRect(x, y, x2-x, y2-y,random(0xFFFF));
|
||||
myGLCD.drawRect(x, y, x2 - x, y2 - y, random(0xFFFF));
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
// Draw some random rounded rectangles
|
||||
for (int i=0; i<100; i++)
|
||||
// Draw some random rounded rectangles
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
x=2+random(TFT_W-4);
|
||||
y=16+random(TFT_H-33);
|
||||
x2=2+random(TFT_W-4);
|
||||
y2=16+random(TFT_H-33);
|
||||
x = 2 + random(TFT_W - 4);
|
||||
y = 16 + random(TFT_H - 33);
|
||||
x2 = 2 + random(TFT_W - 4);
|
||||
y2 = 16 + random(TFT_H - 33);
|
||||
// We need to get the width and height and do some window checking
|
||||
if (x2<x) {
|
||||
r=x;x=x2;x2=r;
|
||||
if (x2 < x) {
|
||||
r = x; x = x2; x2 = r;
|
||||
}
|
||||
if (y2<y) {
|
||||
r=y;y=y2;y2=r;
|
||||
if (y2 < y) {
|
||||
r = y; y = y2; y2 = r;
|
||||
}
|
||||
// We need a minimum size of 6
|
||||
if((x2-x)<6) x2=x+6;
|
||||
if((y2-y)<6) y2=y+6;
|
||||
myGLCD.drawRoundRect(x, y, x2-x,y2-y, 3,random(0xFFFF));
|
||||
if ((x2 - x) < 6) x2 = x + 6;
|
||||
if ((y2 - y) < 6) y2 = y + 6;
|
||||
myGLCD.drawRoundRect(x, y, x2 - x, y2 - y, 3, random(0xFFFF));
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
myGLCD.fillRect(1, 15, TFT_W - 3, TFT_H - 31, TFT_BLACK);
|
||||
|
||||
//randomSeed(1234);
|
||||
int colour = 0;
|
||||
for (int i=0; i<100; i++)
|
||||
//randomSeed(1234);
|
||||
int colour = 0;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
x=2+random(TFT_W-4);
|
||||
y=16+random(TFT_H-31);
|
||||
x2=2+random(TFT_W-4);
|
||||
y2=16+random(TFT_H-31);
|
||||
colour=random(0xFFFF);
|
||||
myGLCD.drawLine(x, y, x2, y2,colour);
|
||||
x = 2 + random(TFT_W - 4);
|
||||
y = 16 + random(TFT_H - 31);
|
||||
x2 = 2 + random(TFT_W - 4);
|
||||
y2 = 16 + random(TFT_H - 31);
|
||||
colour = random(0xFFFF);
|
||||
myGLCD.drawLine(x, y, x2, y2, colour);
|
||||
}
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK);
|
||||
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);
|
||||
while (j--) myGLCD.drawPixel(i + TFT_W / 2 - 50, j + TFT_H / 2 - 50, i + j);
|
||||
}
|
||||
#endif
|
||||
|
||||
delay(DELAY);
|
||||
|
||||
myGLCD.fillScreen(TFT_BLUE);
|
||||
myGLCD.fillRoundRect(20, 20, TFT_W-40, TFT_H-60, 6,TFT_RED);
|
||||
|
||||
myGLCD.setTextColor(TFT_WHITE,TFT_RED);
|
||||
myGLCD.drawCentreString("That's it!", TFT_W/2-1, 23,2);
|
||||
myGLCD.drawCentreString("Restarting in a", TFT_W/2-1, 40,2);
|
||||
myGLCD.drawCentreString("few seconds...", TFT_W/2-1, 57,2);
|
||||
myGLCD.fillRoundRect(20, 20, TFT_W - 40, TFT_H - 60, 6, TFT_RED);
|
||||
|
||||
runTime = millis()-runTime;
|
||||
myGLCD.setTextColor(TFT_GREEN,TFT_BLUE);
|
||||
myGLCD.drawCentreString("Draw time: (msecs)", TFT_W/2, TFT_H-34,2);
|
||||
myGLCD.drawNumber(runTime-11*DELAY, TFT_W/2-20, TFT_H-17,2);
|
||||
myGLCD.setTextColor(TFT_WHITE, TFT_RED);
|
||||
myGLCD.drawCentreString("That's it!", TFT_W / 2 - 1, 23, 2);
|
||||
myGLCD.drawCentreString("Restarting in a", TFT_W / 2 - 1, 40, 2);
|
||||
myGLCD.drawCentreString("few seconds...", TFT_W / 2 - 1, 57, 2);
|
||||
|
||||
runTime = millis() - runTime;
|
||||
myGLCD.setTextColor(TFT_GREEN, TFT_BLUE);
|
||||
myGLCD.drawCentreString("Draw time: (msecs)", TFT_W / 2, TFT_H - 34, 2);
|
||||
myGLCD.drawNumber(runTime - 11 * DELAY, TFT_W / 2 - 20, TFT_H - 17, 2);
|
||||
delay (5000);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user