Update TFT_eSPI to v2.5.43
This commit is contained in:
@@ -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
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
|
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user