Merge branch 'master' into pr_displaySize
This commit is contained in:
commit
3e6eba1e06
|
|
@ -883,7 +883,7 @@ bool TFT_eSprite::pushSprite(int32_t tx, int32_t ty, int32_t sx, int32_t sy, int
|
|||
_tft->startWrite();
|
||||
while (sh--)
|
||||
{
|
||||
_tft->pushImage(tx, ty++, sw, 1, _img8 + (_bitwidth>>3) * _ys, (bool)false );
|
||||
_tft->pushImage(tx, ty++, sw, 1, _img8 + (_bitwidth>>3) * _ys++, (bool)false );
|
||||
}
|
||||
_tft->endWrite();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t
|
|||
// If image is clipped, copy pixels into a contiguous block
|
||||
if ( (dw != w) || (dh != h) ) {
|
||||
for (int32_t yb = 0; yb < dh; yb++) {
|
||||
memcpy((uint8_t*) (buffer + yb * dw), (uint8_t*) (image + dx + w * (yb + dy)), dw << 1);
|
||||
memmove((uint8_t*) (buffer + yb * dw), (uint8_t*) (image + dx + w * (yb + dy)), dw << 1);
|
||||
}
|
||||
}
|
||||
// else, if a buffer pointer has been provided copy whole image to the buffer
|
||||
|
|
@ -390,6 +390,8 @@ bool TFT_eSPI::initDMA(bool ctrl_cs)
|
|||
{
|
||||
if (DMA_Enabled) return false;
|
||||
|
||||
ctrl_cs = ctrl_cs; // stop unused parameter warning
|
||||
|
||||
dma_tx_channel = dma_claim_unused_channel(true);
|
||||
dma_tx_config = dma_channel_get_default_config(dma_tx_channel);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,13 @@
|
|||
#else
|
||||
//#define DC_C sio_hw->gpio_clr = (1ul << TFT_DC)
|
||||
//#define DC_D sio_hw->gpio_set = (1ul << TFT_DC)
|
||||
#if defined (RPI_DISPLAY_TYPE)
|
||||
#define DC_C digitalWrite(TFT_DC, LOW);
|
||||
#define DC_D digitalWrite(TFT_DC, HIGH);
|
||||
#else
|
||||
#define DC_C sio_hw->gpio_clr = (1ul << TFT_DC)
|
||||
#define DC_D sio_hw->gpio_set = (1ul << TFT_DC)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -70,8 +75,13 @@
|
|||
#define CS_L // No macro allocated so it generates no code
|
||||
#define CS_H // No macro allocated so it generates no code
|
||||
#else
|
||||
#if defined (RPI_DISPLAY_TYPE)
|
||||
#define CS_L digitalWrite(TFT_CS, LOW);
|
||||
#define CS_H digitalWrite(TFT_CS, HIGH);
|
||||
#else
|
||||
#define CS_L sio_hw->gpio_clr = (1ul << TFT_CS)
|
||||
#define CS_H sio_hw->gpio_set = (1ul << TFT_CS)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -1,26 +1,47 @@
|
|||
// This is the command sequence that rotates the ILI9481 driver coordinate frame
|
||||
// This is the command sequence that rotates the HX8357D driver coordinate frame
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
writecommand(TFT_MADCTL);
|
||||
rotation = m % 8;
|
||||
switch (rotation)
|
||||
{
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MX);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 2: // Inverter portrait
|
||||
writedata(TFT_MAD_RGB);
|
||||
case 2: // Inverter portrait
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MY);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
}
|
||||
case 4: // Portrait
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_MY);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 5: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 6: // Inverter portrait
|
||||
writedata(TFT_MAD_BGR);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 7: // Inverted landscape
|
||||
writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MY);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
12
TFT_eSPI.cpp
12
TFT_eSPI.cpp
|
|
@ -3093,8 +3093,12 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
|||
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
|
||||
DC_C;
|
||||
#if !defined (SPI_18BIT_DRIVER)
|
||||
#if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
|
||||
spi_set_format(spi0, 16, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
|
||||
#else
|
||||
spi_set_format(spi0, 8, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
|
||||
#endif
|
||||
#endif
|
||||
spi_get_hw(spi0)->dr = (uint32_t)TFT_CASET;
|
||||
|
||||
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
|
||||
|
|
@ -3282,7 +3286,11 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
|
|||
// a busy check is not needed.
|
||||
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
|
||||
DC_C;
|
||||
#if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
|
||||
spi_set_format(spi0, 16, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
|
||||
#else
|
||||
spi_set_format(spi0, 8, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
|
||||
#endif
|
||||
spi_get_hw(spi0)->dr = (uint32_t)TFT_CASET;
|
||||
|
||||
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS){};
|
||||
|
|
@ -3317,9 +3325,13 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
|
|||
#else
|
||||
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
|
||||
DC_D;
|
||||
#if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
|
||||
spi_get_hw(spi0)->dr = (uint32_t)color;
|
||||
#else
|
||||
spi_get_hw(spi0)->dr = (uint32_t)color>>8;
|
||||
spi_get_hw(spi0)->dr = (uint32_t)color;
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
// Subsequent pixel reads work OK without draining the FIFO...
|
||||
// Drain RX FIFO, then wait for shifting to finish (which may be *after*
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef _TFT_eSPIH_
|
||||
#define _TFT_eSPIH_
|
||||
|
||||
#define TFT_ESPI_VERSION "2.3.70"
|
||||
#define TFT_ESPI_VERSION "2.3.73"
|
||||
|
||||
// Bit level feature flags
|
||||
// Bit 0 set: viewport capability
|
||||
|
|
|
|||
|
|
@ -35,6 +35,6 @@
|
|||
#define SMOOTH_FONT
|
||||
|
||||
#define SPI_FREQUENCY 40000000 // This display also seems to work reliably at 80MHz
|
||||
#define SPI_FREQUENCY 80000000
|
||||
//#define SPI_FREQUENCY 80000000
|
||||
|
||||
#define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Setup for the TTGO T4 ("Bitcoin Tracker") ESP32 board with 2.2" ILI9341 display
|
||||
// Setup for the TTGO T Display
|
||||
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
#define ST7789_DRIVER
|
||||
#define TFT_SDA_READ // Display has a bidirectionsl SDA pin
|
||||
#define TFT_SDA_READ // Display has a bidirectional SDA pin
|
||||
|
||||
#define TFT_WIDTH 135
|
||||
#define TFT_HEIGHT 240
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#define SMOOTH_FONT
|
||||
|
||||
//#define SPI_FREQUENCY 27000000
|
||||
#define SPI_FREQUENCY 40000000 // Maximum for ILI9341
|
||||
#define SPI_FREQUENCY 40000000
|
||||
|
||||
|
||||
#define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@
|
|||
// Define STM32 to invoke STM32 optimised driver
|
||||
#define STM32
|
||||
|
||||
// Define if Port A (or B) pins 0-7 are used for data bus bits 0-7
|
||||
// Define if Port A (B, C or D) pins 0-7 are used for data bus bits 0-7
|
||||
// this will improve rendering performance by a factor of ~8x
|
||||
#define STM_PORTA_DATA_BUS
|
||||
//#define STM_PORTB_DATA_BUS // Pins below must re re-allocated to use this option
|
||||
//#define STM_PORTC_DATA_BUS // Pins below must re re-allocated to use this option
|
||||
//#define STM_PORTD_DATA_BUS // Pins below must re re-allocated to use this option
|
||||
|
||||
// Tell the library to use 8 bit parallel mode (otherwise SPI is assumed)
|
||||
#define TFT_PARALLEL_8_BIT
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ void computeCA() {
|
|||
}
|
||||
}
|
||||
|
||||
// Check the Moore neighborhood
|
||||
// Check the Moore neighbourhood
|
||||
int getNumberOfNeighbors(int x, int y) {
|
||||
return grid[x - 1][y] + grid[x - 1][y - 1] + grid[x][y - 1] + grid[x + 1][y - 1] + grid[x + 1][y] + grid[x + 1][y + 1] + grid[x][y + 1] + grid[x - 1][y + 1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ void computeCA() {
|
|||
}
|
||||
}
|
||||
|
||||
// Check the Moore neighborhood
|
||||
// Check the Moore neighbourhood
|
||||
int getNumberOfNeighbors(int x, int y) {
|
||||
return grid[x - 1][y] + grid[x - 1][y - 1] + grid[x][y - 1] + grid[x + 1][y - 1] + grid[x + 1][y] + grid[x + 1][y + 1] + grid[x][y + 1] + grid[x - 1][y + 1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ void computeCA() {
|
|||
}
|
||||
}
|
||||
|
||||
// Check the Moore neighborhood
|
||||
// Check the Moore neighbourhood
|
||||
int getNumberOfNeighbors(int x, int y) {
|
||||
return grid[x - 1][y] + grid[x - 1][y - 1] + grid[x][y - 1] + grid[x + 1][y - 1] + grid[x + 1][y] + grid[x + 1][y + 1] + grid[x][y + 1] + grid[x - 1][y + 1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void setup() {
|
|||
|
||||
fact = 180 / 3.14159259; // conversion from degrees to radians.
|
||||
|
||||
Xoff = 240; // Position the center of the 3d conversion space into the center of the TFT screen.
|
||||
Xoff = 240; // Position the centre of the 3d conversion space into the centre of the TFT screen.
|
||||
Yoff = 160;
|
||||
Zoff = 550; // Z offset in 3D space (smaller = closer and bigger rendering)
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ void ProcessLine(struct Line2d *ret, struct Line3d vec)
|
|||
ret->p1.x = rx2;
|
||||
ret->p1.y = ry2;
|
||||
}
|
||||
// The ifs here are checks for out of bounds. needs a bit more code here to "safe" lines that will be way out of whack, so they dont get drawn and cause screen garbage.
|
||||
// The ifs here are checks for out of bounds. needs a bit more code here to "safe" lines that will be way out of whack, so they don't get drawn and cause screen garbage.
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ String fps = "xx.xx fps";
|
|||
|
||||
// Structure to hold circle plotting parameters
|
||||
typedef struct circle_t {
|
||||
int16_t cx[CNUMBER] = { 0 }; // x coord of centre
|
||||
int16_t cy[CNUMBER] = { 0 }; // y coord of centre
|
||||
int16_t cx[CNUMBER] = { 0 }; // x coordinate of centre
|
||||
int16_t cy[CNUMBER] = { 0 }; // y coordinate of centre
|
||||
int16_t cr[CNUMBER] = { 0 }; // radius
|
||||
uint16_t col[CNUMBER] = { 0 }; // colour
|
||||
int16_t dx[CNUMBER] = { 0 }; // x movment & direction
|
||||
int16_t dy[CNUMBER] = { 0 }; // y movment & direction
|
||||
int16_t dx[CNUMBER] = { 0 }; // x movement & direction
|
||||
int16_t dy[CNUMBER] = { 0 }; // y movement & direction
|
||||
} circle_param;
|
||||
|
||||
// Create the structure and get a pointer to it
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
If needed, first resize and crop to an appropriate width and height
|
||||
to suit your display with an image editing program such as IrfanView.
|
||||
|
||||
You can also change the image "guality" to reduce the file size.
|
||||
You can also change the image "quality" to reduce the file size.
|
||||
|
||||
Paste the array into a new tabe, top and tail the array from the
|
||||
Paste the array into a new tab, top and tail the array from the
|
||||
tool to look like the one below with:
|
||||
|
||||
const uint8_t name[] PROGMEM = {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ TFT_eSprite spr[2] = {TFT_eSprite(&tft), TFT_eSprite(&tft) };
|
|||
// Toggle buffer selection
|
||||
bool sprSel = 0;
|
||||
|
||||
// Pointers to start of Sprties in RAM
|
||||
// Pointers to start of Sprites in RAM
|
||||
uint16_t* sprPtr[2];
|
||||
|
||||
// Define the cube face colors
|
||||
|
|
@ -305,7 +305,7 @@ void drawCube()
|
|||
p2y[i] = IHEIGHT / 2 + ay[i] * CUBE_SIZE / az[i];
|
||||
}
|
||||
|
||||
// Fill the buffer with color 0 (Black)
|
||||
// Fill the buffer with colour 0 (Black)
|
||||
spr[sprSel].fillSprite(TFT_BLACK);
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
|||
#define RED 0xF800
|
||||
#define WHITE 0xFFFF
|
||||
|
||||
#define YBOTTOM 123 // Ball Y coord at bottom
|
||||
#define YBOTTOM 123 // Ball Y coordinate at bottom
|
||||
#define YBOUNCE -3.5 // Upward velocity on ball bounce
|
||||
|
||||
// Ball coordinates are stored floating-point because screen refresh
|
||||
|
|
@ -49,7 +49,7 @@ float ballx = 20.0, bally = YBOTTOM, // Current ball position
|
|||
ballframe = 3; // Ball animation frame #
|
||||
int balloldx = ballx, balloldy = bally; // Prior ball position
|
||||
|
||||
// Working buffer for ball rendering...2 scanlines that alternate,
|
||||
// Working buffer for ball rendering...2 scan lines that alternate,
|
||||
// one is rendered while the other is transferred via DMA.
|
||||
uint16_t renderbuf[2][SCREENWIDTH];
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ void setup() {
|
|||
tft.begin();
|
||||
tft.setRotation(3); // Landscape orientation, USB at bottom right
|
||||
tft.setSwapBytes(false);
|
||||
// Draw initial framebuffer contents:
|
||||
// Draw initial frame buffer contents:
|
||||
//tft.setBitmapColor(GRIDCOLOR, BGCOLOR);
|
||||
tft.fillScreen(BGCOLOR);
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ void loop() {
|
|||
(by >= 0) && (by < BALLHEIGHT)) { // inside the ball bitmap area?
|
||||
// Yes, do ball compositing math...
|
||||
p = ball[by][bx1 / 2]; // Get packed value (2 pixels)
|
||||
c = (bx1 & 1) ? (p & 0xF) : (p >> 4); // Unpack high or low nybble
|
||||
c = (bx1 & 1) ? (p & 0xF) : (p >> 4); // Unpack high or low nibble
|
||||
if(c == 0) { // Outside ball - just draw grid
|
||||
c = background[bgy][bgx1 / 8] & (0x80 >> (bgx1 & 7)) ? GRIDCOLOR : BGCOLOR;
|
||||
} else if(c > 1) { // In ball area...
|
||||
|
|
@ -155,7 +155,7 @@ void loop() {
|
|||
} else { // Outside ball bitmap, just draw background bitmap...
|
||||
c = background[bgy][bgx1 / 8] & (0x80 >> (bgx1 & 7)) ? GRIDCOLOR : BGCOLOR;
|
||||
}
|
||||
*destPtr++ = c<<8 | c>>8; // Store pixel color
|
||||
*destPtr++ = c<<8 | c>>8; // Store pixel colour
|
||||
bx1++; // Increment bitmap position counters (X axis)
|
||||
bgx1++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
// An adaption of the "UncannyEyes" sketch (see eye_functions tab)
|
||||
// for the TFT_eSPI library. As written the sketch is for driving
|
||||
// one (240x320 minimum) TFT display, showing 2 eyes. See example
|
||||
// Animated_Eyes_2 for a dual 128x128 TFT display configued sketch.
|
||||
// Animated_Eyes_2 for a dual 128x128 TFT display configured sketch.
|
||||
|
||||
// The size of the displayed eye is determined by the screen size and
|
||||
// resolution. The eye image is 128 pixels wide. In humans the palpebral
|
||||
// fissure (open eye) width is about 30mm so a low resolution, large
|
||||
// pixel size display works best to show a scale eye image. Note that
|
||||
// display manufacturers usually quote the diagonal measurement, so a
|
||||
// 128 x 128 1.7" display or 128 x 160 2" display is about right.
|
||||
|
||||
// Configuration settings for the eye, eye style, display count,
|
||||
// chip selects and x offsets can be defined in the sketch "config.h" tab.
|
||||
|
|
@ -9,7 +16,7 @@
|
|||
// Performance (frames per second = fps) can be improved by using
|
||||
// DMA (for SPI displays only) on ESP32 and STM32 processors. Use
|
||||
// as high a SPI clock rate as is supported by the display. 27MHz
|
||||
// minimum, some diplays can be operated at higher clock rates in
|
||||
// minimum, some displays can be operated at higher clock rates in
|
||||
// the range 40-80MHz.
|
||||
|
||||
// Single defaultEye performance for different processors
|
||||
|
|
@ -22,7 +29,7 @@
|
|||
// STM32F446 55MHz SPI 83 fps 155 fps
|
||||
// STM32F767 55MHz SPI 136 fps 197 fps
|
||||
|
||||
// DMA can be used with STM32 and ESP32 processors when the interface
|
||||
// DMA can be used with RP2040, STM32 and ESP32 processors when the interface
|
||||
// is SPI, uncomment the next line:
|
||||
//#define USE_DMA
|
||||
|
||||
|
|
@ -95,7 +102,7 @@ void setup(void) {
|
|||
// User call for additional features
|
||||
user_setup();
|
||||
|
||||
// Initialiase the eye(s), this will set all chip selects low for the tft.init()
|
||||
// Initialise the eye(s), this will set all chip selects low for the tft.init()
|
||||
initEyes();
|
||||
|
||||
// Initialise TFT
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@
|
|||
// for the TFT_eSPI library. As written the sketch is for driving
|
||||
// two TFT displays.
|
||||
|
||||
// The size of the displayed eye is determined by the screen size and
|
||||
// resolution. The eye image is 128 pixels wide. In humans the palpebral
|
||||
// fissure (open eye) width is about 30mm so a low resolution, large
|
||||
// pixel size display works best to show a scale eye image. Note that
|
||||
// display manufacturers usually quote the diagonal measurement, so a
|
||||
// 128 x 128 1.7" display or 128 x 160 2" display is about right.
|
||||
|
||||
// The number of displays and chip selects used are defined in the
|
||||
// config.h tab. The display count can be set to 1. If using one
|
||||
// TFT and the chip select for that display is already defined in
|
||||
|
|
@ -17,7 +24,7 @@
|
|||
// Performance (frames per second = fps) can be improved by using
|
||||
// DMA (for SPI displays only) on ESP32 and STM32 processors. Use
|
||||
// as high a SPI clock rate as is supported by the display. 27MHz
|
||||
// minimum, some diplays can be operated at higher clock rates in
|
||||
// minimum, some displays can be operated at higher clock rates in
|
||||
// the range 40-80MHz.
|
||||
|
||||
// Single defaultEye performance for different processors
|
||||
|
|
@ -30,7 +37,7 @@
|
|||
// STM32F446 55MHz SPI 83 fps 155 fps
|
||||
// STM32F767 55MHz SPI 136 fps 197 fps
|
||||
|
||||
// DMA can be used with STM32 and ESP32 processors when the interface
|
||||
// DMA can be used with RP2040, STM32 and ESP32 processors when the interface
|
||||
// is SPI, uncomment the next line:
|
||||
//#define USE_DMA
|
||||
|
||||
|
|
@ -103,7 +110,7 @@ void setup(void) {
|
|||
// User call for additional features
|
||||
user_setup();
|
||||
|
||||
// Initialiase the eye(s), this will set all chip selects low for the tft.init()
|
||||
// Initialise the eye(s), this will set all chip selects low for the tft.init()
|
||||
initEyes();
|
||||
|
||||
// Initialise TFT
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
// To do, maybe, one day:
|
||||
// 1. Get the eye to blink
|
||||
// 2. Add another screen for another eye
|
||||
// 3. Add varaible to set how wide open the eye is
|
||||
// 3. Add variable to set how wide open the eye is
|
||||
// 4. Add a reflected highlight to the cornea
|
||||
// 5. Add top eyelid shaddow to eye surface
|
||||
// 5. Add top eyelid shadow to eye surface
|
||||
// 6. Add aliasing to blur mask edge
|
||||
//
|
||||
// With one lidded eye drawn the code runs at 28-33fps (at 27-40MHz SPI clock)
|
||||
|
|
@ -58,8 +58,8 @@
|
|||
|
||||
// The ESP8266 is rather constrained here as it only has one analogue port.
|
||||
// An I2C ADC could be used for more analogue channels
|
||||
//#define JOYSTICK_X_PIN A0 // Analog pin for eye horiz pos (else auto)
|
||||
//#define JOYSTICK_Y_PIN A0 // Analog pin for eye vert position (")
|
||||
//#define JOYSTICK_X_PIN A0 // Analogue pin for eye horiz pos (else auto)
|
||||
//#define JOYSTICK_Y_PIN A0 // Analogue pin for eye vert position (")
|
||||
//#define JOYSTICK_X_FLIP // If set, reverse stick X axis
|
||||
//#define JOYSTICK_Y_FLIP // If set, reverse stick Y axis
|
||||
#define TRACKING // If enabled, eyelid tracks pupil
|
||||
|
|
@ -107,7 +107,7 @@ void setup(void) {
|
|||
uint8_t e = 0;
|
||||
|
||||
Serial.begin(250000);
|
||||
randomSeed(analogRead(A0)); // Seed random() from floating analog input
|
||||
randomSeed(analogRead(A0)); // Seed random() from floating analogue input
|
||||
|
||||
eye[e].tft.init();
|
||||
eye[e].tft.fillScreen(TFT_BLACK);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
https://playground.arduino.cc/Code/UTF-8
|
||||
|
||||
To sumarise, UTF-8 characters are encoded as mor than 1 byte so care must
|
||||
To summarise, UTF-8 characters are encoded as more than 1 byte so care must
|
||||
be taken:
|
||||
|
||||
char c = 'µ'; // Wrong
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
// This is the file name used to store the touch coordinate
|
||||
// calibration data. Cahnge the name to start a new calibration.
|
||||
// calibration data. Change the name to start a new calibration.
|
||||
#define CALIBRATION_FILE "/TouchCalData3"
|
||||
|
||||
// Set REPEAT_CAL to true instead of false to run calibration
|
||||
|
|
@ -115,7 +115,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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Bodmers BMP image rendering function
|
||||
// Bodmer's BMP image rendering function
|
||||
|
||||
void drawBmp(const char *filename, int16_t x, int16_t y) {
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,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.drawString("Font size 2", xpos, 14, 2); // Draw text centre at position xpos, 14 using font 2
|
||||
tft.drawString("Font size 4", xpos, 30, 4); // Draw text centre at position xpos, 30 using font 4
|
||||
tft.drawString("12.34", xpos, 54, 6); // Draw text centre at position xpos, 54 using font 6
|
||||
|
|
@ -150,7 +150,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
|
||||
int rotation = tft.getRotation();
|
||||
tft.setRotation(random(4));
|
||||
for (int i = tft.height() - 1; i >= 0; i--) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
int32_t h = tft.getViewportHeight(); // Always returns height of viewport
|
||||
bool f = tft.getViewportDatum(); // Datum of the viewport (false = TFT corner, true = viewport corner)
|
||||
// To check if all or part of an area is in the viewport
|
||||
checkViewport(x, y, w, h); // Retruns "true" if all or part of area is in viewport
|
||||
checkViewport(x, y, w, h); // Returns "true" if all or part of area is in viewport
|
||||
|
||||
// To draw a rectangular frame outside viewport of width W (when W is negative)
|
||||
tft.frameViewport(TFT_RED, -W); // Note setting the width to a large negative value will clear the screen
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
This tests the alpha blending function that is used with the antialiased
|
||||
This tests the alpha blending function that is used with the anti-aliased
|
||||
fonts:
|
||||
|
||||
Alpha = 0 = 100% background, alpha = 255 = 100% foreground colour
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ void loop() {
|
|||
// Mono spaced font
|
||||
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
spr.loadFont(AA_FONT_MONO); // Mono spaced fonts have fixed intercharacter gaps to
|
||||
spr.loadFont(AA_FONT_MONO); // Mono spaced fonts have fixed inter-character gaps to
|
||||
// aid formatting
|
||||
int bnum = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,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 anti-aliased fonts
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@
|
|||
The library supports 16 bit unicode characters:
|
||||
https://en.wikipedia.org/wiki/Unicode_font
|
||||
|
||||
The characters supported are in the in the Basic Multilingal Plane:
|
||||
The characters supported are in the in the Basic Multilingual Plane:
|
||||
https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
|
||||
|
||||
Make sure all the display driver and pin connenctions are correct by
|
||||
Make sure all the display driver and pin connections are correct by
|
||||
editing the User_Setup.h file in the TFT_eSPI library folder.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
This sketch uses Smooth fonts stored in FLASH program memory. It uses a method
|
||||
for rendering anti-aliased fonts on a graded background. This is acheived by
|
||||
for rendering anti-aliased fonts on a graded background. This is achieved by
|
||||
telling the TFT_eSPI library the pixel color at each point on the screen. In
|
||||
this sketch a background colour gradient is drawn, the color of each pixel can
|
||||
therefore be determined by a function. The TFT does not need to support reading
|
||||
|
|
@ -74,7 +74,7 @@ void setup(void) {
|
|||
|
||||
void loop() {
|
||||
|
||||
// Select a font size comensurate with screen size
|
||||
// Select a font size commensurate with screen size
|
||||
if (tft.width()>= 320)
|
||||
tft.loadFont(AA_FONT_LARGE);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
This sketch uses Smooth fonts stored in FLASH program memory. It uses a method
|
||||
for rendering anti-aliased fonts on an arbitrary background. This is acheived
|
||||
for rendering anti-aliased fonts on an arbitrary background. This is achieved
|
||||
by reading the pixel color at each point on the screen. The TFT must support
|
||||
reading the graphics RAM of the screen memory. This sketch has been tested with
|
||||
ILI9241 and ILI9481 serial and parallel screens.
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,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 anit-aliased fonts well the Sprite
|
||||
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
|
||||
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.
|
||||
|
|
@ -112,7 +112,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.
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ void loop() {
|
|||
// Mono spaced font
|
||||
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
spr.loadFont(AA_FONT_MONO, LittleFS); // Mono spaced fonts have fixed intercharacter gaps to
|
||||
spr.loadFont(AA_FONT_MONO, LittleFS); // Mono spaced fonts have fixed inter-character gaps to
|
||||
// aid formatting
|
||||
int bnum = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,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 anti-aliased fonts
|
||||
|
||||
if (!LittleFS.begin()) {
|
||||
Serial.println("Flash FS initialisation failed!");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Sketch to demonstrate using the print class with smooth fonts
|
||||
|
||||
Sketch is writtent for a 240 x 320 display
|
||||
Sketch is written for a 240 x 320 display
|
||||
|
||||
// Upload the fonts and icons to LittleFS (must set at least 1M for LittleFS) using the
|
||||
// "Tools" "ESP8266 LittleFS Data Upload" menu option in the IDE.
|
||||
|
|
@ -12,13 +12,13 @@
|
|||
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 Multilingal Plane:
|
||||
The characters supported are in the in the Basic Multilingual Plane:
|
||||
https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
|
||||
|
||||
Make sure all the display driver and pin connenctions are correct by
|
||||
Make sure all the display driver and pin connections are correct by
|
||||
editing the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
#########################################################################
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
This sketch is based on Font Demo 1. It introduces a method for rendering
|
||||
anti-aliased fonts on a graded background. This is acheived by telling the
|
||||
anti-aliased fonts on a graded background. This is achieved by telling the
|
||||
TFT_eSPI library the pixel color at each point on the screen. In this sketch
|
||||
a graded background is drawn, the color of each pixel can therefore be
|
||||
determined. The TFT does not need to support reading of the graphics memory.
|
||||
|
|
@ -99,7 +99,7 @@ void setup(void) {
|
|||
|
||||
void loop() {
|
||||
|
||||
// Select a font size comensurate with screen size
|
||||
// Select a font size commensurate with screen size
|
||||
if (tft.width()>= 320)
|
||||
tft.loadFont(AA_FONT_LARGE, LittleFS);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
This sketch is based on Font Demo 1. It introduces a method for rendering
|
||||
anti-aliased fonts on an arbitrary background. This is acheived by reading
|
||||
anti-aliased fonts on an arbitrary background. This is achieved by reading
|
||||
the pixel color at each point on the screen. The TFT must support reading
|
||||
the graphics RAM of the screen memory. This sketch has been tested with
|
||||
ILI9241 and ILI9481 serial and parallel screens. Other screens may or may
|
||||
|
|
@ -52,7 +52,7 @@ void setup(void) {
|
|||
|
||||
tft.begin();
|
||||
|
||||
tft.setCallback(pixelColor); // The callback is only used durung font rendering
|
||||
tft.setCallback(pixelColor); // The callback is only used during font rendering
|
||||
//tft.setCallback(nullptr); // Switch off callback (off by default)
|
||||
|
||||
tft.setRotation(1);
|
||||
|
|
@ -110,7 +110,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!
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
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 Multilingal Plane:
|
||||
The characters supported are in the in the Basic Multilingual Plane:
|
||||
https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
|
||||
|
||||
Make sure all the display driver and pin connenctions are correct by
|
||||
Make sure all the display driver and pin connections are correct by
|
||||
editing the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
#########################################################################
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#define AA_FONT_SMALL "NotoSansBold15"
|
||||
#define AA_FONT_LARGE "NotoSansBold36"
|
||||
|
||||
// Font files are stored in SPIFFS, so load the linbrary
|
||||
// Font files are stored in SPIFFS, so load the library
|
||||
#include <FS.h>
|
||||
|
||||
#include <SPI.h>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,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 anit-aliased fonts well the Sprite
|
||||
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
|
||||
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.
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#define AA_FONT_SMALL "NotoSansBold15"
|
||||
#define AA_FONT_LARGE "NotoSansBold36"
|
||||
#define AA_FONT_MONO "NotoSansMonoSCB20" // NotoSansMono-SemiCondensedBold 20pt
|
||||
// Font files are stored in SPIFFS, so load the linbrary
|
||||
// Font files are stored in SPIFFS, so load the library
|
||||
#include <FS.h>
|
||||
|
||||
#include <SPI.h>
|
||||
|
|
@ -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 anti aliased fonts
|
||||
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("SPIFFS initialisation failed!");
|
||||
|
|
@ -112,7 +112,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.
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ void loop() {
|
|||
// Mono spaced font
|
||||
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
spr.loadFont(AA_FONT_MONO); // Mono spaced fonts have fixed intercharacter gaps to
|
||||
spr.loadFont(AA_FONT_MONO); // Mono spaced fonts have fixed inter-character gaps to
|
||||
// aid formatting
|
||||
int bnum = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
#define AA_FONT_SMALL "NotoSansBold15"
|
||||
#define AA_FONT_LARGE "NotoSansBold36"
|
||||
|
||||
// Font files are stored in SPIFFS, so load the linbrary
|
||||
// Font files are stored in SPIFFS, so load the library
|
||||
#include <FS.h>
|
||||
|
||||
#include <SPI.h>
|
||||
|
|
@ -61,7 +61,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 anti-aliased fonts
|
||||
|
||||
if (!SPIFFS.begin()) {
|
||||
Serial.println("SPIFFS initialisation failed!");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Sketch to demonstrate using the print class with smooth fonts
|
||||
|
||||
Sketch is writtent for a 240 x 320 display
|
||||
Sketch is written for a 240 x 320 display
|
||||
|
||||
Load the font file into SPIFFS first by using the Arduino IDE
|
||||
Sketch Data Upload menu option. Font files must be stored in the
|
||||
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
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 Multilingal Plane:
|
||||
The characters supported are in the in the Basic Multilingual Plane:
|
||||
https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
|
||||
|
||||
Make sure all the display driver and pin connenctions are correct by
|
||||
Make sure all the display driver and pin connections are correct by
|
||||
editing the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
#########################################################################
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
This sketch is based on Font Demo 1. It introduces a method for rendering
|
||||
anti-aliased fonts on a graded background. This is acheived by telling the
|
||||
anti-aliased fonts on a graded background. This is achieved by telling the
|
||||
TFT_eSPI library the pixel color at each point on the screen. In this sketch
|
||||
a graded background is drawn, the color of each pixel can therefore be
|
||||
determined. The TFT does not need to support reading of the graphics memory.
|
||||
The sketch could be adapted so only part of the screen is gas a color gradient.
|
||||
|
||||
The TFT_eSPI library must be given the name of the function in the sketch
|
||||
that will return the pixel xolor at a position x,y on the TFT. In this
|
||||
that will return the pixel color at a position x,y on the TFT. In this
|
||||
sketch that function is called gradientColor, so this line is included:
|
||||
|
||||
tft.setCallback(gradientColor);
|
||||
|
|
@ -100,7 +100,7 @@ void setup(void) {
|
|||
|
||||
void loop() {
|
||||
|
||||
// Select a font size comensurate with screen size
|
||||
// Select a font size commensurate with screen size
|
||||
if (tft.width()>= 320)
|
||||
tft.loadFont(AA_FONT_LARGE);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
This sketch is based on Font Demo 1. It introduces a method for rendering
|
||||
anti-aliased fonts on an arbitrary background. This is acheived by reading
|
||||
anti-aliased fonts on an arbitrary background. This is achieved by reading
|
||||
the pixel color at each point on the screen. The TFT must support reading
|
||||
the graphics RAM of the screen memory. This sketch has been tested with
|
||||
ILI9241 and ILI9481 serial and parallel screens. Other screens may or may
|
||||
|
|
@ -52,7 +52,7 @@ void setup(void) {
|
|||
|
||||
tft.begin();
|
||||
|
||||
tft.setCallback(pixelColor); // The callback is only used durung font rendering
|
||||
tft.setCallback(pixelColor); // The callback is only used during font rendering
|
||||
//tft.setCallback(nullptr); // Switch off callback (off by default)
|
||||
|
||||
tft.setRotation(1);
|
||||
|
|
@ -81,7 +81,7 @@ void loop() {
|
|||
|
||||
rainbow_fill(); // Fill the screen with rainbow colours
|
||||
|
||||
// Select a font size comensurate with screen size
|
||||
// Select a font size commensurate with screen size
|
||||
if (tft.width()>= 320)
|
||||
tft.loadFont(AA_FONT_LARGE);
|
||||
else
|
||||
|
|
@ -110,7 +110,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!
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
// The sketch operates by creating a copy of the screen block where
|
||||
// the needle will be drawn, the needle is then drawn on the screen.
|
||||
// When the needle moves, the original copy of the sreen area is
|
||||
// When the needle moves, the original copy of the screen area is
|
||||
// pushed to the screen to over-write the needle graphic. A copy
|
||||
// of the screen where the new position will be drawn is then made
|
||||
// before drawing the needle in the new postion. This technique
|
||||
// before drawing the needle in the new position. This technique
|
||||
// allows the needle to move over other screen graphics.
|
||||
|
||||
// The sketch calculates the size of the buffer memory required and
|
||||
|
|
@ -195,7 +195,7 @@ void plotNeedle(int16_t angle, uint16_t ms_delay)
|
|||
buffer_loaded = true;
|
||||
}
|
||||
|
||||
// Draw the needle in the new postion, black in needle image is transparent
|
||||
// Draw the needle in the new position, black in needle image is transparent
|
||||
needle.pushRotated(old_angle, TFT_BLACK);
|
||||
|
||||
// Wait before next update
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// This sketch draws a rotating Yin and Yang symbol. It illustrates
|
||||
// the drawimg and rendering of simple animated graphics using
|
||||
// the drawing and rendering of simple animated graphics using
|
||||
// a 1 bit per pixel (1 bpp) Sprite.
|
||||
|
||||
// Note: TFT_BLACK sets the pixel value to 0
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ void loop() {
|
|||
// it is rotated and hence it clears the swept area to black
|
||||
for (int16_t angle = 0; angle <= 360; angle += 5)
|
||||
{
|
||||
needle.pushRotated(angle); // Plot direct to TFT at specifed angle
|
||||
needle.pushRotated(angle); // Plot direct to TFT at specified angle
|
||||
yield(); // Avoid a watchdog time-out
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
This example draws a jpeg image in a Sprite then plot a rotated copy of the Sprite
|
||||
to the TFT.
|
||||
|
||||
The jpeg used in in the sketch Data folder (presss Ctrl+K to see folder)
|
||||
The jpeg used in in the sketch Data folder (press Ctrl+K to see folder)
|
||||
|
||||
The jpeg must be uploaded to the ESP8266 or ESP32 SPIFFS by using the Tools menu
|
||||
sketch data upload option of the Arduino IDE. If you do not have that option it can
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
Created by Bodmer 6/1/19 as an example to the TFT_eSPI library:
|
||||
https://github.com/Bodmer/TFT_eSPI
|
||||
|
||||
Extension funtions in the TFT_eFEX library are used to list SPIFFS files and render
|
||||
Extension functions in the TFT_eFEX library are used to list SPIFFS files and render
|
||||
the jpeg to the TFT and to the Sprite:
|
||||
https://github.com/Bodmer/TFT_eFEX
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Display all the fast rendering fonts in a sprite
|
||||
|
||||
Make sure all the display driver and pin comnections are correct by
|
||||
Make sure all the display driver and pin connections are correct by
|
||||
editing the User_Setup.h file in the TFT_eSPI library folder.
|
||||
|
||||
#########################################################################
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ void loop() {
|
|||
// The new larger fonts do not use the .setCursor call, coords are embedded
|
||||
img.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!)
|
||||
img.drawCentreString("Font size 2", 80, 14, 2); // Draw text centre at position 80, 12 using font 2
|
||||
|
||||
//img.drawCentreString("Font size 2",81,12,2); // Draw text centre at position 80, 12 using font 2
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
A 16 bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
|
||||
On a ESP8266 Sprite sizes up to 126 x 160 can be accomodated,
|
||||
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.
|
||||
|
||||
When 8 bit colour depth sprites are created they occupy
|
||||
|
|
@ -46,7 +46,7 @@ void setup()
|
|||
// Initialise the TFT registers
|
||||
tft.init();
|
||||
|
||||
// Optionally set colour depth to 8 or 16 bits, default is 16 if not spedified
|
||||
// Optionally set colour depth to 8 or 16 bits, default is 16 if not specified
|
||||
// spr.setColorDepth(8);
|
||||
|
||||
// Create a sprite of defined size
|
||||
|
|
@ -123,7 +123,7 @@ void loop(void)
|
|||
{
|
||||
if (updateTime <= millis())
|
||||
{
|
||||
// Use time delay so sprtie does not move fast when not all on screen
|
||||
// Use time delay so sprite does not move fast when not all on screen
|
||||
updateTime = millis() + wait;
|
||||
|
||||
// Push the sprite to the TFT screen
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
A 16 bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
|
||||
On a ESP8266 Sprite sizes up to 126 x 160 can be accomodated,
|
||||
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.
|
||||
|
||||
When 8 bit color depth sprites are created they occupy
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Sketch to show scrolling of the graphics in sprites.
|
||||
Scrolling in this way moves the pixels in a defined rectangle
|
||||
within the Sprite. By defalt the whole sprite is scrolled.
|
||||
within the Sprite. By default the whole sprite is scrolled.
|
||||
The gap left by scrolling is filled with a defined colour.
|
||||
|
||||
Example for library:
|
||||
|
|
@ -74,7 +74,7 @@ void loop() {
|
|||
// Draw number in stext1 sprite at 31,63 (bottom right datum set)
|
||||
stext1.drawNumber(graphVal, 31, 63, 2); // plot value in font 2
|
||||
|
||||
// Push the sprites onto the TFT at specied coordinates
|
||||
// Push the sprites onto the TFT at specified coordinates
|
||||
graph1.pushSprite(0, 0);
|
||||
stext1.pushSprite(0, 64);
|
||||
stext2.pushSprite(40, 70);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
https://github.com/Bodmer/TFT_eSPI
|
||||
|
||||
The sketch has been tested on a 320x240 ILI9341 based TFT, it
|
||||
coule be adapted for other screen sizes.
|
||||
could be adapted for other screen sizes.
|
||||
|
||||
A Sprite is notionally an invisible graphics screen that is
|
||||
kept in the processors RAM. Graphics can be drawn into the
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
The Sprite occupies (2 * width * height) bytes.
|
||||
|
||||
On a ESP8266 Sprite sizes up to 128 x 160 can be accomodated,
|
||||
On a ESP8266 Sprite sizes up to 128 x 160 can be accommodated,
|
||||
this size requires 128*160*2 bytes (40kBytes) of RAM, this must be
|
||||
available or the processor will crash. You need to make the sprite
|
||||
small enough to fit, with RAM spare for any "local variables" that
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
tft.setBitmapColor(ON_COLOR, OFF_COLOR);
|
||||
|
||||
Scrolling moves the pixels in a defined rectangle within
|
||||
the Sprite. By defalt the whole sprite is scrolled.
|
||||
the Sprite. By default the whole sprite is scrolled.
|
||||
The gap left by scrolling is filled with a defined colour.
|
||||
|
||||
Example for library:
|
||||
|
|
@ -82,7 +82,7 @@ void loop() {
|
|||
// Draw number in stext1 sprite at 31,63 (bottom right datum set)
|
||||
stext1.drawNumber(graphVal, 31, 63, 2); // plot value in font 2
|
||||
|
||||
// Push the sprites onto the TFT at specied coordinates
|
||||
// Push the sprites onto the TFT at specified coordinates
|
||||
tft.setBitmapColor(TFT_WHITE, TFT_BLUE); // Specify the colours of the ON and OFF pixels
|
||||
graph1.pushSprite(0, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void setup() {
|
|||
tft.init();
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Populate the palette table, table must have 16 entires
|
||||
// Populate the palette table, table must have 16 entries
|
||||
palette[0] = TFT_BLACK;
|
||||
palette[1] = TFT_ORANGE;
|
||||
palette[2] = TFT_DARKGREEN;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
An 8 bit colour Sprite occupies (width * height) bytes.
|
||||
|
||||
On a ESP8266, 16 bit Sprite sizes up to 128 x 160 can be accomodated,
|
||||
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
|
||||
|
|
@ -108,7 +108,7 @@ void build_banner(String msg, int xpos)
|
|||
// Fill with rainbow stripes
|
||||
while (h--) img.drawFastHLine(0, h, IWIDTH, rainbow(h * 4));
|
||||
|
||||
// Draw some graphics, the text will apear to scroll over these
|
||||
// Draw some graphics, the text will appear to scroll over these
|
||||
img.fillRect (IWIDTH / 2 - 20, IHEIGHT / 2 - 10, 40, 20, TFT_YELLOW);
|
||||
img.fillCircle(IWIDTH / 2, IHEIGHT / 2, 10, TFT_ORANGE);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
A 16 bit Sprite occupies (2 * width * height) bytes in RAM.
|
||||
|
||||
On a ESP8266 Sprite sizes up to 126 x 160 can be accomodated,
|
||||
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.
|
||||
|
||||
When 8 bit colour depth sprites are created they occupy
|
||||
|
|
@ -54,7 +54,7 @@ void loop() {
|
|||
|
||||
uint32_t dt = millis();
|
||||
|
||||
// Now go bananas and draw 500 nore
|
||||
// Now go bananas and draw 500 more
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
int x = random(240-70);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
// Diagnostic test for the displayed colour order
|
||||
//
|
||||
// Writen by Bodmer 17/2/19 for the TFT_eSPI library:
|
||||
// Written by Bodmer 17/2/19 for the TFT_eSPI library:
|
||||
// https://github.com/Bodmer/TFT_eSPI
|
||||
|
||||
/*
|
||||
|
|
@ -66,7 +66,7 @@ void setup(void) {
|
|||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
// We can now plot text on screen using the "print" class
|
||||
tft.println("Intialised default\n");
|
||||
tft.println("Initialised default\n");
|
||||
tft.println("White text");
|
||||
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void loop() {
|
|||
|
||||
frame.fillSprite(PAPER); // Fill frame with white
|
||||
|
||||
// Draw circle in frame buffer (x, y, r, color) in center of screen
|
||||
// Draw circle in frame buffer (x, y, r, color) in centre of screen
|
||||
frame.drawCircle(frame.width()/2, frame.height()/2, frame.width()/6, INK);
|
||||
|
||||
// Draw diagonal lines
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "TFT_eSPI",
|
||||
"version": "2.3.70",
|
||||
"version": "2.3.73",
|
||||
"keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D",
|
||||
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32",
|
||||
"repository":
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name=TFT_eSPI
|
||||
version=2.3.70
|
||||
version=2.3.73
|
||||
author=Bodmer
|
||||
maintainer=Bodmer
|
||||
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
|
||||
|
|
|
|||
Loading…
Reference in New Issue