Update for spelling etc. in comments!

This commit is contained in:
Bodmer committed 2023-12-07 20:35:59 +00:00
1 parent aefcf5af63
commit d506a3c49d
197 files changed
+1006 -757

No files matched your search

@@ -44,7 +44,7 @@ void setup() {
tft.fillScreen(TFT_BLACK);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE);
tft.setCursor(0, 0);
tft.setcursor(0, 0);
}
@@ -54,11 +54,11 @@ void loop() {
tft.fillScreen(TFT_BLACK);
tft.setTextSize(2);
tft.setTextColor(TFT_WHITE);
tft.setCursor(40, 5);
tft.setcursor(40, 5);
tft.println(F("Arduino"));
tft.setCursor(35, 25);
tft.setcursor(35, 25);
tft.println(F("Cellular"));
tft.setCursor(35, 45);
tft.setcursor(35, 45);
tft.println(F("Automata"));
delay(1000);
@@ -79,7 +79,7 @@ void loop() {
if (ss==0 || initial) {
initial = 0;
tft.setTextColor(TFT_GREEN, TFT_BLACK);
tft.setCursor (8, 52);
tft.setcursor (8, 52);
tft.print(__DATE__); // This uses the standard ADAFruit small font
tft.setTextColor(TFT_BLUE, TFT_BLACK);
@@ -20,7 +20,7 @@ void loop() {
tft.fillScreen(TFT_BLACK);
// Draw some random filled elipses
// Draw some random filled ellipses
for (int i = 0; i < 20; i++)
{
int rx = random(40);
@@ -33,7 +33,7 @@ void loop() {
delay(2000);
tft.fillScreen(TFT_BLACK);
// Draw some random outline elipses
// Draw some random outline ellipses
for (int i = 0; i < 20; i++)
{
int rx = random(40);
@@ -73,7 +73,7 @@ void analogMeter()
// Long scale tick length
int tl = 15;
// Coodinates of tick to draw
// Coordinates of tick to draw
float sx = cos((i - 90) * 0.0174532925);
float sy = sin((i - 90) * 0.0174532925);
uint16_t x0 = sx * (M_SIZE*100 + tl) + M_SIZE*120;
@@ -1,5 +1,5 @@
/*
Test the tft.print() viz embedded tft.write() function
Test the tft.print() viz. embedded tft.write() function
This sketch used font 2, 4, 7
@@ -36,7 +36,7 @@ void loop() {
// Set "cursor" at top left corner of display (0,0) and select font 2
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0, 2);
tft.setcursor(0, 0, 2);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1);
// We can now plot text on screen using the "print" class
@@ -90,13 +90,13 @@ void loop() {
// The standard ADAFruit font still works as before
tft.setTextColor(TFT_BLACK);
tft.setCursor (12, 5);
tft.setcursor (12, 5);
tft.print("Original ADAfruit font!");
// The new larger fonts do not use the .setCursor call, coords are embedded
// The new larger fonts do not use the .setcursor call, coords are embedded
tft.setTextColor(TFT_BLACK, TFT_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!)
// Overlay the black text on top of the rainbow plot (the advantage of not drawing the background 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
@@ -1,7 +1,7 @@
// Sketch to display images on a 160 x 128 TFT
// Renders images stored in an array in program (FLASH)
// The JPEG images are stored in header files (see jpeg1.h etc)
// The JPEG images are stored in header files (see jpeg1.h etc.)
// As well as the TFT_eSPI library:
// https://github.com/Bodmer/TFT_eSPI
@@ -95,7 +95,7 @@ void drawArrayJpeg(const uint8_t arrayname[], uint32_t array_size, int xpos, int
// fit totally on the screen are cropped to the nearest MCU size and may leave right/bottom borders.
void renderJPEG(int xpos, int ypos) {
// retrieve infomration about the image
// retrieve information about the image
uint16_t *pImg;
uint16_t mcu_w = JpegDec.MCUWidth;
uint16_t mcu_h = JpegDec.MCUHeight;
@@ -193,12 +193,12 @@ void jpegInfo() {
// Show the execution time (optional)
//####################################################################################################
// WARNING: for UNO/AVR legacy reasons printing text to the screen with the Mega might not work for
// sketch sizes greater than ~70KBytes because 16 bit address pointers are used in some libraries.
// sketch sizes greater than ~70KBytes because 16-bit address pointers are used in some libraries.
// The Due will work fine with the HX8357_Due library.
void showTime(uint32_t msTime) {
//tft.setCursor(0, 0);
//tft.setcursor(0, 0);
//tft.setTextFont(1);
//tft.setTextSize(2);
//tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -132,7 +132,7 @@ void loop(void)
d = -d;
}
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(TFT_MAGENTA);
tft.println(F("Bodmer's TFT_eSPI"));
@@ -343,7 +343,7 @@ uint32_t testHaD()
uint32_t t = micros() - start;
tft.setTextColor(TFT_YELLOW);
tft.setCursor(0, 145);
tft.setcursor(0, 145);
tft.print(F(" http://hackaday.io/"));
tft.print(F(" Xark"));
@@ -371,7 +371,7 @@ uint32_t testFillScreen()
uint32_t testText() {
tft.fillScreen(TFT_BLACK);
uint32_t start = micros_start();
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(TFT_WHITE); tft.setTextSize(1);
tft.println(F("Hello World!"));
tft.setTextColor(tft.color565(0xff, 0x00, 0x00));
@@ -126,7 +126,7 @@ void testlines(uint16_t color) {
}
void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
@@ -215,7 +215,7 @@ void testroundrects() {
void tftPrintTest() {
tft.setTextWrap(false);
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 30);
tft.setcursor(0, 30);
tft.setTextColor(TFT_RED);
tft.setTextSize(1);
tft.println("Hello World!");
@@ -229,7 +229,7 @@ void tftPrintTest() {
tft.setTextSize(4);
tft.print(1234.567);
delay(1500);
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE);
tft.setTextSize(0);
@@ -376,7 +376,7 @@ void loop() {
}
// There follows a crude way of flagging that this example sketch needs fonts which
// have not been enbabled in the User_Setup.h file inside the TFT_HX8357 library.
// have not been enabled in the User_Setup.h file inside the TFT_HX8357 library.
//
// These lines produce errors during compile time if settings in User_Setup are not correct
//
@@ -38,7 +38,7 @@ void setup() {
tft.fillScreen(TFT_BLACK);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE);
tft.setCursor(0, 0);
tft.setcursor(0, 0);
}
@@ -48,11 +48,11 @@ void loop() {
tft.fillScreen(TFT_BLACK);
tft.setTextSize(2);
tft.setTextColor(TFT_WHITE);
tft.setCursor(40, 5);
tft.setcursor(40, 5);
tft.println(F("Arduino"));
tft.setCursor(35, 25);
tft.setcursor(35, 25);
tft.println(F("Cellular"));
tft.setCursor(35, 45);
tft.setcursor(35, 45);
tft.println(F("Automata"));
delay(1000);
@@ -70,7 +70,7 @@ void loop() {
// For comaptibility with Adafruit_GFX library the text background is not plotted when using the print class
// even if we specify it.
tft.setTextColor(TFT_YELLOW);
tft.setCursor(xpos, ypos); // Set cursor near top left corner of screen
tft.setcursor(xpos, ypos); // Set cursor near top left corner of screen
tft.setFreeFont(TT1); // Select the orginal small TomThumb font
tft.println(); // Move cursor down a line
@@ -280,7 +280,7 @@ void drawDatumMarker(int x, int y)
// There follows a crude way of flagging that this example sketch needs fonts which
// have not been enbabled in the User_Setup.h file inside the TFT_HX8357 library.
// have not been enabled in the User_Setup.h file inside the TFT_HX8357 library.
//
// These lines produce errors during compile time if settings in User_Setup are not correct
//
@@ -3,8 +3,8 @@
button handling class, this sketch is based on the Arduin-o-phone
example.
This example diplays a keypad where numbers can be entered and
send to the Serial Monitor window.
This example displays a keypad where numbers can be entered and
sent to the Serial Monitor window.
The sketch has been tested on the ESP8266 (which supports SPIFFS)
@@ -164,7 +164,7 @@ void loop(void) {
// Update the number display field
tft.setTextDatum(TL_DATUM); // Use top left corner as text coord datum
tft.setFreeFont(&FreeSans18pt7b); // Choose a nicefont that fits box
tft.setFreeFont(&FreeSans18pt7b); // Choose a nice font that fits box
tft.setTextColor(DISP_TCOLOR); // Set the font colour
// Draw the string, the value returned is the width in pixels
@@ -209,7 +209,7 @@ void touch_calibrate()
// check file system exists
if (!SPIFFS.begin()) {
Serial.println("Formating file system");
Serial.println("formatting file system");
SPIFFS.format();
SPIFFS.begin();
}
@@ -238,7 +238,7 @@ void touch_calibrate()
} else {
// data not valid so recalibrate
tft.fillScreen(TFT_BLACK);
tft.setCursor(20, 0);
tft.setcursor(20, 0);
tft.setTextFont(2);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -272,7 +272,7 @@ void touch_calibrate()
// Print something in the mini status bar
void status(const char *msg) {
tft.setTextPadding(240);
//tft.setCursor(STATUS_X, STATUS_Y);
//tft.setcursor(STATUS_X, STATUS_Y);
tft.setTextColor(TFT_WHITE, TFT_DARKGREY);
tft.setTextFont(0);
tft.setTextDatum(TC_DATUM);
@@ -11,7 +11,7 @@
// Change the pin settings to suit your hardware
// UNO etc
// UNO etc.
//#define TFT_MOSI 11
//#define TFT_SCK 13
//#define TFT_CS 9
@@ -116,7 +116,7 @@ void setup() {
uint32_t ID = 0;
Serial.begin(115200);
delay(4000); // Delay to allow USB to connect to a Leonardo etc
delay(4000); // Delay to allow USB to connect to a Leonardo etc.
Serial.println("TFT driver register values:");
Serial.println("===========================");
@@ -11,7 +11,7 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
byte inc = 0;
unsigned int col = 0;
byte red = 31; // Red is the top 5 bits of a 16 bit colour value
byte red = 31; // 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 state = 0;
@@ -56,7 +56,7 @@ void loop() {
// rx = x axis outer radius
// ry = y axis outer radius
// w = width (thickness) of arc in pixels
// colour = 16 bit colour value
// colour = 16-bit colour value
// Note if rx and ry are the same then an arc of a circle is drawn
void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour)
@@ -87,7 +87,7 @@ void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w
tft.fillTriangle(x0, y0, x1, y1, x2, y2, colour);
tft.fillTriangle(x1, y1, x2, y2, x3, y3, colour);
// Copy segment end to sgement start for next segment
// Copy segment end to segment start for next segment
x0 = x2;
y0 = y2;
x1 = x3;
@@ -96,7 +96,7 @@ void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w
}
// #########################################################################
// Return the 16 bit colour with brightness 0-100%
// Return the 16-bit colour with brightness 0-100%
// #########################################################################
unsigned int brightness(unsigned int colour, int brightness)
{
@@ -112,7 +112,7 @@ unsigned int brightness(unsigned int colour, int brightness)
}
// #########################################################################
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// #########################################################################
unsigned int rainbow(byte value)
{
@@ -19,7 +19,7 @@
#########################################################################
*/
// Note the the tilda symbol ~ does not exist in some fonts at the moment
// Note the the tilde symbol ~ does not exist in some fonts at the moment
#define TEXT "abc MWy 123 |" // Text that will be printed on screen in any font
#include "SPI.h"
@@ -13,7 +13,7 @@ int segment = 0;
unsigned int col = 0;
int delta = -1;
byte red = 31; // Red is the top 5 bits of a 16 bit colour value
byte red = 31; // 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 state = 0;
@@ -48,7 +48,7 @@ void loop() {
// rx = x axis radius
// yx = y axis radius
// w = width (thickness) of arc in pixels
// colour = 16 bit colour value
// colour = 16-bit colour value
// Note if rx and ry are the same an arc of a circle is drawn
void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour)
@@ -82,7 +82,7 @@ void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w
}
// #########################################################################
// Return a 16 bit colour with brightness 0 - 100%
// Return a 16-bit colour with brightness 0 - 100%
// #########################################################################
unsigned int brightness(unsigned int colour, int brightness)
{
@@ -98,7 +98,7 @@ unsigned int brightness(unsigned int colour, int brightness)
}
// #########################################################################
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// #########################################################################
unsigned int rainbow(byte value)
{
@@ -62,7 +62,7 @@ unsigned int rainbow(int value)
// Value is expected to be in range 0-127
// The value is converted to a spectrum colour from 0 = blue through to red = blue
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
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
@@ -47,7 +47,7 @@ void setup(void) {
void loop() {
if (updateTime <= millis()) {
updateTime = millis() + 35; // Update emter every 35 milliseconds
updateTime = millis() + 35; // Update meter every 35 milliseconds
// Create a Sine wave for testing
d += 4; if (d >= 360) d = 0;
@@ -75,7 +75,7 @@ void analogMeter()
// Long scale tick length
int tl = 15;
// Coodinates of tick to draw
// Coordinates of tick to draw
float sx = cos((i - 90) * 0.0174532925);
float sy = sin((i - 90) * 0.0174532925);
uint16_t x0 = sx * (M_SIZE*100 + tl) + M_SIZE*120;
@@ -175,7 +175,7 @@ void plotNeedle(int value, byte ms_delay)
if (ms_delay == 0) old_analog = value; // Update immediately if delay is 0
float sdeg = map(old_analog, -10, 110, -150, -30); // Map value to angle
// Calcualte tip of needle coords
// Calculate tip of needle coords
float sx = cos(sdeg * 0.0174532925);
float sy = sin(sdeg * 0.0174532925);
+2 -2
View File
@@ -95,7 +95,7 @@ void analogMeter()
// Long scale tick length
int tl = 15;
// Coodinates of tick to draw
// Coordinates of tick to draw
float sx = cos((i - 90) * 0.0174532925);
float sy = sin((i - 90) * 0.0174532925);
uint16_t x0 = sx * (100 + tl) + 120;
@@ -195,7 +195,7 @@ void plotNeedle(int value, byte ms_delay)
if (ms_delay == 0) old_analog = value; // Update immediately id delay is 0
float sdeg = map(old_analog, -10, 110, -150, -30); // Map value to angle
// Calcualte tip of needle coords
// Calculate tip of needle coords
float sx = cos(sdeg * 0.0174532925);
float sy = sin(sdeg * 0.0174532925);
@@ -44,7 +44,7 @@ void loop() {
// start_angle = 0 - 359
// sub_angle = 0 - 360 = subtended angle
// r = radius
// colour = 16 bit colour value
// colour = 16-bit colour value
int fillSegment(int x, int y, int start_angle, int sub_angle, int r, unsigned int colour)
{
@@ -63,7 +63,7 @@ int fillSegment(int x, int y, int start_angle, int sub_angle, int r, unsigned in
tft.fillTriangle(x1, y1, x2, y2, x, y, colour);
// Copy segment end to sgement start for next segment
// Copy segment end to segment start for next segment
x1 = x2;
y1 = y2;
}
@@ -71,7 +71,7 @@ int fillSegment(int x, int y, int start_angle, int sub_angle, int r, unsigned in
// #########################################################################
// Return the 16 bit colour with brightness 0-100%
// Return the 16-bit colour with brightness 0-100%
// #########################################################################
unsigned int brightness(unsigned int colour, int brightness)
{
@@ -1,5 +1,5 @@
/*
Test the tft.print() viz embedded tft.write() function
Test the tft.print() viz. embedded tft.write() function
This sketch used font 2, 4, 7
@@ -34,7 +34,7 @@ void loop() {
// Set "cursor" at top left corner of display (0,0) and select font 2
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0, 2);
tft.setcursor(0, 0, 2);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1);
// We can now plot text on screen using the "print" class
@@ -45,15 +45,15 @@ void loop() {
// The standard AdaFruit font still works as before
tft.setTextColor(TFT_BLACK); // Background is not defined so it is transparent
tft.setCursor (60, 5);
tft.setcursor (60, 5);
tft.setTextFont(0); // Select font 0 which is the Adafruit font
tft.print("Original Adafruit font!");
//tft.drawString("Original Adafruit font!",60,5,1);
// The new larger fonts do not need to use the .setCursor call, coords are embedded
// The new larger fonts do not need to use the .setcursor call, coords are embedded
tft.setTextColor(TFT_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!)
// Overlay the black text on top of the rainbow plot (the advantage of not drawing the background colour!)
tft.drawCentreString("Font size 2", 120, 14, 2); // Draw text centre at position 120, 14 using font 2
tft.drawCentreString("Font size 4", 120, 30, 4); // Draw text centre at position 120, 30 using font 4
tft.drawCentreString("12.34", 120, 54, 6); // Draw text centre at position 120, 54 using font 6
@@ -74,15 +74,15 @@ void loop() {
tft.setTextColor(TFT_BLACK); // Set text colour to black, no background (so transparent)
tft.setCursor(36, 150, 4); // Set cursor to x = 36, y = 150 and use font 4
tft.setcursor(36, 150, 4); // Set cursor to x = 36, y = 150 and use font 4
tft.println("Transparent..."); // As we use println, the cursor moves to the next line
tft.setCursor(30, 175); // Set cursor to x = 30, y = 175
tft.setcursor(30, 175); // Set cursor to x = 30, y = 175
tft.setTextColor(TFT_WHITE, TFT_BLACK); // Set text colour to white and background to black
tft.println("White on black");
tft.setTextFont(4); // Select font 4 without moving cursor
tft.setCursor(50, 210); // Set cursor to x = 50, y = 210 without changing the font
tft.setcursor(50, 210); // Set cursor to x = 50, y = 210 without changing the font
tft.setTextColor(TFT_WHITE);
// By using #TFT print we can use all the formatting features like printing HEX
tft.print(57005, HEX); // Cursor does no move to next line
@@ -98,7 +98,7 @@ void loop() {
// Fill screen with a rainbow pattern
void rainbow_fill()
{
// The colours and state are not initialised so the start colour changes each time the funtion is called
// The colours and state are not initialised so the start colour changes each time the function is called
for (int i = 319; i > 0; i--) {
// Draw a vertical line 1 pixel wide in the selected colour
@@ -38,7 +38,7 @@ void setup(void) {
void loop() {
tft.fillScreen(TFT_BLUE);
tft.setCursor(0, 0, 2);
tft.setcursor(0, 0, 2);
// Set the font colour to be white with a black background
tft.setTextColor(TFT_WHITE, TFT_BLACK);
// We can now plot text on screen using the "print" class
@@ -56,7 +56,7 @@ void loop() {
printSubset(); // Print a useful subset of the readable registers
readTest(); // Test 8, 16 and 32 bit reads and index on the ID register
readTest(); // Test 8, 16 and 32-bit reads and index on the ID register
//printRange32(0x00, 0xFF); // Print a range of registers (32 bits, index = 0)
@@ -70,8 +70,8 @@ void loop() {
void readTest(void)
{
Serial.println(); Serial.println("Test 8, 16 and 32 bit reads and the index...");
// Test 8, 16 and 32 bit reads and index
Serial.println(); Serial.println("Test 8, 16 and 32-bit reads and the index...");
// Test 8, 16 and 32-bit reads and index
// Note at index 0 the register values are typically undefined (Bxxxxxxxx)
Serial.println(tft.readcommand8(ILI9341_RDID4, 2), HEX);
Serial.println(tft.readcommand16(ILI9341_RDID4, 2), HEX);
+2 -2
View File
@@ -1,5 +1,5 @@
// Spiro
// Rainbow patern generator
// Rainbow pattern generator
#include <TFT_eSPI.h> // Hardware-specific library
#include <SPI.h>
@@ -67,7 +67,7 @@ unsigned int rainbow(int value)
// Value is expected to be in range 0-127
// The value is converted to a spectrum colour from 0 = blue through to red = blue
//int value = random (128);
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
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
@@ -59,7 +59,7 @@ void loop()
int old_screen_x = ((int)sx[i] - 160) * 256 / sz[i] + 160;
int old_screen_y = ((int)sy[i] - 120) * 256 / sz[i] + 120;
// This is a faster pixel drawing function for occassions where many single pixels must be drawn
// This is a faster pixel drawing function for occasions where many single pixels must be drawn
tft.drawPixel(old_screen_x, old_screen_y,TFT_BLACK);
sz[i] -= 2;
@@ -82,7 +82,7 @@ void loop()
unsigned long t1 = micros();
//static char timeMicros[8] = {};
// Calcualte frames per second
// Calculate frames per second
Serial.println(1.0/((t1 - t0)/1000000.0));
}
@@ -7,7 +7,7 @@
Connect GND to target board GND
Connect RX line to TX line of target board
Make sure the target and terminal have the same baud rate
and serial stettings!
and serial settings!
The sketch works with the ILI9341 TFT 240x320 display and
the called up libraries.
@@ -117,7 +117,7 @@ void loop(void)
d = -d;
}
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(TFT_MAGENTA);
tft.setTextSize(2);
@@ -362,9 +362,9 @@ uint32_t testHaD()
tft.setTextColor(TFT_YELLOW);
tft.setTextSize(2);
tft.setCursor(8, 285);
tft.setcursor(8, 285);
tft.print(F("http://hackaday.io/"));
tft.setCursor(96, 302);
tft.setcursor(96, 302);
tft.print(F("Xark"));
delay(3 * 1000L);
@@ -389,7 +389,7 @@ uint32_t testText()
{
tft.fillScreen(TFT_BLACK);
uint32_t start = micros_start();
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1);
tft.println(F("Hello World!"));
tft.setTextSize(2);
@@ -121,7 +121,7 @@ unsigned long testFillScreen() {
unsigned long testText() {
tft.fillScreen(TFT_BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(TFT_WHITE); tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
@@ -38,7 +38,7 @@ void setup() {
tft.fillScreen(TFT_BLACK);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE);
tft.setCursor(0, 0);
tft.setcursor(0, 0);
}
@@ -48,11 +48,11 @@ void loop() {
tft.fillScreen(TFT_BLACK);
tft.setTextSize(2);
tft.setTextColor(TFT_WHITE);
tft.setCursor(40, 5);
tft.setcursor(40, 5);
tft.println(F("Arduino"));
tft.setCursor(35, 25);
tft.setcursor(35, 25);
tft.println(F("Cellular"));
tft.setCursor(35, 45);
tft.setcursor(35, 45);
tft.println(F("Automata"));
delay(1000);
@@ -56,7 +56,7 @@ void loop() {
// For comaptibility with Adafruit_GFX library the text background is not plotted when using the print class
// even if we specify it.
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
tft.setCursor(xpos, ypos); // Set cursor near top left corner of screen
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
tft.println(); // Move cursor down a line
@@ -249,7 +249,7 @@ void drawDatum(int x, int y)
// There follows a crude way of flagging that this example sketch needs fonts which
// have not been enbabled in the User_Setup.h file inside the TFT_HX8357 library.
// have not been enabled in the User_Setup.h file inside the TFT_HX8357 library.
//
// These lines produce errors during compile time if settings in User_Setup are not correct
//
@@ -3,8 +3,8 @@
button handling class, this sketch is based on the Arduin-o-phone
example.
This example diplays a keypad where numbers can be entered and
send to the Serial Monitor window.
This example displays a keypad where numbers can be entered and
sent to the Serial Monitor window.
The sketch has been tested on the ESP8266 (which supports SPIFFS)
@@ -167,7 +167,7 @@ void loop(void) {
// Update the number display field
tft.setTextDatum(TL_DATUM); // Use top left corner as text coord datum
tft.setFreeFont(&FreeSans18pt7b); // Choose a nicefont that fits box
tft.setFreeFont(&FreeSans18pt7b); // Choose a nice font that fits box
tft.setTextColor(DISP_TCOLOR); // Set the font colour
// Draw the string, the value returned is the width in pixels
@@ -212,7 +212,7 @@ void touch_calibrate()
// check file system exists
if (!SPIFFS.begin()) {
Serial.println("Formating file system");
Serial.println("formatting file system");
SPIFFS.format();
SPIFFS.begin();
}
@@ -241,7 +241,7 @@ void touch_calibrate()
} else {
// data not valid so recalibrate
tft.fillScreen(TFT_BLACK);
tft.setCursor(20, 0);
tft.setcursor(20, 0);
tft.setTextFont(2);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -275,7 +275,7 @@ void touch_calibrate()
// Print something in the mini status bar
void status(const char *msg) {
tft.setTextPadding(240);
//tft.setCursor(STATUS_X, STATUS_Y);
//tft.setcursor(STATUS_X, STATUS_Y);
tft.setTextColor(TFT_WHITE, TFT_DARKGREY);
tft.setTextFont(0);
tft.setTextDatum(TC_DATUM);
@@ -49,7 +49,7 @@ void setup(void) {
void loop() {
if (updateTime <= millis()) {
updateTime = millis() + 35; // Update emter every 35 milliseconds
updateTime = millis() + 35; // Update meter every 35 milliseconds
// Create a Sine wave for testing
d += 4; if (d >= 360) d = 0;
@@ -77,7 +77,7 @@ void analogMeter()
// Long scale tick length
int tl = 15;
// Coodinates of tick to draw
// Coordinates of tick to draw
float sx = cos((i - 90) * 0.0174532925);
float sy = sin((i - 90) * 0.0174532925);
uint16_t x0 = sx * (M_SIZE*100 + tl) + M_SIZE*120;
@@ -177,7 +177,7 @@ void plotNeedle(int value, byte ms_delay)
if (ms_delay == 0) old_analog = value; // Update immediately if delay is 0
float sdeg = map(old_analog, -10, 110, -150, -30); // Map value to angle
// Calcualte tip of needle coords
// Calculate tip of needle coords
float sx = cos(sdeg * 0.0174532925);
float sy = sin(sdeg * 0.0174532925);
+2 -2
View File
@@ -97,7 +97,7 @@ void analogMeter()
// Long scale tick length
int tl = 15;
// Coodinates of tick to draw
// Coordinates of tick to draw
float sx = cos((i - 90) * 0.0174532925);
float sy = sin((i - 90) * 0.0174532925);
uint16_t x0 = sx * (100 + tl) + 120;
@@ -197,7 +197,7 @@ void plotNeedle(int value, byte ms_delay)
if (ms_delay == 0) old_analog = value; // Update immediately id delay is 0
float sdeg = map(old_analog, -10, 110, -150, -30); // Map value to angle
// Calcualte tip of needle coords
// Calculate tip of needle coords
float sx = cos(sdeg * 0.0174532925);
float sy = sin(sdeg * 0.0174532925);
@@ -1,5 +1,5 @@
/*
Test the tft.print() viz the libraries embedded write() function
Test the tft.print() viz. the libraries embedded write() function
This sketch used font 2, 4, 7
@@ -34,7 +34,7 @@ void loop() {
// Set "cursor" at top left corner of display (0,0) and select font 2
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0, 2);
tft.setcursor(0, 0, 2);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1);
// We can now plot text on screen using the "print" class
@@ -44,13 +44,13 @@ void loop() {
// The standard AdaFruit font still works as before
tft.setTextColor(TFT_BLACK); // Background is not defined so it is transparent
tft.setCursor (100, 5);
tft.setcursor (100, 5);
tft.setTextFont(1); // Select font 1 which is the Adafruit GLCD font
tft.print("Original Adafruit font!");
// The new larger fonts do not need to use the .setCursor call, coords are embedded
// The new larger fonts do not need to use the .setcursor call, coords are embedded
tft.setTextColor(TFT_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!)
// Overlay the black text on top of the rainbow plot (the advantage of not drawing the background colour!)
tft.drawCentreString("Font size 2", 160, 14, 2); // Draw text centre at position 120, 14 using font 2
tft.drawCentreString("Font size 4", 160, 30, 4); // Draw text centre at position 120, 30 using font 4
tft.drawCentreString("12.34", 160, 54, 6); // Draw text centre at position 120, 54 using font 6
@@ -69,15 +69,15 @@ void loop() {
tft.setTextSize(1); // We are using a text size multiplier of 1
tft.setTextColor(TFT_BLACK); // Set text colour to black, no background (so transparent)
tft.setCursor(76, 150, 4); // Set cursor to x = 76, y = 150 and use font 4
tft.setcursor(76, 150, 4); // Set cursor to x = 76, y = 150 and use font 4
tft.println("Transparent..."); // As we use println, the cursor moves to the next line
tft.setCursor(70, 175); // Set cursor to x = 70, y = 175
tft.setcursor(70, 175); // Set cursor to x = 70, y = 175
tft.setTextColor(TFT_WHITE, TFT_BLACK); // Set text colour to white and background to black
tft.println("White on black");
tft.setTextFont(4); // Select font 4 without moving cursor
tft.setCursor(00, 210); // Set cursor to x = 90, y = 210 without changing the font
tft.setcursor(00, 210); // Set cursor to x = 90, y = 210 without changing the font
tft.setTextColor(TFT_WHITE);
// By using the print class we can use all the formatting features like printing HEX
@@ -100,7 +100,7 @@ void loop() {
// Fill screen with a rainbow pattern
void rainbow_fill()
{
// The colours and state are not initialised so the start colour changes each time the funtion is called
// The colours and state are not initialised so the start colour changes each time the function is called
for (int i = 479; i > 0; i--) {
// Draw a vertical line 1 pixel wide in the selected colour
@@ -1,8 +1,8 @@
// Sketch to display images on a 480 x 320 ILI9486 Raspberry Pi 3.5" TFT (Waveshare design)
// which has a 16 bit serial interface based on 74HC04, 74HC4040 and 2 x 74HC4094 logic chips
// which has a 16-bit serial interface based on 74HC04, 74HC4040 and 2 x 74HC4094 logic chips
// Renders images stored in an array in program (FLASH)JPEG images are stored in header files
// (see jpeg1.h etc)
// (see jpeg1.h etc.)
// The sketch does not need the SD or sdFat libraries since it does not access an SD Card.
@@ -108,7 +108,7 @@ void drawArrayJpeg(const uint8_t arrayname[], uint32_t array_size, int xpos, int
// fit totally on the screen are cropped to the nearest MCU size and may leave right/bottom borders.
void renderJPEG(int xpos, int ypos) {
// retrieve infomration about the image
// retrieve information about the image
uint16_t *pImg;
uint16_t mcu_w = JpegDec.MCUWidth;
uint16_t mcu_h = JpegDec.MCUHeight;
@@ -222,12 +222,12 @@ void jpegInfo() {
// Show the execution time (optional)
//####################################################################################################
// WARNING: for UNO/AVR legacy reasons printing text to the screen with the Mega might not work for
// sketch sizes greater than ~70KBytes because 16 bit address pointers are used in some libraries.
// sketch sizes greater than ~70KBytes because 16-bit address pointers are used in some libraries.
// The Due will work fine with the HX8357_Due library.
void showTime(uint32_t msTime) {
//tft.setCursor(0, 0);
//tft.setcursor(0, 0);
//tft.setTextFont(1);
//tft.setTextSize(2);
//tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -121,7 +121,7 @@ unsigned long testFillScreen() {
unsigned long testText() {
tft.fillScreen(TFT_BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(TFT_WHITE); tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
@@ -13,7 +13,7 @@
#define GREEN2RED 4
#define RED2GREEN 5
#define TFT_GREY 0x2104 // Dark grey 16 bit colour
#define TFT_GREY 0x2104 // Dark grey 16-bit colour
#include "Alert.h" // Out of range alert icon
@@ -127,8 +127,8 @@ int ringMeter(int value, int vmin, int vmax, int x, int y, int r, const char *un
case 1: colour = TFT_GREEN; break; // Fixed colour
case 2: colour = TFT_BLUE; break; // Fixed colour
case 3: colour = rainbow(map(i, -angle, angle, 0, 127)); break; // Full spectrum blue to red
case 4: colour = rainbow(map(i, -angle, angle, 70, 127)); break; // Green to red (high temperature etc)
case 5: colour = rainbow(map(i, -angle, angle, 127, 63)); break; // Red to green (low battery etc)
case 4: colour = rainbow(map(i, -angle, angle, 70, 127)); break; // Green to red (high temperature etc.)
case 5: colour = rainbow(map(i, -angle, angle, 127, 63)); break; // Red to green (low battery etc.)
default: colour = TFT_BLUE; break; // Fixed colour
}
tft.fillTriangle(x0, y0, x1, y1, x2, y2, colour);
@@ -193,14 +193,14 @@ void drawAlert(int x, int y , int side, bool draw)
}
// #########################################################################
// Return a 16 bit rainbow colour
// 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 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
@@ -17,13 +17,13 @@ void setup(void) {
tft.setRotation(3);
tft.fillScreen((0xFFFF));
tft.setCursor(20, 0, 2);
tft.setcursor(20, 0, 2);
tft.setTextColor(TFT_BLACK, TFT_WHITE); tft.setTextSize(1);
tft.println("calibration run");
// check file system
if (!SPIFFS.begin()) {
Serial.println("formating file system");
Serial.println("formatting file system");
SPIFFS.format();
SPIFFS.begin();
@@ -62,9 +62,9 @@ void loop() {
if (tft.getTouch(&x, &y)) {
tft.setCursor(5, 5, 2);
tft.setcursor(5, 5, 2);
tft.printf("x: %i ", x);
tft.setCursor(5, 20, 2);
tft.setcursor(5, 20, 2);
tft.printf("y: %i ", y);
tft.drawPixel(x, y, color);
@@ -153,7 +153,7 @@ void drawUpdate (bool sel) {
}
// #########################################################################
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// #########################################################################
uint16_t rainbow(byte value)
{
@@ -163,7 +163,7 @@ uint16_t rainbow(byte value)
value = value % 192;
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
byte red = 0; // Red is the top 5 bits of a 16-bit colour value
byte green = 0; // Green is the middle 6 bits, but only top 5 bits used here
byte blue = 0; // Blue is the bottom 5 bits
@@ -76,7 +76,7 @@ void setup()
tft.setSwapBytes(true);
// The decoder must be given the exact name of the rendering function above
TJpgDec.setCallback(tft_output);
TJpgDec.setcallback(tft_output);
}
void loop()
@@ -2,7 +2,7 @@
// https://en.wikipedia.org/wiki/Direct_memory_access
// Tested with ESP32, Nucleo 64 STM32F446RE and Nucleo 144 STM32F767ZI
// TFT's with SPI can use DMA, the sketch also works with 8 bit
// TFT's with SPI can use DMA, the sketch also works with 8-bit
// parallel TFT's (tested with ILI9341 and ILI9481)
// The sketch will run on processors without DMA and also parallel
@@ -36,7 +36,7 @@
// Color depth has to be 16 bits if DMA is used to render image
#define COLOR_DEPTH 16
// 128x128 for a 16 bit colour Sprite (32Kbytes RAM)
// 128x128 for a 16-bit colour Sprite (32Kbytes RAM)
// Maximum is 181x181 (64Kbytes) for DMA - restricted by processor design
#define IWIDTH 128
#define IHEIGHT 128
@@ -147,8 +147,8 @@ void setup() {
ypos = (tft.height() - IHEIGHT) / 2;
// Define cprite colour depth
spr[0].setColorDepth(COLOR_DEPTH);
spr[1].setColorDepth(COLOR_DEPTH);
spr[0].setcolorDepth(COLOR_DEPTH);
spr[1].setcolorDepth(COLOR_DEPTH);
// Create the 2 sprites
sprPtr[0] = (uint16_t*)spr[0].createSprite(IWIDTH, IHEIGHT);
+1 -1
View File
@@ -19,7 +19,7 @@
// Blue Pill overclocked to 128MHz *no* DMA - 32MHz SPI 64 fps
// Blue Pill overclocked to 128MHz with DMA - 32MHz SPI 116 fps
// ESP32 - 8 bit parallel 110 fps (no DMA)
// ESP32 - 8-bit parallel 110 fps (no DMA)
// ESP32 - 40MHz SPI *no* DMA 93 fps
// ESP32 - 40MHz SPI with DMA 112 fps
@@ -132,7 +132,7 @@ void touch_calibrate()
// check file system exists
if (!LittleFS.begin()) {
Serial.println("Formating file system");
Serial.println("formatting file system");
LittleFS.format();
LittleFS.begin();
}
@@ -161,7 +161,7 @@ void touch_calibrate()
} else {
// data not valid so recalibrate
tft.fillScreen(TFT_BLACK);
tft.setCursor(20, 0);
tft.setcursor(20, 0);
tft.setTextFont(2);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -66,7 +66,7 @@ void loop() {
if (gy < -500.0) delta = 10.0;
gy += delta;
// If the end of the graph x ais is reached start a new trace at 0.0,0.0
// If the end of the graph x axis is reached start a new trace at 0.0,0.0
if (gx > gxHigh) {
gx = 0.0;
gy = 0.0;
@@ -1,4 +1,4 @@
// Demonstrate graph widget functions with two independant trace instances
// Demonstrate graph widget functions with two independent trace instances
// Multiple traces can be drawn at a time with multiple trace instances
// Note: Traces are automatically clipped at graph boundaries by widget library
@@ -142,7 +142,7 @@ void touch_calibrate()
// check file system exists
if (!LittleFS.begin()) {
Serial.println("Formating file system");
Serial.println("formatting file system");
LittleFS.format();
LittleFS.begin();
}
@@ -171,7 +171,7 @@ void touch_calibrate()
} else {
// data not valid so recalibrate
tft.fillScreen(TFT_BLACK);
tft.setCursor(20, 0);
tft.setcursor(20, 0);
tft.setTextFont(2);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
+1 -1
View File
@@ -64,7 +64,7 @@
// JOYSTICK_X_PIN and JOYSTICK_Y_PIN specify analog input pins for manually
// controlling the eye with an analog joystick. If set to -1 or if not
// defined, the eye will move on its own.
// IRIS_PIN speficies an analog input pin for a photocell to make pupils
// IRIS_PIN specifies an analog input pin for a photocell to make pupils
// react to light (or potentiometer for manual control). If set to -1 or
// if not defined, the pupils will change on their own.
// BLINK_PIN specifies an input pin for a button (to ground) that will
@@ -11,7 +11,7 @@
// boards and WILL NOT work on normal Arduino or other boards!
//
// SEE FILE "config.h" FOR MOST CONFIGURATION (graphics, pins, display type,
// etc). Probably won't need to edit THIS file unless you're doing some
// etc.). Probably won't need to edit THIS file unless you're doing some
// extremely custom modifications.
//
// Adafruit invests time and resources providing this open source code,
@@ -91,7 +91,7 @@ void updateEye (void)
// EYE-RENDERING FUNCTION --------------------------------------------------
void drawEye( // Renders one eye. Inputs must be pre-clipped & valid.
// Use native 32 bit variables where possible as this is 10% faster!
// Use native 32-bit variables where possible as this is 10% faster!
uint8_t e, // Eye array index; 0 or 1 for left/right
uint32_t iScale, // Scale factor for iris
uint32_t scleraX, // First pixel X offset into sclera image
+1 -1
View File
@@ -64,7 +64,7 @@
// JOYSTICK_X_PIN and JOYSTICK_Y_PIN specify analog input pins for manually
// controlling the eye with an analog joystick. If set to -1 or if not
// defined, the eye will move on its own.
// IRIS_PIN speficies an analog input pin for a photocell to make pupils
// IRIS_PIN specifies an analog input pin for a photocell to make pupils
// react to light (or potentiometer for manual control). If set to -1 or
// if not defined, the pupils will change on their own.
// BLINK_PIN specifies an input pin for a button (to ground) that will
@@ -11,7 +11,7 @@
// boards and WILL NOT work on normal Arduino or other boards!
//
// SEE FILE "config.h" FOR MOST CONFIGURATION (graphics, pins, display type,
// etc). Probably won't need to edit THIS file unless you're doing some
// etc.). Probably won't need to edit THIS file unless you're doing some
// extremely custom modifications.
//
// Adafruit invests time and resources providing this open source code,
@@ -91,7 +91,7 @@ void updateEye (void)
// EYE-RENDERING FUNCTION --------------------------------------------------
void drawEye( // Renders one eye. Inputs must be pre-clipped & valid.
// Use native 32 bit variables where possible as this is 10% faster!
// Use native 32-bit variables where possible as this is 10% faster!
uint8_t e, // Eye array index; 0 or 1 for left/right
uint32_t iScale, // Scale factor for iris
uint32_t scleraX, // First pixel X offset into sclera image
@@ -249,12 +249,12 @@ void jpegInfo() {
// Show the execution time (optional)
//####################################################################################################
// WARNING: for UNO/AVR legacy reasons printing text to the screen with the Mega might not work for
// sketch sizes greater than ~70KBytes because 16 bit address pointers are used in some libraries.
// sketch sizes greater than ~70KBytes because 16-bit address pointers are used in some libraries.
// The Due will work fine with the HX8357_Due library.
void showTime(uint32_t msTime) {
//tft.setCursor(0, 0);
//tft.setcursor(0, 0);
//tft.setTextFont(1);
//tft.setTextSize(2);
//tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -120,7 +120,7 @@ void setup(void) {
// EYE-RENDERING FUNCTION --------------------------------------------------
#define BUFFER_SIZE 256 // 64 to 512 seems optimum = 30 fps for default eye
void drawEye( // Renders one eye. Inputs must be pre-clipped & valid.
// Use native 32 bit variables where possible as this is 10% faster!
// Use native 32-bit variables where possible as this is 10% faster!
uint8_t e, // Eye array index; 0 or 1 for left/right
uint32_t iScale, // Scale factor for iris
uint32_t scleraX, // First pixel X offset into sclera image
@@ -134,7 +134,7 @@ void drawEye( // Renders one eye. Inputs must be pre-clipped & valid.
uint32_t d;
uint32_t pixels = 0;
uint16_t pbuffer[BUFFER_SIZE]; // This one needs to be 16 bit
uint16_t pbuffer[BUFFER_SIZE]; // This one needs to be 16-bit
// Set up raw pixel dump to entire screen. Although such writes can wrap
// around automatically from end of rect back to beginning, the region is
@@ -58,7 +58,7 @@ void screenshotToConsole()
// Get first pixel to prime the Run Length Encoded
// Function format is: tft.readRectRGB( x, y, width, height, buffer);
// color is a pointer to a buffer that the RGB 8 bit values are piped into
// color is a pointer to a buffer that the RGB 8-bit values are piped into
// the buffer size must be >= (width * height * 3) bytes
eye[e].tft.readRectRGB(0, 0, 1, 1, color); // 1 x 1 so reading 1 pixel at 0,0
@@ -27,11 +27,11 @@ void setup(void) {
void loop()
{
tft.fillRectHGradient(0, 0, 160, 50, TFT_MAGENTA, TFT_BLUE);
tft.setCursor(10,10);
tft.setcursor(10,10);
tft.print("Horizontal gradient");
tft.fillRectVGradient(0, 60, 160, 50, TFT_ORANGE, TFT_RED);
tft.setCursor(10,70);
tft.setcursor(10,70);
tft.print("Vertical gradient");
while(1) delay(100); // Wait here
+3 -3
View File
@@ -31,7 +31,7 @@ void loop() {
/* Dessine la fractale */
draw_Julia(-0.8,+0.156,zoom);
tft.fillRect(0, 0, 150, 20, TFT_BLACK);
tft.setCursor(0,15);
tft.setcursor(0,15);
tft.setTextColor(TFT_WHITE);
tft.print(" Zoom = ");
tft.println(zoom);
@@ -46,12 +46,12 @@ void loop() {
void draw_Julia(float c_r, float c_i, float zoom) {
tft.setCursor(0,0);
tft.setcursor(0,0);
float new_r = 0.0, new_i = 0.0, old_r = 0.0, old_i = 0.0;
/* Pour chaque pixel en X */
for(int16_t x = SCREEN_WIDTH/2 - 1; x >= 0; x--) { // Rely on inverted symettry
for(int16_t x = SCREEN_WIDTH/2 - 1; x >= 0; x--) { // Rely on inverted symmetry
/* Pour chaque pixel en Y */
for(uint16_t y = 0; y < SCREEN_HEIGHT; y++) {
old_r = 1.5 * (x - SCREEN_WIDTH / 2) / (0.5 * zoom * SCREEN_WIDTH);
@@ -112,7 +112,7 @@ void loop() {
// Setting textDatum does nothing when using tft.print
tft.fillScreen(TFT_BLUE); // Clear screen
tft.setCursor(0,60); // To be compatible with Adafruit_GFX the cursor datum is always bottom left
tft.setcursor(0,60); // To be compatible with Adafruit_GFX the cursor datum is always bottom left
tft.print("âäàå"); // Using tft.print means text background is NEVER rendered
delay(2000);
@@ -144,7 +144,7 @@ void touch_calibrate()
} else {
// data not valid so recalibrate
tft.fillScreen(TFT_BLACK);
tft.setCursor(20, 0);
tft.setcursor(20, 0);
tft.setTextFont(2);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -162,7 +162,7 @@ void touch_calibrate()
} else {
// data not valid so recalibrate
tft.fillScreen(TFT_BLACK);
tft.setCursor(20, 0);
tft.setcursor(20, 0);
tft.setTextFont(2);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -1,4 +1,4 @@
// Icon images are stored in tabs ^ e.g. Alert.h etc above this line
// Icon images are stored in tabs ^ e.g. Alert.h etc.above this line
// more than one icon can be in a header file
// Arrays containing FLASH images can be created with UTFT library tool:
@@ -46,7 +46,7 @@ void drawBmp(const char *filename, int16_t x, int16_t y) {
bmpFS.read(lineBuffer, sizeof(lineBuffer));
uint8_t* bptr = lineBuffer;
uint16_t* tptr = (uint16_t*)lineBuffer;
// Convert 24 to 16 bit colours
// Convert 24 to 16-bit colours
for (uint16_t col = 0; col < w; col++)
{
b = *bptr++;
@@ -84,7 +84,7 @@ void loop() {
tft.setTextFont(0); // Select font 0 which is the Adafruit font
tft.drawString("Original Adafruit font!", xpos, 5);
// The new larger fonts do not need to use the .setCursor call, coords are embedded
// The new larger fonts do not need to use the .setcursor call, coords are embedded
tft.setTextColor(TFT_BLACK); // Do not plot the background colour
// Overlay the black text on top of the rainbow plot (the advantage of not drawing the background colour!)
@@ -63,7 +63,7 @@ int max_allowed = 1000; // Maximum number of save images allowed before a resta
// These are default values, this sketch obtains the actual values from the Arduino board
int tft_width = 480; // default TFT width (automatic - sent by Arduino)
int tft_height = 480; // default TFT height (automatic - sent by Arduino)
int color_bytes = 2; // 2 for 16 bit, 3 for three RGB bytes (automatic - sent by Arduino)
int color_bytes = 2; // 2 for 16-bit, 3 for three RGB bytes (automatic - sent by Arduino)
import processing.serial.*;
@@ -2,8 +2,8 @@
// over the serial port. Use a high baud rate, e.g. for an ESP8266:
// Serial.begin(921600);
// At 921600 baud a 320 x 240 image with 16 bit colour transfers can be sent to the
// PC client in ~1.67s and 24 bit colour in ~2.5s which is close to the theoretical
// At 921600 baud a 320 x 240 image with 16-bit colour transfers can be sent to the
// PC client in ~1.67s and 24-bit colour in ~2.5s which is close to the theoretical
// minimum transfer time.
// This sketch has been created to work with the TFT_eSPI library here:
@@ -40,7 +40,7 @@
// Number of pixels to send in a burst (minimum of 1), no benefit above 8
// NPIXELS values and render times:
// NPIXELS 1 = use readPixel() = >5s and 16 bit pixels only
// NPIXELS 1 = use readPixel() = >5s and 16-bit pixels only
// NPIXELS >1 using rectRead() 2 = 1.75s, 4 = 1.68s, 8 = 1.67s
#define NPIXELS 8 // Must be integer division of both TFT width and TFT height
@@ -104,7 +104,7 @@ bool serialScreenServer(String filename)
wait = false; // No need to wait anymore
lastCmdTime = millis(); // Set last received command time
// Send screen size etc using a simple header with delimiters for client checks
// Send screen size etc.using a simple header with delimiters for client checks
sendParameters(filename);
}
}
@@ -169,7 +169,7 @@ bool serialScreenServer(String filename)
}
//====================================================================================
// Send screen size etc using a simple header with delimiters for client checks
// Send screen size etc.using a simple header with delimiters for client checks
//====================================================================================
void sendParameters(String filename)
{
@@ -183,7 +183,7 @@ void sendParameters(String filename)
Serial.write('Y'); // Bits per pixel (16 or 24)
if (NPIXELS > 1) Serial.write(BITS_PER_PIXEL);
else Serial.write(16); // readPixel() only provides 16 bit values
else Serial.write(16); // readPixel() only provides 16-bit values
Serial.write('?'); // Filename next
Serial.print(filename);
@@ -66,7 +66,7 @@ void touch_calibrate()
// Calibrate
tft.fillScreen(TFT_BLACK);
tft.setCursor(20, 0);
tft.setcursor(20, 0);
tft.setTextFont(2);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -10,7 +10,7 @@
// Viewports have a number of potential uses:
// - create a "virtual" TFT screen smaller than the actual TFT screen
// - render GUI items (menus etc) in a viewport, erase GUI item by redrawing whole screen,
// - render GUI items (menus etc.) in a viewport, erase GUI item by redrawing whole screen,
// this will be fast because only the viewport will be refreshed (e.g. clearing menu)
// - limit screen refresh to a particular area, e.g. changing numbers, icons or graph plotting
// - showing a small portion of a larger image or sprite, this allows panning and scrolling
@@ -134,7 +134,7 @@ unsigned long testFillScreen() {
unsigned long testText() {
tft.fillScreen(TFT_BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
tft.setcursor(0, 0);
tft.setTextColor(TFT_WHITE); tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
@@ -6,7 +6,7 @@
blendedColor = tft.alphaBlend(alpha, fg_color, bg_color);
The alphaBlend() function operates on 16 bit colours only
The alphaBlend() function operates on 16-bit colours only
A test is included where the colours are mapped to 8 bits after blending
Information on alpha blending is here
@@ -43,7 +43,7 @@ void setup(void) {
// -------------------------------------------------------------------------
void loop()
{
// 16 bit colours (5 bits red, 6 bits green, 5 bits blue)
// 16-bit colours (5 bits red, 6 bits green, 5 bits blue)
// Blend from white to full spectrum
for (int a = 0; a < 256; a+=2) // Alpha 0 = 100% background, alpha 255 = 100% foreground
{
@@ -79,18 +79,18 @@ void loop()
delay(4000);
//*
// Decrease to 8 bit colour (3 bits red, 3 bits green, 2 bits blue)
// Decrease to 8-bit colour (3 bits red, 3 bits green, 2 bits blue)
// Blend from white to full spectrum
for (int a = 0; a < 256; a+=2) // Alpha 0 = 100% background, alpha 255 = 100% foreground
{
// Convert blended 16 bit colour to 8 bits to reduce colour resolution, then map back to 16 bits for displaying
// Convert blended 16-bit colour to 8 bits to reduce colour resolution, then map back to 16 bits for displaying
for (int c = 0; c < 192; c++) tft.drawPixel(c, a/2, tft.color8to16(tft.color16to8(tft.alphaBlend(a, rainbow(c), 0xFFFF))));
}
// Blend from full spectrum to black
for (int a = 255; a > 2; a-=2)
{
// Convert blended 16 bit colour to 8 bits to reduce colour resolution, then map back to 16 bits for displaying
// Convert blended 16-bit colour to 8 bits to reduce colour resolution, then map back to 16 bits for displaying
for (int c = 0; c < 192; c++) tft.drawPixel(c, 128 + (255-a)/2, tft.color8to16(tft.color16to8(tft.alphaBlend(a, rainbow(c), 0))));
}
@@ -108,7 +108,7 @@ void loop()
//*/
/*
// 16 bit colours (5 bits red, 6 bits green, 5 bits blue)
// 16-bit colours (5 bits red, 6 bits green, 5 bits blue)
for (int a = 0; a < 256; a+=2) // Alpha 0 = 100% background, alpha 255 = 100% foreground
{
for (int c = 0; c < 192; c++) tft.drawPixel(c, a/2, tft.alphaBlend(a, rainbow(c), TFT_CYAN));
@@ -137,7 +137,7 @@ void loop()
// #########################################################################
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// #########################################################################
unsigned int rainbow(byte value)
{
@@ -147,7 +147,7 @@ unsigned int rainbow(byte value)
value = value%192;
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
byte red = 0; // Red is the top 5 bits of a 16-bit colour value
byte green = 0; // Green is the middle 6 bits, but only top 5 bits used here
byte blue = 0; // Blue is the bottom 5 bits
+2 -2
View File
@@ -14,9 +14,9 @@
// Include the PNG decoder library
#include <PNGdec.h>
#include "panda.h" // Image is stored here in an 8 bit array
#include "panda.h" // Image is stored here in an 8-bit array
PNG png; // PNG decoder inatance
PNG png; // PNG decoder instance
#define MAX_IMAGE_WIDTH 240 // Adjust for your images
@@ -61,7 +61,7 @@ void loop() {
tft.setTextColor(TFT_WHITE, TFT_BLACK); // Set the font colour AND the background colour
// so the anti-aliasing works
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -102,7 +102,7 @@ void loop() {
// Get ready for the next demo while we have this font loaded
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.println("Wrong and right ways to");
tft.println("print changing values...");
@@ -121,17 +121,17 @@ void loop() {
// Draw changing numbers - does not work unless a filled rectangle is drawn over the old text
for (int i = 0; i <= 99; i++)
{
tft.setCursor(50, 50);
tft.setcursor(50, 50);
tft.setTextColor(TFT_GREEN, TFT_BLACK); // TFT_BLACK is used for anti-aliasing only
// By default background fill is off
tft.print(" "); // Overprinting old number with spaces DOES NOT WORK!
tft.setCursor(50, 50);
tft.setcursor(50, 50);
tft.print(i / 10.0, 1);
// Adding a parameter "true" to the setTextColor() function fills character background
// This extra parameter is only for smooth fonts!
tft.setTextColor(TFT_GREEN, TFT_BLACK, true);
tft.setCursor(50, 90);
tft.setcursor(50, 90);
tft.print(i / 10.0, 1);
delay (200);
@@ -147,7 +147,7 @@ void loop() {
tft.setTextColor(TFT_YELLOW, TFT_BLACK); // Change the font colour and the background colour
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
tft.println("Large font!");
@@ -11,7 +11,7 @@
This sketch uses method 3, the font characters are first plotted in a Sprite, then the
Sprite is pushed to the screen. This method is very flexible and the Sprite can be
created, deleted, resized as needed. To render anti-aliased fonts well the Sprite
needs to be 16 bit. The fonts will render in 1 bit per pixel sprites but there
needs to be 16-bit. The fonts will render in 1 bit per pixel sprites but there
will then be no anti-aliasing. Using 1 bit per pixel Sprites is however useful
to use the extended Unicode range in fonts on mono displays like ePaper.
@@ -50,7 +50,7 @@ void setup(void) {
tft.setRotation(1);
spr.setColorDepth(16); // 16 bit colour needed to show antialiased fonts
spr.setcolorDepth(16); // 16-bit colour needed to show antialiased fonts
}
void loop() {
@@ -93,7 +93,7 @@ void loop() {
tft.fillScreen(TFT_BLACK);
// Beware: Sprites are a differerent "class" to TFT, so different fonts can be loaded
// Beware: Sprites are a different "class" to TFT, so different fonts can be loaded
// in the tft and sprite instances, so load the font in the class instance you use!
// In this example this means the spr. instance.
@@ -181,8 +181,8 @@ void button(int x, int y, int num )
#define IWIDTH 40
#define IHEIGHT 25
// Create a 16 bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
spr.setColorDepth(16);
// Create a 16-bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
spr.setcolorDepth(16);
spr.createSprite(IWIDTH, IHEIGHT);
// Fill it with black (this will be the transparent colour this time)
@@ -58,7 +58,7 @@ void setup(void) {
tft.setRotation(1);
spr.setColorDepth(16); // 16 bit colour needed to show anti-aliased fonts
spr.setcolorDepth(16); // 16-bit colour needed to show anti-aliased fonts
}
void loop() {
@@ -81,7 +81,7 @@ void loop() {
spr.setTextColor(TFT_YELLOW, TFT_BLACK); // Set the sprite font colour and the background colour
tft.setCursor(xpos - 50, ypos); // Set the tft cursor position, yes tft position!
tft.setcursor(xpos - 50, ypos); // Set the tft cursor position, yes tft position!
spr.printToSprite("Small 15pt font"); // Prints to tft cursor position, tft cursor NOT moved
ypos += spr.fontHeight(); // Get the font height and move ypos down
@@ -100,14 +100,14 @@ void loop() {
spr.setTextColor(TFT_WHITE, TFT_BLUE); // Set the font colour and the background colour
tft.setCursor(xpos - 90, ypos); // Set the tft cursor position
tft.setcursor(xpos - 90, ypos); // Set the tft cursor position
spr.printToSprite("36pt font"); // Text is rendered via a minimally sized sprite
ypos += spr.fontHeight(); // Get the font height and move ypos down
// Draw changing numbers - no flicker using this plot method!
for (int i = 0; i <= 200; i++) {
tft.setCursor(10, 10);
tft.setcursor(10, 10);
// Number is converted to String type by (String) (number)
spr.printToSprite(" " + (String) (i / 100.0) + " "); // Space padding helps over-write old numbers
delay (20);
@@ -8,7 +8,7 @@
sketch in the library Tools folder. The Processing sketch can convert
TrueType fonts in *.ttf or *.otf files.
The library supports 16 bit unicode characters:
The library supports 16-bit Unicode characters:
https://en.wikipedia.org/wiki/Unicode_font
The characters supported are in the in the Basic Multilingual Plane:
@@ -60,7 +60,7 @@ void loop() {
// Set "cursor" at top left corner of display (0,0)
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0);
tft.setcursor(0, 0);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -11,7 +11,7 @@
will return the pixel color at a position x,y on the TFT. In this sketch that
function is called gradientColor, so this line is included in setup():
tft.setCallback(gradientColor);
tft.setcallback(gradientColor);
TFT_eSPI will call this function during the rendering of the anti-aliased
font to blend the edges of each character with the returned color.
@@ -66,8 +66,8 @@ void setup(void) {
tft.begin();
tft.setCallback(gradientColor); // Switch on color callback for anti-aliased fonts
//tft.setCallback(nullptr); // Switch off callback (off by default)
tft.setcallback(gradientColor); // Switch on color callback for anti-aliased fonts
//tft.setcallback(nullptr); // Switch off callback (off by default)
tft.setRotation(1);
}
@@ -83,7 +83,7 @@ void loop() {
fillGradient(); // Put here after selecting the font so fontHeight() is already set
tft.setTextColor(TFT_WHITE); // Background color is ignored in gradient area
tft.setCursor(0, 10); // Set cursor at top left of screen
tft.setcursor(0, 10); // Set cursor at top left of screen
uint32_t t = millis();
tft.println(" Ode to a small\n lump of green\n putty I found\n in my armpit\n one midsummer\n morning ");
@@ -9,7 +9,7 @@
that will return the pixel color at a position x,y on the TFT. In this
sketch that function is called pixelColor, so this line is included:
tft.setCallback(pixelColor);
tft.setcallback(pixelColor);
TFT_eSPI will call this function during the rendering of the anti-aliased
font and use it to blend the edges of each character with the screen color.
@@ -43,8 +43,8 @@ void setup(void) {
tft.begin();
tft.setCallback(pixelColor); // Switch on color callback for anti-aliased fonts
//tft.setCallback(nullptr); // Switch off callback (off by default)
tft.setcallback(pixelColor); // Switch on color callback for anti-aliased fonts
//tft.setcallback(nullptr); // Switch off callback (off by default)
tft.setRotation(1);
}
@@ -61,7 +61,7 @@ void loop() {
tft.loadFont(AA_FONT_SMALL);
tft.setTextColor(TFT_BLACK, TFT_WHITE); // Background color is ignored if callback is set
tft.setCursor(0, 10); // Set cursor at top left of screen
tft.setcursor(0, 10); // Set cursor at top left of screen
uint32_t t = millis();
tft.println(" Ode to a small\n lump of green\n putty I found\n in my armpit\n one midsummer\n morning ");
@@ -83,7 +83,7 @@ unsigned int colour = red << 11; // Colour order is RGB 5+6+5 bits each
void rainbow_fill()
{
// The colours and state are not initialised so the start colour changes each time the funtion is called
// The colours and state are not initialised so the start colour changes each time the function is called
for (int i = 319; i >= 0; i--) {
// Draw a vertical line 1 pixel wide in the selected colour
@@ -8,14 +8,14 @@
The library expects strings to be in UTF-8 encoded format:
https://www.fileformat.info/info/unicode/utf8.htm
Creating varaibles needs to be done with care when using character arrays:
Creating variables needs to be done with care when using character arrays:
char c = 'µ'; // Wrong
char bad[4] = "5µA"; // Wrong
char good[] = "5µA"; // Good
String okay = "5µA"; // Good
This is because UTF-8 characters outside the basic Latin set occupy more than
1 byte per character! A 16 bit Unicode character occupies 3 bytes!
1 byte per character! A 16-bit Unicode character occupies 3 bytes!
*/
@@ -77,7 +77,7 @@ void loop()
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
tft.println(test1);
@@ -89,7 +89,7 @@ void loop()
//----------------------------------------------------------------------------
// We can have any random mix of characters in the font
String test2 = "仝倀"; // Unicodes 0x4EDD, 0x5000
String test2 = "仝倀"; // Unicode 0x4EDD, 0x5000
tft.loadFont(Unicode_Test_72);
@@ -99,7 +99,7 @@ void loop()
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
tft.setTextColor(TFT_CYAN, bg);
tft.println(test2);
@@ -129,7 +129,7 @@ void loop()
tft.fillScreen(bg);
tft.setTextColor(TFT_GREEN, bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
tft.println("Konnichiwa");
tft.println(test3);
@@ -80,7 +80,7 @@ void loop() {
tft.setTextColor(TFT_WHITE, TFT_BLACK); // Set the font colour AND the background colour
// so the anti-aliasing works
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -120,7 +120,7 @@ void loop() {
// Get ready for the next demo while we have this font loaded
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.println("Wrong and right ways to");
tft.println("print changing values...");
@@ -139,17 +139,17 @@ void loop() {
// Draw changing numbers - does not work unless a filled rectangle is drawn over the old text
for (int i = 0; i <= 20; i++)
{
tft.setCursor(50, 50);
tft.setcursor(50, 50);
tft.setTextColor(TFT_GREEN, TFT_BLACK); // TFT_BLACK is used for anti-aliasing only
// By default background fill is off
tft.print(" "); // Overprinting old number with spaces DOES NOT WORK!
tft.setCursor(50, 50);
tft.setcursor(50, 50);
tft.print(i / 10.0, 1);
// Adding a parameter "true" to the setTextColor() function fills character background
// This extra parameter is only for smooth fonts!
tft.setTextColor(TFT_GREEN, TFT_BLACK, true);
tft.setCursor(50, 90);
tft.setcursor(50, 90);
tft.print(i / 10.0, 1);
delay (200);
@@ -165,7 +165,7 @@ void loop() {
tft.setTextColor(TFT_YELLOW, TFT_BLACK); // Change the font colour and the background colour
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
tft.println("Large font!");
@@ -4,7 +4,7 @@
This sketch uses method 3, the font characters are first plotted in a Sprite, then the
Sprite is pushed to the screen. This method is very flexible and the Sprite can be
created, deleted, resized as needed. To render anti-aliased fonts well the Sprite
needs to be 16 bit. The fonts will render in 1 bit per pixel sprites but there
needs to be 16-bit. The fonts will render in 1 bit per pixel sprites but there
will then be no anti-aliasing. Using 1 bit per pixel Sprites is however useful
to use the extended Unicode range in fonts on mono displays like ePaper.
@@ -51,7 +51,7 @@ void setup(void) {
tft.setRotation(1);
spr.setColorDepth(16); // 16 bit colour needed to show antialiased fonts
spr.setcolorDepth(16); // 16-bit colour needed to show antialiased fonts
if (!LittleFS.begin()) {
Serial.println("Flash FS initialisation failed!");
@@ -200,8 +200,8 @@ void button(int x, int y, int num )
#define IWIDTH 40
#define IHEIGHT 25
// Create a 16 bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
spr.setColorDepth(16);
// Create a 16-bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
spr.setcolorDepth(16);
spr.createSprite(IWIDTH, IHEIGHT);
// Fill it with black (this will be the transparent colour this time)
@@ -61,7 +61,7 @@ void setup(void) {
tft.setRotation(1);
spr.setColorDepth(16); // 16 bit colour needed to show anti-aliased fonts
spr.setcolorDepth(16); // 16-bit colour needed to show anti-aliased fonts
if (!LittleFS.begin()) {
Serial.println("Flash FS initialisation failed!");
@@ -102,7 +102,7 @@ void loop() {
spr.setTextColor(TFT_YELLOW, TFT_BLACK); // Set the sprite font colour and the background colour
tft.setCursor(xpos - 50, ypos); // Set the tft cursor position, yes tft position!
tft.setcursor(xpos - 50, ypos); // Set the tft cursor position, yes tft position!
spr.printToSprite("Small 15pt font"); // Prints to tft cursor position, tft cursor NOT moved
ypos += spr.fontHeight(); // Get the font height and move ypos down
@@ -121,14 +121,14 @@ void loop() {
spr.setTextColor(TFT_WHITE, TFT_BLUE); // Set the font colour and the background colour
tft.setCursor(xpos - 90, ypos); // Set the tft cursor position
tft.setcursor(xpos - 90, ypos); // Set the tft cursor position
spr.printToSprite("36pt font"); // Text is rendered via a minimally sized sprite
ypos += spr.fontHeight(); // Get the font height and move ypos down
// Draw changing numbers - no flicker using this plot method!
for (int i = 0; i <= 200; i++) {
tft.setCursor(10, 10);
tft.setcursor(10, 10);
// Number is converted to String type by (String) (number)
spr.printToSprite(" " + (String) (i / 100.0) + " "); // Space padding helps over-write old numbers
delay (20);
@@ -12,7 +12,7 @@
sketch in the library Tools folder. The Processing sketch can convert
TrueType fonts in *.ttf or *.otf files.
The library supports 16 bit Unicode characters:
The library supports 16-bit Unicode characters:
https://en.wikipedia.org/wiki/Unicode_font
The characters supported are in the in the Basic Multilingual Plane:
@@ -78,7 +78,7 @@ void loop() {
// Set "cursor" at top left corner of display (0,0)
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0);
tft.setcursor(0, 0);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -10,7 +10,7 @@
that will return the pixel xolor at a position x,y on the TFT. In this
sketch that function is called gradientColor, so this line is included:
tft.setCallback(gradientColor);
tft.setcallback(gradientColor);
TFT_eSPI will call this function during the rendering of the anti-aliased
font to blend the edges of each character with the returned color.
@@ -73,8 +73,8 @@ void setup(void) {
tft.begin();
tft.setCallback(gradientColor); // Switch on color callback for anti-aliased fonts
//tft.setCallback(nullptr); // Switch off callback (off by default)
tft.setcallback(gradientColor); // Switch on color callback for anti-aliased fonts
//tft.setcallback(nullptr); // Switch off callback (off by default)
tft.setRotation(1);
@@ -108,7 +108,7 @@ void loop() {
fillGradient(); // Put here after selecting the font so fontHeight() is already set
tft.setTextColor(TFT_WHITE); // Background color is ignored in gradient area
tft.setCursor(0, 10); // Set cursor at top left of screen
tft.setcursor(0, 10); // Set cursor at top left of screen
uint32_t t = millis();
tft.println(" Ode to a small\n lump of green\n putty I found\n in my armpit\n one midsummer\n morning ");
@@ -10,7 +10,7 @@
that will return the pixel color at a position x,y on the TFT. In this
sketch that function is called pixelColor, so this line is included:
tft.setCallback(pixelColor);
tft.setcallback(pixelColor);
TFT_eSPI will call this function during the rendering of the anti-aliased
font and use it to blend the edges of each character with the screen color.
@@ -52,8 +52,8 @@ void setup(void) {
tft.begin();
tft.setCallback(pixelColor); // The callback is only used during font rendering
//tft.setCallback(nullptr); // Switch off callback (off by default)
tft.setcallback(pixelColor); // The callback is only used during font rendering
//tft.setcallback(nullptr); // Switch off callback (off by default)
tft.setRotation(1);
@@ -88,7 +88,7 @@ void loop() {
tft.loadFont(AA_FONT_SMALL, LittleFS);
tft.setTextColor(TFT_BLACK, TFT_WHITE); // Background color is ignored if callback is set
tft.setCursor(0, 10); // Set cursor at top left of screen
tft.setcursor(0, 10); // Set cursor at top left of screen
uint32_t t = millis();
tft.println(" Ode to a small\n lump of green\n putty I found\n in my armpit\n one midsummer\n morning ");
@@ -15,7 +15,7 @@
String okay = "5µA"; // Good
This is because UTF-8 characters outside the basic Latin set occupy more than
1 byte per character! A 16 bit Unicode character occupies 3 bytes!
1 byte per character! A 16-bit Unicode character occupies 3 bytes!
*/
@@ -82,7 +82,7 @@ void loop()
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
tft.println(test1);
@@ -104,7 +104,7 @@ void loop()
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
uint32_t dt = millis();
tft.setTextColor(TFT_CYAN, bg);
tft.println(test2);
@@ -134,7 +134,7 @@ dt = millis();
Serial.println(millis()-dt);
tft.fillScreen(bg);
tft.setTextColor(TFT_GREEN, bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
dt = millis();
tft.println("Konnichiwa");
tft.println(test3);
@@ -10,7 +10,7 @@
Load the font file onto the root directory of the SD Card. The font files
used by this sketch can be found in the Data folder, press Ctrl+K to see it.
The library supports 16 bit Unicode characters:
The library supports 16-bit Unicode characters:
https://en.wikipedia.org/wiki/Unicode_font
The characters supported are in the in the Basic Multilingual Plane:
@@ -103,7 +103,7 @@ void loop() {
// Set "cursor" at top left corner of display (0,0)
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0);
tft.setcursor(0, 0);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -81,7 +81,7 @@ void loop() {
tft.setTextColor(TFT_WHITE, TFT_BLACK); // Set the font colour AND the background colour
// so the anti-aliasing works
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -121,7 +121,7 @@ void loop() {
// Get ready for the next demo while we have this font loaded
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.println("Wrong and right ways to");
tft.println("print changing values...");
@@ -140,17 +140,17 @@ void loop() {
// Draw changing numbers - does not work unless a filled rectangle is drawn over the old text
for (int i = 0; i <= 20; i++)
{
tft.setCursor(50, 50);
tft.setcursor(50, 50);
tft.setTextColor(TFT_GREEN, TFT_BLACK); // TFT_BLACK is used for anti-aliasing only
// By default background fill is off
tft.print(" "); // Overprinting old number with spaces DOES NOT WORK!
tft.setCursor(50, 50);
tft.setcursor(50, 50);
tft.print(i / 10.0, 1);
// Adding a parameter "true" to the setTextColor() function fills character background
// This extra parameter is only for smooth fonts!
tft.setTextColor(TFT_GREEN, TFT_BLACK, true);
tft.setCursor(50, 90);
tft.setcursor(50, 90);
tft.print(i / 10.0, 1);
delay (200);
@@ -166,7 +166,7 @@ void loop() {
tft.setTextColor(TFT_YELLOW, TFT_BLACK); // Change the font colour and the background colour
tft.setCursor(0, 0); // Set cursor at top left of screen
tft.setcursor(0, 0); // Set cursor at top left of screen
tft.println("Large font!");
@@ -4,7 +4,7 @@
This sketch uses method 3, the font characters are first plotted in a Sprite, then the
Sprite is pushed to the screen. This method is very flexible and the Sprite can be
created, deleted, resized as needed. To render anti-aliased fonts well the Sprite
needs to be 16 bit. The fonts will render in 1 bit per pixel sprites but there
needs to be 16-bit. The fonts will render in 1 bit per pixel sprites but there
will then be no anti-aliasing. Using 1 bit per pixel Sprites is however useful
to use the extended Unicode range in fonts on mono displays like ePaper.
@@ -50,7 +50,7 @@ void setup(void) {
tft.setRotation(1);
spr.setColorDepth(16); // 16 bit colour needed to show anti aliased fonts
spr.setcolorDepth(16); // 16-bit colour needed to show anti aliased fonts
if (!SPIFFS.begin()) {
Serial.println("SPIFFS initialisation failed!");
@@ -200,8 +200,8 @@ void button(int x, int y, int num )
#define IWIDTH 40
#define IHEIGHT 25
// Create a 16 bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
spr.setColorDepth(16);
// Create a 16-bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
spr.setcolorDepth(16);
spr.createSprite(IWIDTH, IHEIGHT);
// Fill it with black (this will be the transparent colour this time)
@@ -61,7 +61,7 @@ void setup(void) {
tft.setRotation(1);
spr.setColorDepth(16); // 16 bit colour needed to show anti-aliased fonts
spr.setcolorDepth(16); // 16-bit colour needed to show anti-aliased fonts
if (!SPIFFS.begin()) {
Serial.println("SPIFFS initialisation failed!");
@@ -102,7 +102,7 @@ void loop() {
spr.setTextColor(TFT_YELLOW, TFT_BLACK); // Set the sprite font colour and the background colour
tft.setCursor(xpos - 50, ypos); // Set the tft cursor position, yes tft position!
tft.setcursor(xpos - 50, ypos); // Set the tft cursor position, yes tft position!
spr.printToSprite("Small 15pt font"); // Prints to tft cursor position, tft cursor NOT moved
ypos += spr.fontHeight(); // Get the font height and move ypos down
@@ -121,14 +121,14 @@ void loop() {
spr.setTextColor(TFT_WHITE, TFT_BLUE); // Set the font colour and the background colour
tft.setCursor(xpos - 90, ypos); // Set the tft cursor position
tft.setcursor(xpos - 90, ypos); // Set the tft cursor position
spr.printToSprite("36pt font"); // Text is rendered via a minimally sized sprite
ypos += spr.fontHeight(); // Get the font height and move ypos down
// Draw changing numbers - no flicker using this plot method!
for (int i = 0; i <= 200; i++) {
tft.setCursor(10, 10);
tft.setcursor(10, 10);
// Number is converted to String type by (String) (number)
spr.printToSprite(" " + (String) (i / 100.0) + " "); // Space padding helps over-write old numbers
delay (20);
@@ -15,7 +15,7 @@
Note: SPIFFS does not accept an underscore _ in filenames!
The library supports 16 bit Unicode characters:
The library supports 16-bit Unicode characters:
https://en.wikipedia.org/wiki/Unicode_font
The characters supported are in the in the Basic Multilingual Plane:
@@ -80,7 +80,7 @@ void loop() {
// Set "cursor" at top left corner of display (0,0)
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0);
tft.setcursor(0, 0);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -10,7 +10,7 @@
that will return the pixel color at a position x,y on the TFT. In this
sketch that function is called gradientColor, so this line is included:
tft.setCallback(gradientColor);
tft.setcallback(gradientColor);
TFT_eSPI will call this function during the rendering of the anti-aliased
font to blend the edges of each character with the returned color.
@@ -73,8 +73,8 @@ void setup(void) {
tft.begin();
tft.setCallback(gradientColor); // Switch on color callback for anti-aliased fonts
//tft.setCallback(nullptr); // Switch off callback (off by default)
tft.setcallback(gradientColor); // Switch on color callback for anti-aliased fonts
//tft.setcallback(nullptr); // Switch off callback (off by default)
tft.setRotation(1);
@@ -109,7 +109,7 @@ void loop() {
fillGradient(); // Put here after selecting the font so fontHeight() is already set
tft.setTextColor(TFT_WHITE); // Background color is ignored in gradient area
tft.setCursor(0, 10); // Set cursor at top left of screen
tft.setcursor(0, 10); // Set cursor at top left of screen
uint32_t t = millis();
tft.println(" Ode to a small\n lump of green\n putty I found\n in my armpit\n one midsummer\n morning ");
@@ -10,7 +10,7 @@
that will return the pixel color at a position x,y on the TFT. In this
sketch that function is called pixelColor, so this line is included:
tft.setCallback(pixelColor);
tft.setcallback(pixelColor);
TFT_eSPI will call this function during the rendering of the anti-aliased
font and use it to blend the edges of each character with the screen color.
@@ -52,8 +52,8 @@ void setup(void) {
tft.begin();
tft.setCallback(pixelColor); // The callback is only used during font rendering
//tft.setCallback(nullptr); // Switch off callback (off by default)
tft.setcallback(pixelColor); // The callback is only used during font rendering
//tft.setcallback(nullptr); // Switch off callback (off by default)
tft.setRotation(1);
@@ -88,7 +88,7 @@ void loop() {
tft.loadFont(AA_FONT_SMALL);
tft.setTextColor(TFT_BLACK, TFT_WHITE); // Background color is ignored if callback is set
tft.setCursor(0, 10); // Set cursor at top left of screen
tft.setcursor(0, 10); // Set cursor at top left of screen
uint32_t t = millis();
tft.println(" Ode to a small\n lump of green\n putty I found\n in my armpit\n one midsummer\n morning ");
@@ -15,7 +15,7 @@
String okay = "5µA"; // Good
This is because UTF-8 characters outside the basic Latin set occupy more than
1 byte per character! A 16 bit Unicode character occupies 3 bytes!
1 byte per character! A 16-bit Unicode character occupies 3 bytes!
*/
@@ -77,7 +77,7 @@ void loop()
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
tft.println(test1);
@@ -99,7 +99,7 @@ void loop()
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
tft.setTextColor(TFT_CYAN, bg);
tft.println(test2);
@@ -129,7 +129,7 @@ void loop()
tft.fillScreen(bg);
tft.setTextColor(TFT_GREEN, bg);
tft.setCursor(0,0);
tft.setcursor(0,0);
tft.println("Konnichiwa");
tft.println(test3);
@@ -74,7 +74,7 @@ void setup() {
tft.fillScreen(TFT_BLACK);
// Create the clock face sprite
//face.setColorDepth(8); // 8 bit will work, but reduces effectiveness of anti-aliasing
//face.setcolorDepth(8); // 8-bit will work, but reduces effectiveness of anti-aliasing
face.createSprite(FACE_W, FACE_H);
// Only 1 font used in the sprite, so can remain loaded
@@ -138,7 +138,7 @@ static void renderFace(float t) {
// Draw digits around clock perimeter
for (uint32_t h = 1; h <= 12; h++) {
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, dialOffset, h * 360.0 / 12);
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, dialOffset, h * 360.0 / 12);
face.drawNumber(h, xp, 2 + yp);
}
@@ -147,12 +147,12 @@ static void renderFace(float t) {
face.drawString("TFT_eSPI", CLOCK_R, CLOCK_R * 0.75);
// Draw minute hand
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, M_HAND_LENGTH, m_angle);
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, M_HAND_LENGTH, m_angle);
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 6.0f, CLOCK_FG);
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 2.0f, CLOCK_BG);
// Draw hour hand
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, H_HAND_LENGTH, h_angle);
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, H_HAND_LENGTH, h_angle);
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 6.0f, CLOCK_FG);
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 2.0f, CLOCK_BG);
@@ -160,7 +160,7 @@ static void renderFace(float t) {
face.fillSmoothCircle(CLOCK_R, CLOCK_R, 4, CLOCK_FG);
// Draw cecond hand
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, S_HAND_LENGTH, s_angle);
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, S_HAND_LENGTH, s_angle);
face.drawWedgeLine(CLOCK_R, CLOCK_R, xp, yp, 2.5, 1.0, SECCOND_FG);
face.pushSprite(5, 5, TFT_TRANSPARENT);
}
@@ -170,7 +170,7 @@ static void renderFace(float t) {
// =========================================================================
// Coordinates are returned to caller via the xp and yp pointers
#define DEG2RAD 0.0174532925
void getCoord(int16_t x, int16_t y, float *xp, float *yp, int16_t r, float a)
void getcoord(int16_t x, int16_t y, float *xp, float *yp, int16_t r, float a)
{
float sx1 = cos( (a - 90) * DEG2RAD);
float sy1 = sin( (a - 90) * DEG2RAD);
@@ -31,16 +31,16 @@ WiFiUDP udp;
// Settings
//====================================================================================
#define TIMEZONE UK // See below for other "Zone references", UK, usMT etc
#define TIMEZONE UK // See below for other "Zone references", UK, usMT etc.
#ifdef ESP32 // Temporary fix, ESP8266 fails to communicate with some servers...
// Try to use pool url instead so the server IP address is looked up from those available
// Try to use pool URL instead so the server IP address is looked up from those available
// (use a pool server in your own country to improve response time and reliability)
//const char* ntpServerName = "time.nist.gov";
//const char* ntpServerName = "pool.ntp.org";
const char* ntpServerName = "time.google.com";
#else
// Try to use pool url instead so the server IP address is looked up from those available
// Try to use pool URL instead so the server IP address is looked up from those available
// (use a pool server in your own country to improve response time and reliability)
// const char* ntpServerName = "time.nist.gov";
const char* ntpServerName = "pool.ntp.org";
@@ -43,7 +43,7 @@ OpenFontRender ofr;
uint32_t runTime = 0; // time for next update
int reading = 0; // Value to be displayed
int d = 0; // Variable used for the sinewave test waveform
int d = 0; // Variable used for the sine wave test waveform
bool range_error = 0;
int8_t ramp = 1;
@@ -109,12 +109,12 @@ void loop() {
}
#ifdef DRAW_DIGITS
ofr.unloadFont(); // Recover space used by font metrics etc
ofr.unloadFont(); // Recover space used by font metrics etc.
#endif
}
// #########################################################################
// Draw the meter on the screen, returns x coord of righthand side
// Draw the meter on the screen, returns x coord of right-hand side
// #########################################################################
// x,y is centre of meter, r the radius, val a number in range 0-100
// units is the meter scale label
@@ -154,10 +154,10 @@ void ringMeter(int x, int y, int r, int val, const char *units)
// The OpenFontRender library only has simple print functions...
// Digit jiggle for chaging values often happens with proportional fonts because
// Digit jiggle for changing values often happens with proportional fonts because
// digit glyph width varies ( 1 narrower that 4 for example). This code prints up to
// 3 digits with even spacing.
// A few experiemntal fudge factors are used here to position the
// A few experimental fudge factors are used here to position the
// digits in the sprite...
// Create a sprite to draw the digits into
uint8_t w = ofr.getTextWidth("444");
@@ -167,12 +167,12 @@ void ringMeter(int x, int y, int r, int val, const char *units)
char str_buf[8]; // Buffed for string
itoa (val, str_buf, 10); // Convert value to string (null terminated)
uint8_t ptr = 0; // Pointer to a digit character
uint8_t dx = 4; // x offfset for cursor position
uint8_t dx = 4; // x offset for cursor position
if (val < 100) dx = ofr.getTextWidth("4") / 2; // Adjust cursor x for 2 digits
if (val < 10) dx = ofr.getTextWidth("4"); // Adjust cursor x for 1 digit
while ((uint8_t)str_buf[ptr] != 0) ptr++; // Count the characters
while (ptr) {
ofr.setCursor(w - dx - w / 20, -h / 2.5); // Offset cursor position in sprtie
ofr.setcursor(w - dx - w / 20, -h / 2.5); // Offset cursor position in sprite
ofr.rprintf(str_buf + ptr - 1); // Draw a character
str_buf[ptr - 1] = 0; // Replace character with a null
dx += 1 + w / 3; // Adjust cursor for next character
@@ -185,12 +185,12 @@ void ringMeter(int x, int y, int r, int val, const char *units)
ofr.setDrawer(tft);
ofr.setFontColor(TFT_GOLD, DARKER_GREY);
ofr.setFontSize(r / 2.0);
ofr.setCursor(x, y + (r * 0.4));
ofr.setcursor(x, y + (r * 0.4));
ofr.cprintf("Watts");
}
#endif
//ofr.unloadFont(); // Recover space used by font metrics etc
//ofr.unloadFont(); // Recover space used by font metrics etc.
// Allocate a value to the arc thickness dependant of radius
uint8_t thickness = r / 5;
@@ -44,7 +44,7 @@ void loop()
// -------------------------------------------------------------------------
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// -------------------------------------------------------------------------
unsigned int rainbow(byte value)
{
@@ -54,7 +54,7 @@ unsigned int rainbow(byte value)
value = value%192;
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
byte red = 0; // Red is the top 5 bits of a 16-bit colour value
byte green = 0; // Green is the middle 6 bits, but only top 5 bits used here
byte blue = 0; // Blue is the bottom 5 bits
@@ -1,4 +1,4 @@
// Sketch to demonstrate smooth (anti-aliased) graphics funtions:
// Sketch to demonstrate smooth (anti-aliased) graphics functions:
// Smooth graphics result in less pixel resolution jaggedness.
#include <TFT_eSPI.h> // Master copy here: https://github.com/Bodmer/TFT_eSPI
@@ -35,7 +35,7 @@ void loop() {
// drawSpot is for small anti-aliased circles, coordinates and radius are
// floating point to allow sub-pixel positioning (large circles will
// be slow to draw). Use fillSmoothCircle() for large circles.
// In this case black is the backgorund colour for the anti-aliasing
// In this case black is the background colour for the anti-aliasing
float x = 10.5;
float y = 10.5;
float r = 8.6;
@@ -43,7 +43,7 @@ void loop() {
// Fill sprite with a colour
spr.fillSprite(TFT_RED);
// Draw spot in sprite, the backgorund colour is ommitted so function
// Draw spot in sprite, the background colour is omitted so function
// reads background colour for aliasing. (To use this method with direct write
// to TFT (tft.drawSpot...) requires the capability to read data from the TFT!)
spr.drawSpot(x, y, r, TFT_WHITE);
@@ -63,7 +63,7 @@ void loop() {
int w1 = r1 / 25;
int w2 = r2 / 20;
// The following will be updated by the getCoord function
// The following will be updated by the getcoord function
float px1 = 0.0;
float py1 = 0.0;
float px2 = 0.0;
@@ -72,7 +72,7 @@ void loop() {
// Wedge line function, an anti-aliased wide line between 2 points, with different
// line widths at the two ends. Background colour is black.
for (int angle = -130; angle <= 130; angle += 10) {
getCoord(cx, cy, &px1, &py1, &px2, &py2, r1, r2, angle);
getcoord(cx, cy, &px1, &py1, &px2, &py2, r1, r2, angle);
uint16_t colour = rainbow(map(angle, -130, 130, 0, 127));
if (angle > 45) colour = TFT_DARKGREY;
tft.drawWedgeLine(px1, py1, px2, py2, w1, w2, colour, TFT_BLACK);
@@ -82,7 +82,7 @@ void loop() {
tft.fillSmoothCircle(cx, cy, r1 - 8, TFT_MAROON, TFT_BLACK);
// Draw a white dial pointer using wedge line function
getCoord(cx, cy, &px1, &py1, &px2, &py2, 0, r1 - 10, 45);
getcoord(cx, cy, &px1, &py1, &px2, &py2, 0, r1 - 10, 45);
// Magenta wedge line pointer on red background
// Line tapers from radius 5 to zero
tft.drawWedgeLine(cx, cy, px2, py2, 5, 0, TFT_WHITE, TFT_MAROON);
@@ -133,7 +133,7 @@ void loop() {
// =========================================================================
// Coordinates are returned to caller via the xp and yp pointers
#define DEG2RAD 0.0174532925
void getCoord(int16_t x, int16_t y, float *xp1, float *yp1, float *xp2, float *yp2, int16_t r1, int16_t r2, float a)
void getcoord(int16_t x, int16_t y, float *xp1, float *yp1, float *xp2, float *yp2, int16_t r1, int16_t r2, float a)
{
float sx = cos( (a - 90) * DEG2RAD);
float sy = sin( (a - 90) * DEG2RAD);
@@ -144,14 +144,14 @@ void getCoord(int16_t x, int16_t y, float *xp1, float *yp1, float *xp2, float *y
}
// =========================================================================
// Return a 16 bit rainbow colour
// 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 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
@@ -11,7 +11,7 @@ void setup(void) {
void loop() {
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 0);
tft.setcursor(0, 0);
// Draw some random smooth rounded rectangles
for (int i = 0; i < 20; i++)
@@ -30,7 +30,7 @@ void loop() {
delay(2000);
tft.fillScreen(TFT_BLACK);
tft.setCursor(0, 0);
tft.setcursor(0, 0);
// Draw some random minimum thickness smooth rounded rectangles
for (int i = 0; i < 20; i++)
@@ -70,7 +70,7 @@ void setup() {
TJpgDec.setSwapBytes(true);
// The jpeg decoder must be given the exact name of the rendering function above
TJpgDec.setCallback(tft_output);
TJpgDec.setcallback(tft_output);
tft.begin();
tft.setRotation(0);
@@ -128,7 +128,7 @@ void loop() {
// =======================================================================================
void createNeedle(void)
{
needle.setColorDepth(16);
needle.setcolorDepth(16);
needle.createSprite(NEEDLE_WIDTH, NEEDLE_LENGTH); // create the needle Sprite
needle.fillSprite(TFT_BLACK); // Fill with black
@@ -12,7 +12,7 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 1 bit Sprite occupies (width * height)/8 bytes in RAM. So,
A 1-bit Sprite occupies (width * height)/8 bytes in RAM. So,
for example, a 320 x 240 pixel Sprite occupies 9600 bytes.
*/
// A new setBitmapColor(fg_color, bg_color) function allows
@@ -76,7 +76,7 @@ void drawStar(int x, int y, int star_color)
// Create an 1 bit (2 colour) sprite 70x80 pixels (uses 70*80/8 = 700 bytes of RAM)
// Colour depths of 8 bits per pixel and 16 bits are also supported.
img.setColorDepth(BITS_PER_PIXEL); // Set colour depth first
img.setcolorDepth(BITS_PER_PIXEL); // Set colour depth first
img.createSprite(70, 80); // then create the sprite
// Fill Sprite with the colour that will be defined later as "transparent"
Loaded 100 of 197 files, more files were not shown because too many files have changed in this diff. Show more