Add ESP32 VSPI or HSPI port option + others
If the VSPI port is in use and pins are not accessible (e.g. TTGO T-Beam) then add or uncomment the following line in the setup header file: //#define USE_HSPI_PORT Minor performance tweaks for ESP32 to minimise the occurence of the slow transaction overhead. setAddrWindow now takes xstart, ystart, width and height as inputs Multi-sample raw touch x and y for noisy displays Example update for setAddrWindow change compatibility
This commit is contained in:
1 parent
0fdd25186a
commit
054a824eb8
16 files changed
+355
-242
No files matched your search
@@ -107,13 +107,17 @@ void midline() {
|
||||
// If the ball is not on the line then don't redraw the line
|
||||
if ((ball_x<dashline_x-ball_w) && (ball_x > dashline_x+dashline_w)) return;
|
||||
|
||||
tft.startWrite();
|
||||
|
||||
// Quick way to draw a dashed line
|
||||
tft.setAddrWindow(dashline_x,0,dashline_x+dashline_w-1,h);
|
||||
tft.setAddrWindow(dashline_x, 0, dashline_w, h);
|
||||
|
||||
for(int16_t i = 0; i < dashline_n; i+=2) {
|
||||
tft.pushColor(WHITE, dashline_w*dashline_h); // push dash pixels
|
||||
tft.pushColor(BLACK, dashline_w*dashline_h); // push gap pixels
|
||||
}
|
||||
|
||||
tft.endWrite();
|
||||
}
|
||||
|
||||
void lpaddle() {
|
||||
|
||||
@@ -308,14 +308,16 @@ uint32_t testHaD()
|
||||
0x0a, 0x2b, 0x0b, 0x41, 0x0a, 0x29, 0x0b, 0x43, 0x0a, 0x27, 0x0a, 0x46, 0x0a, 0x25, 0x0a, 0x49,
|
||||
0x09, 0x23, 0x08, 0x4e, 0x08, 0x96, 0x12
|
||||
};
|
||||
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
uint32_t start = micros_start();
|
||||
|
||||
|
||||
tft.startWrite();
|
||||
|
||||
for (int i = 0; i < 0x10; i++)
|
||||
{
|
||||
tft.setAddrWindow(0, 0, tft.width()-1, tft.height()-1);
|
||||
tft.setAddrWindow(0, 0, tft.width(), tft.height());
|
||||
|
||||
uint16_t cnt = 0;
|
||||
uint16_t color = tft.color565((i << 4) | i, (i << 4) | i, (i << 4) | i);
|
||||
@@ -335,6 +337,8 @@ uint32_t testHaD()
|
||||
}
|
||||
}
|
||||
|
||||
tft.endWrite();
|
||||
|
||||
uint32_t t = micros() - start;
|
||||
|
||||
tft.setTextColor(TFT_YELLOW);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
|
||||
#define ILI9341_GREY 0x7BEF
|
||||
#define TFT_GREY 0x7BEF
|
||||
|
||||
unsigned long runTime = 0;
|
||||
|
||||
@@ -16,8 +16,9 @@ uint16_t x0 = 0, x1 = 0, yy0 = 0, yy1 = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(250000);
|
||||
//randomSeed(analogRead(A0));
|
||||
|
||||
Serial.println();
|
||||
// Setup the LCD
|
||||
tft.init();
|
||||
tft.setRotation(3);
|
||||
@@ -27,7 +28,8 @@ void loop()
|
||||
{
|
||||
runTime = millis();
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.startWrite();
|
||||
for (int px = 1; px < 320; px++)
|
||||
{
|
||||
for (int py = 0; py < 240; py++)
|
||||
@@ -49,6 +51,9 @@ void loop()
|
||||
yield();tft.drawPixel(px, py, color);
|
||||
}
|
||||
}
|
||||
tft.endWrite();
|
||||
|
||||
Serial.println(millis()-runTime);
|
||||
while(1) yield();
|
||||
}
|
||||
|
||||
|
||||
@@ -108,13 +108,17 @@ void midline() {
|
||||
// If the ball is not on the line then don't redraw the line
|
||||
if ((ball_x<dashline_x-ball_w) && (ball_x > dashline_x+dashline_w)) return;
|
||||
|
||||
tft.startWrite();
|
||||
|
||||
// Quick way to draw a dashed line
|
||||
tft.setWindow(dashline_x,0,dashline_x+dashline_w-1,h);
|
||||
tft.setAddrWindow(dashline_x, 0, dashline_w, h);
|
||||
|
||||
for(int16_t i = 0; i < dashline_n; i+=2) {
|
||||
tft.pushColor(WHITE, dashline_w*dashline_h); // push dash pixels
|
||||
tft.pushColor(BLACK, dashline_w*dashline_h); // push gap pixels
|
||||
}
|
||||
|
||||
tft.endWrite();
|
||||
}
|
||||
|
||||
void lpaddle() {
|
||||
|
||||
@@ -336,10 +336,10 @@ uint32_t testHaD()
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
uint32_t start = micros_start();
|
||||
|
||||
|
||||
for (int i = 0; i < 0x10; i++)
|
||||
{
|
||||
tft.setWindow(0, 0, 240-1, 320-1);
|
||||
tft.setAddrWindow(0, 0, 240, 320);
|
||||
|
||||
uint16_t cnt = 0;
|
||||
uint16_t color = tft.color565((i << 4) | i, (i << 4) | i, (i << 4) | i);
|
||||
@@ -347,6 +347,7 @@ uint32_t testHaD()
|
||||
|
||||
const uint8_t *cmp = &HaD_240x320[0];
|
||||
|
||||
tft.startWrite();
|
||||
while (cmp < &HaD_240x320[sizeof(HaD_240x320)])
|
||||
{
|
||||
cnt = pgm_read_byte(cmp++);
|
||||
@@ -354,6 +355,7 @@ uint32_t testHaD()
|
||||
tft.pushColor(curcolor, cnt); // PDQ_GFX has count
|
||||
curcolor ^= color;
|
||||
}
|
||||
tft.endWrite();
|
||||
}
|
||||
|
||||
uint32_t t = micros() - start;
|
||||
|
||||
@@ -171,11 +171,14 @@ void renderJPEG(int xpos, int ypos) {
|
||||
// calculate how many pixels must be drawn
|
||||
uint32_t mcu_pixels = win_w * win_h;
|
||||
|
||||
tft.startWrite();
|
||||
|
||||
// draw image MCU block only if it will fit on the screen
|
||||
if (( mcu_x + win_w ) <= tft.width() && ( mcu_y + win_h ) <= tft.height())
|
||||
{
|
||||
|
||||
// Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
|
||||
tft.setWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
|
||||
tft.setAddrWindow(mcu_x, mcu_y, win_w, win_h);
|
||||
|
||||
// Write all MCU pixels to the TFT window
|
||||
while (mcu_pixels--) {
|
||||
@@ -185,6 +188,8 @@ void renderJPEG(int xpos, int ypos) {
|
||||
|
||||
}
|
||||
else if ( (mcu_y + win_h) >= tft.height()) JpegDec.abort(); // Image has run off bottom of screen so abort decoding
|
||||
|
||||
tft.endWrite();
|
||||
}
|
||||
|
||||
// calculate how long it took to draw the image
|
||||
|
||||
@@ -251,8 +251,10 @@ void drawIcon(const unsigned short* icon, int16_t x, int16_t y, int8_t width, in
|
||||
|
||||
uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)
|
||||
|
||||
tft.startWrite();
|
||||
|
||||
// Set up a window the right size to stream pixels into
|
||||
tft.setWindow(x, y, x + width - 1, y + height - 1);
|
||||
tft.setAddrWindow(x, y, width, height);
|
||||
|
||||
// Work out the number whole buffers to send
|
||||
uint16_t nb = ((uint16_t)height * width) / BUFF_SIZE;
|
||||
@@ -273,5 +275,7 @@ void drawIcon(const unsigned short* icon, int16_t x, int16_t y, int8_t width, in
|
||||
for (int i = 0; i < np; i++) pix_buffer[i] = pgm_read_word(&icon[nb * BUFF_SIZE + i]);
|
||||
tft.pushColors(pix_buffer, np);
|
||||
}
|
||||
|
||||
tft.endWrite();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user