Update TFT_eSPI to v2.5.43
@@ -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
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ void loop() {
|
||||
// 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,7 +193,7 @@ 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.
|
||||
|
||||
|
||||
@@ -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
|
||||
//
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ void loop() {
|
||||
|
||||
// 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
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ void loop() {
|
||||
|
||||
// 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
|
||||
@@ -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,7 +222,7 @@ 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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void setup(void) {
|
||||
|
||||
// check file system
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("formating file system");
|
||||
Serial.println("formatting file system");
|
||||
|
||||
SPIFFS.format();
|
||||
SPIFFS.begin();
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 19 KiB |
@@ -36,7 +36,7 @@ void setup() {
|
||||
|
||||
tft.begin();
|
||||
|
||||
if (!SD.begin()) {
|
||||
if (!SD.begin(5, tft.getSPIinstance())) {
|
||||
Serial.println("Card Mount Failed");
|
||||
return;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ 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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// Based on sketch here:
|
||||
// https://github.com/OpenHDZ/Arduino-experimentation
|
||||
// Adapted for TFT_eSPI library
|
||||
|
||||
// Note: a high number of floating point calculations are needed
|
||||
// for each pixel so rendering will be quite slow.
|
||||
// For best performance use a Teensy 4.x (600MHz CPU clock).
|
||||
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
const uint16_t MAX_ITERATION = 300; // Nombre de couleurs
|
||||
|
||||
#define SCREEN_WIDTH tft.width() //
|
||||
#define SCREEN_HEIGHT tft.height() // Taille de l'écran
|
||||
|
||||
static float zoom = 0.5;
|
||||
|
||||
/* Fonction setup */
|
||||
void setup() {
|
||||
/* Initialise l'écran LCD */
|
||||
tft.begin();
|
||||
tft.setRotation(1);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setFreeFont(&FreeMono9pt7b);
|
||||
}
|
||||
|
||||
/* Fonction loop() */
|
||||
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.setTextColor(TFT_WHITE);
|
||||
tft.print(" Zoom = ");
|
||||
tft.println(zoom);
|
||||
delay(2000);
|
||||
zoom *= 1.5;
|
||||
if (zoom > 100) zoom = 0.5;
|
||||
}
|
||||
|
||||
/*
|
||||
Dessine une fractale de Julia
|
||||
*/
|
||||
|
||||
void draw_Julia(float c_r, float c_i, float zoom) {
|
||||
|
||||
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 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);
|
||||
old_i = (y - SCREEN_HEIGHT / 2) / (0.5 * zoom * SCREEN_HEIGHT);
|
||||
uint16_t i = 0;
|
||||
|
||||
while ((old_r * old_r + old_i * old_i) < 4.0 && i < MAX_ITERATION) {
|
||||
new_r = old_r * old_r - old_i * old_i ;
|
||||
new_i = 2.0 * old_r * old_i;
|
||||
|
||||
old_r = new_r+c_r;
|
||||
old_i = new_i+c_i;
|
||||
|
||||
i++;
|
||||
}
|
||||
/* Affiche le pixel */
|
||||
if (i < 100){
|
||||
tft.drawPixel(x,y,tft.color565(255,255,map(i,0,100,255,0)));
|
||||
tft.drawPixel(SCREEN_WIDTH - x - 1,SCREEN_HEIGHT - y - 1,tft.color565(255,255,map(i,0,100,255,0)));
|
||||
}if(i<200){
|
||||
tft.drawPixel(x,y,tft.color565(255,map(i,100,200,255,0),0));
|
||||
tft.drawPixel(SCREEN_WIDTH - x - 1,SCREEN_HEIGHT - y - 1,tft.color565(255,map(i,100,200,255,0),0));
|
||||
}else{
|
||||
tft.drawPixel(x,y,tft.color565(map(i,200,300,255,0),0,0));
|
||||
tft.drawPixel(SCREEN_WIDTH - x - 1,SCREEN_HEIGHT - y - 1,tft.color565(map(i,200,300,255,0),0,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,6 +2,10 @@
|
||||
// This example renders a png file that is stored in a FLASH array
|
||||
// using the PNGdec library (available via library manager).
|
||||
|
||||
// Note: The PNGDEC required lots of RAM to work (~40kbytes) so
|
||||
// this sketch is will not run on smaller memory processors (e.g.
|
||||
// ESP8266, STM32F103 etc.)
|
||||
|
||||
// Image files can be converted to arrays using the tool here:
|
||||
// https://notisrac.github.io/FileToCArray/
|
||||
// To use this tool:
|
||||
@@ -14,9 +18,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
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// This example renders a png file that is stored in a FLASH array
|
||||
// using the PNGdec library (available via library manager).
|
||||
|
||||
// Note: The PNGDEC required lots of RAM to work (~40kbytes) so
|
||||
// this sketch is will not run on smaller memory processors (e.g.
|
||||
// ESP8266, STM32F103 etc.)
|
||||
|
||||
// The example png is encoded as ARGB 8 bits per pixel with indexed colour
|
||||
// It was created using GIMP and has a transparent background area.
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
// ESP32, ESP8266). It renders a png file that is stored in LittleFS
|
||||
// using the PNGdec library (available via library manager).
|
||||
|
||||
// Note: The PNGDEC required lots of RAM to work (~40kbytes) so
|
||||
// this sketch is will not run on smaller memory processors (e.g.
|
||||
// ESP8266, STM32F103 etc.)
|
||||
|
||||
// The test image is in the sketch "data" folder (press Ctrl+K to see it).
|
||||
// You must upload the image to LittleFS using the Arduino IDE Tools Data
|
||||
// Upload menu option (you may need to install extra tools for that).
|
||||
|
||||
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 178 KiB |
@@ -3,6 +3,10 @@
|
||||
// ESP32, ESP8266). It renders a png file that is stored in LittleFS
|
||||
// using the PNGdec library (available via library manager).
|
||||
|
||||
// Note: The PNGDEC required lots of RAM to work (~40kbytes) so
|
||||
// this sketch is will not run on smaller memory processors (e.g.
|
||||
// ESP8266, STM32F103 etc.)
|
||||
|
||||
// It uses DMA to send image data to the TFT while the decoding takes
|
||||
// place. The processor and display combination must support DMA to
|
||||
// run this sketch! The decode time dominates so DMA is mainly an advantage
|
||||
|
||||
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 178 KiB |
@@ -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,7 +181,7 @@ 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)
|
||||
// Create a 16-bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
|
||||
spr.setColorDepth(16);
|
||||
spr.createSprite(IWIDTH, IHEIGHT);
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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!
|
||||
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,7 +200,7 @@ 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)
|
||||
// Create a 16-bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
|
||||
spr.setColorDepth(16);
|
||||
spr.createSprite(IWIDTH, IHEIGHT);
|
||||
|
||||
|
||||
@@ -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!");
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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!
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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,7 +200,7 @@ 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)
|
||||
// Create a 16-bit sprite 40 pixels wide, 25 high (2000 bytes of RAM needed)
|
||||
spr.setColorDepth(16);
|
||||
spr.createSprite(IWIDTH, IHEIGHT);
|
||||
|
||||
|
||||
@@ -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!");
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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!
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -190,7 +190,7 @@ void ringMeter(int x, int y, int r, int val, const char *units)
|
||||
}
|
||||
#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);
|
||||
@@ -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
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB |
@@ -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
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// screen very simple. The rotation is clockwise with increasing angle. The angle is in
|
||||
// degrees, an angle of 0 means no Sprite rotation.
|
||||
|
||||
// The pushRotated() function works with 1, 4, 8 and 16 bit per pixel (bpp) Sprites.
|
||||
// The pushRotated() function works with 1, 4, 8 and 16-bit per pixel (bpp) Sprites.
|
||||
|
||||
// The original Sprite is unchanged so can be plotted again at a different angle.
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
// For 1 bpp Sprites the foreground and background colours are defined with the
|
||||
// function spr.setBitmapColor(foregroundColor, backgroundColor).
|
||||
|
||||
// For 4 bpp Sprites the colour map index is used instead of the 16 bit colour
|
||||
// For 4 bpp Sprites the colour map index is used instead of the 16-bit colour
|
||||
// e.g. spr.setTextColor(5); // Green text in default colour map
|
||||
// See "Transparent_Sprite_Demo_4bit" example for default colour map details
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// The rotation angle is in degrees, an angle of 0 means no Sprite rotation.
|
||||
|
||||
// The pushRotated() function works with 1, 8 and 16 bit per pixel (bpp) Sprites.
|
||||
// The pushRotated() function works with 1, 8 and 16-bit per pixel (bpp) Sprites.
|
||||
|
||||
// For 1 bpp Sprites the foreground and background colours are defined with the
|
||||
// member function setBitmapColor(foregroundColor, backgroundColor).
|
||||
|
||||
@@ -80,7 +80,7 @@ void setup()
|
||||
// Send jpeg info to serial port
|
||||
fex.jpegInfo("/Eye_80x64.jpg");
|
||||
|
||||
// Draw jpeg iamge in Sprite spr at 0,0
|
||||
// Draw jpeg image in Sprite spr at 0,0
|
||||
fex.drawJpeg("/Eye_80x64.jpg", 0 , 0, &spr);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void loop()
|
||||
delay(1000);
|
||||
|
||||
// Push copies of Sprite rotated through increasing angles 0-360 degrees
|
||||
// with 45 fegree increments
|
||||
// with 45 degree increments
|
||||
for (int16_t angle = 0; angle <= 360; angle += 45) {
|
||||
spr.pushRotated(angle);
|
||||
delay(500);
|
||||
|
||||
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 9.7 KiB |
@@ -9,7 +9,7 @@
|
||||
#########################################################################
|
||||
*/
|
||||
|
||||
// Specify sprite 160 x 128 pixels (needs 40Kbytes of RAM for 16 bit colour)
|
||||
// Specify sprite 160 x 128 pixels (needs 40Kbytes of RAM for 16-bit colour)
|
||||
#define IWIDTH 160
|
||||
#define IHEIGHT 128
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
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 16 bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
A 16-bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
|
||||
On a ESP8266 Sprite sizes up to 126 x 160 can be accommodated,
|
||||
this size requires 40kBytes of RAM for a 16 bit colour depth.
|
||||
this size requires 40kBytes of RAM for a 16-bit colour depth.
|
||||
|
||||
When 8 bit colour depth sprites are created they occupy
|
||||
When 8-bit colour depth sprites are created they occupy
|
||||
(width * height) bytes in RAM, so larger sprites can be
|
||||
created, or the RAM required is halved.
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
Sketch to show how a 4 bit Sprite is created, how to draw pixels
|
||||
Sketch to show how a 4-bit Sprite is created, how to draw pixels
|
||||
and text within the Sprite and then push the Sprite onto
|
||||
the display screen.
|
||||
|
||||
The advantage of 4 bit sprites is:
|
||||
The advantage of 4-bit sprites is:
|
||||
1. Small memory footprint
|
||||
2. Any set of 16 colours can be specified
|
||||
3. Colours can be changed without redrawing in Sprite
|
||||
@@ -21,7 +21,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 4 bit Sprite occupies (width * height)/2 bytes in RAM.
|
||||
A 4-bit Sprite occupies (width * height)/2 bytes in RAM.
|
||||
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ void loop(void)
|
||||
// Fill the whole sprite with color 0 (Sprite is in memory so not visible yet)
|
||||
spr.fillSprite(0);
|
||||
|
||||
// create a color map with known colors (16 maximum for 4 bit Sprite
|
||||
// create a color map with known colors (16 maximum for 4-bit Sprite
|
||||
uint16_t cmap[16];
|
||||
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
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 16 bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
A 16-bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
|
||||
On a ESP8266 Sprite sizes up to 126 x 160 can be accommodated,
|
||||
this size requires 40kBytes of RAM for a 16 bit color depth.
|
||||
this size requires 40kBytes of RAM for a 16-bit color depth.
|
||||
|
||||
When 8 bit color depth sprites are created they occupy
|
||||
When 8-bit color depth sprites are created they occupy
|
||||
(width * height) bytes in RAM, so larger sprites can be
|
||||
created, or the RAM required is halved.
|
||||
|
||||
@@ -39,7 +39,7 @@ TFT_eSPI tft = TFT_eSPI(); // Declare object "tft"
|
||||
|
||||
TFT_eSprite spr = TFT_eSprite(&tft); // Declare Sprite object "spr" with pointer to "tft" object
|
||||
|
||||
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;
|
||||
@@ -99,7 +99,7 @@ void loop(void)
|
||||
}
|
||||
|
||||
// #########################################################################
|
||||
// Return a 16 bit rainbow colour
|
||||
// Return a 16-bit rainbow colour
|
||||
// #########################################################################
|
||||
unsigned int rainbow()
|
||||
{
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
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 16 bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
A 16-bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
|
||||
An 8 bit Sprite occupies (width * height) bytes in RAM.
|
||||
An 8-bit Sprite occupies (width * height) bytes in RAM.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ void numberBox(int num, int x, int y)
|
||||
// Fill it with black
|
||||
img.fillSprite(TFT_BLACK);
|
||||
|
||||
// Draw a backgorund of 2 filled triangles
|
||||
// Draw a background of 2 filled triangles
|
||||
img.fillTriangle( 0, 0, 0, 49, 40, 25, TFT_RED);
|
||||
img.fillTriangle( 79, 0, 79, 49, 40, 25, TFT_DARKGREEN);
|
||||
|
||||
@@ -150,14 +150,14 @@ void numberBox(int num, int x, int 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 = red through to 127 = 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
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
This sketch scrolls a 1 bit per pixel (1 bpp) Sprite.
|
||||
|
||||
In a 1 bit Sprite any colour except TFT_BLACK turns a pixel "ON"
|
||||
In a 1-bit Sprite any colour except TFT_BLACK turns a pixel "ON"
|
||||
TFT_BLACK turns a pixel "OFF".
|
||||
|
||||
ON and OFF pixels can be set to any two colours before
|
||||
@@ -24,7 +24,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.
|
||||
A 1-bit Sprite occupies (width * height)/8 bytes in RAM.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Sketch to show scrolling of the graphics in 4 bit sprites.
|
||||
Sketch to show scrolling of the graphics in 4-bit sprites.
|
||||
Scrolling in this way moves the pixels in a defined rectangle
|
||||
within the Sprite. By default the whole sprite is scrolled.
|
||||
The gap left by scrolling is filled with a defined colour.
|
||||
@@ -14,7 +14,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 4 bit Sprite occupies (width * height)/2 bytes in RAM.
|
||||
A 4-bit Sprite occupies (width * height)/2 bytes in RAM.
|
||||
*/
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Display "flicker free" scrolling text and updating number
|
||||
|
||||
This sketch uses 8 bit colour sprites to save RAM.
|
||||
This sketch uses 8-bit colour sprites to save RAM.
|
||||
|
||||
Example for library:
|
||||
https://github.com/Bodmer/TFT_eSPI
|
||||
@@ -16,15 +16,15 @@
|
||||
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 16 bit colour Sprite occupies (2 * width * height) bytes.
|
||||
A 16-bit colour Sprite occupies (2 * width * height) bytes.
|
||||
|
||||
An 8 bit colour Sprite occupies (width * height) bytes.
|
||||
An 8-bit colour Sprite occupies (width * height) bytes.
|
||||
|
||||
On a ESP8266, 16 bit Sprite sizes up to 128 x 160 can be accommodated,
|
||||
On a ESP8266, 16-bit Sprite sizes up to 128 x 160 can be accommodated,
|
||||
this size requires 128*160*2 bytes (40kBytes) of RAM.
|
||||
|
||||
This sketch sets the colour depth to 8 bits so larger sprites can be
|
||||
created. 8 bit colour sprites use half amount of RAM. If the colour
|
||||
created. 8-bit colour sprites use half amount of RAM. If the colour
|
||||
depth is not specified then 16 bits is assumed.
|
||||
|
||||
You need to make the sprite small enough to fit, with RAM spare for
|
||||
@@ -137,7 +137,7 @@ void numberBox(int num, int x, int y)
|
||||
// Fill it with black
|
||||
img.fillSprite(TFT_BLACK);
|
||||
|
||||
// Draw a backgorund of 2 filled triangles
|
||||
// Draw a background of 2 filled triangles
|
||||
img.fillTriangle( 0, 0, 0, 49, 40, 25, TFT_RED);
|
||||
img.fillTriangle( 79, 0, 79, 49, 40, 25, TFT_DARKGREEN);
|
||||
|
||||
@@ -161,14 +161,14 @@ void numberBox(int num, int x, int 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 = red through to 127 = 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
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This **ONLY** works for 1 bpp Sprites due to lack of bounds checking in the
|
||||
// Sprite pushImage() function for 8 and 16 bit Sprites (it is on the TO DO list)
|
||||
// Sprite pushImage() function for 8 and 16-bit Sprites (it is on the TO DO list)
|
||||
|
||||
// Wrapping scroll example by Bodmer for the TFT_eSPI library
|
||||
|
||||
|
||||