为什么这个渲染这么慢?

Why is this rendering so slow?

代码如下。我正在使用带有 Feather wing TFT 显示器的 Adafruit Huzzah Feather。我正在尝试创建一个简单的 GUI,上面有几个按钮。显示的初始按钮快如闪电,至少据我所知。当我点击触摸屏转到新的 "page" 时,我可以看到矩形在一秒钟内被绘制,然后我正在绘制的新按钮也是如此。这件事应该这么慢还是我在做一些愚蠢的事情?我什至在使用 "faster" TFT_eSPI 库。对于其他示例,如按钮,显示更新非常快。有什么想法吗?

#include <SPI.h>
#include <Wire.h>      // this is needed even tho we aren't using it
#include <ESP8266WiFi.h>
#include "FS.h"
#include <TFT_eSPI.h>    // Core graphics library
#include <Adafruit_STMPE610.h> // Touchscreen Controller

#define CALIBRATION_FILE "/TouchCalData3"
#define REPEAT_CAL false
#define TS_MINX 3800
#define TS_MAXX 100
#define TS_MINY 100
#define TS_MAXY 3750

const char *ssid = "AP"; // The name of the Wi-Fi network that will be created
const char *password = "changeme";   // The password required to connect to it, leave blank for an open network
Adafruit_STMPE610 ts = Adafruit_STMPE610(16);

int currentPage = 0;
bool allSelected = true;

TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h
void setup(void) {
  Serial.begin(115200);

  delay(10);  

  if (!ts.begin()) {
    Serial.println("Couldn't start touchscreen controller");
    while (1);
  }
  Serial.println("Touchscreen started");

  tft.init();
  tft.setRotation(0);

  setupAp();
  drawHomePage();
}

void drawHomePage() { 
  wipe();
  Serial.println("Drawing HP");

  long time1 = millis();
  tft.drawRoundRect(10, 10, 220, 145, 7, ILI9341_WHITE);
  tft.drawCentreString("LIGHTS", 120, 60, 2);

  tft.drawRoundRect(10, 165, 220, 145, 7, ILI9341_YELLOW);
  tft.setTextColor(ILI9341_YELLOW);
  tft.drawCentreString("GAUGES", 120, 220, 2);

  long time2 = millis();
  long result = time2 - time1;
  Serial.print("HP Took: "); Serial.println(result);
}

void drawLightsHomePage() {
  wipe();
  Serial.println("Drawing Lights");
  long time1 = millis();

  if(allSelected) {
    tft.fillRect(10, 10, 58, 52, ILI9341_WHITE);
    tft.setTextColor(ILI9341_BLACK);
    tft.drawCentreString("All", 34, 20, 2);
  }
  else {
    tft.drawRect(10, 10, 68, 52, ILI9341_WHITE);
    tft.setTextColor(ILI9341_WHITE);
    tft.drawCentreString("All", 34, 60, 2);
  }

  long time2 = millis();
  long result = time2 - time1;
  Serial.print("Lights Took: "); Serial.println(result);
}

void wipe() {
  long time1 = millis();
  Serial.println("Wiping screen");
  tft.fillRect(0, 0, 240, 320, ILI9341_BLACK);
  long time2 = millis();
  long result = time2 - time1;
  Serial.print("Wiping took: "); Serial.println(result);
}

void loop() {
  // Retrieve a point  
  TS_Point p = ts.getPoint();

  if (ts.bufferSize()) {
    p = ts.getPoint(); 
  } else {    
    p.x = p.y = p.z = -1;// this is our way of tracking touch 'release'!
  }

  if (p.z != -1) {
    tft.fillCircle(p.x, p.y, 2, TFT_WHITE);
    p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
    p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());
    Serial.print("("); Serial.print(p.x); Serial.print(", "); 
    Serial.print(p.y); Serial.print(", "); 
    Serial.print(p.z); Serial.println(") ");

    if(currentPage == 0) {
      if(p.y < 160) {
        Serial.println("Hit Button");
        currentPage = 1;
        drawLightsHomePage();
      }
      else if(p.y > 160 && p.y < 320) {
      }
    }
  }
}

void setupAp() {
  Serial.println('\n');

  WiFi.softAP(ssid, password);             // Start the access point
  Serial.print("Access Point \"");
  Serial.print(ssid);
  Serial.println("\" started");

  Serial.print("IP address:\t");
  Serial.println(WiFi.softAPIP());         // Send the IP address of the ESP8266 to the computer
}

times 的示例输出如下,但我可以发誓即使绘制按钮也需要半秒钟。真痛苦!

Wiping screen
Wiping took: 48
Drawing HP
HP Took: 6
(109, 111, 50)
Hit Button
Wiping screen
Wiping took: 1234
Drawing Lights
Lights Took: 52

看完之后简单的答案是:因为 hardware/library 太慢了。