You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xiao ESP32C3搭载GC9A01显示屏时开启WiFi导致SPI显示故障

问题:开启WiFi后TFT_eSPI显示冻结

我在同时进行WiFi操作和使用TFT_eSPI显示图形时遇到问题——开启WiFi模块后,显示更新就停止了。试过用FreeRTOS和Arduino重写代码,都没用。看起来WiFi保持开启状态时显示能正常运行,但开启WiFi的过程会导致故障。

编辑补充:测试复现代码

我写了一个简化的测试程序复现故障。程序中心有简单动画,两个按钮可以更改动画颜色。动画运行10个周期后,开启WiFi并尝试连接,此时所有内容都会冻结:

#include <SPI.h>
#include <TFT_eSPI.h>
#include "I2C_BM8563.h"
#define USE_TFT_ESPI_LIBRARY
#include "lv_xiao_round_screen.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <WiFi.h>
#include <HTTPClient.h>

TFT_eSprite img = TFT_eSprite(&tft);

const char *ssid = "ST";
const char *password = "test1234";


// https://rgbcolorpicker.com/565
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0

double center_x = 120;
double center_y = 120;

lv_coord_t touchX, touchY;

bool init_wifi = false;
bool connected_wifi = false;

void setup() {

  Serial.begin(9600);

  // Start I2C
  Wire.begin();

  WiFi.disconnect();
  WiFi.mode(WIFI_OFF);
  // WiFi.enableSTA(true);

  tft.begin();
  tft.setRotation(0);
  tft.fillScreen(BLACK);

  static lv_indev_drv_t indev_drv;
  lv_indev_drv_init(&indev_drv);
  indev_drv.type = LV_INDEV_TYPE_POINTER;
  indev_drv.read_cb = chsc6x_read;
  lv_indev_drv_register(&indev_drv);

  img.setColorDepth(16);
}

int rad = 0;
uint32_t color = GREEN;
int cnt = 0;

void loop() {

  // Process button inputs to color animation
  if (chsc6x_is_pressed()) {
    chsc6x_get_xy(&touchX, &touchY);
    if (touchX > center_x) {
      color = RED;
    } else {
      color = GREEN;
    }
  }

  // Drive the animation
  int rad = cnt % 40;

  // Draw some buttons and a simple animation
  img.createSprite(240, 240);
  img.fillScreen(BLACK);
  img.drawCircle(center_x, center_y, 40, WHITE);
  img.drawCircle(center_x, center_y, rad, color);
  img.fillCircle(center_x + 80, center_y, 10, RED);
  img.fillCircle(center_x - 80, center_y, 10, GREEN);
  img.fillCircle(center_x, center_y - 80, 10, init_wifi ? connected_wifi ? GREEN : BLUE : BLACK);
  img.pushSprite(0, 0, TFT_TRANSPARENT);
  img.deleteSprite();

  // Enable wifi after 400 cnts have passed
  if (cnt > 400)
  {
    // On first loop initialize wifi
    if (!init_wifi) {
      WiFi.mode(WIFI_STA);
      WiFi.enableSTA(true);
      WiFi.begin(ssid, password);
      init_wifi = true;
    }

    // On every subsequent loop, check connection status
    if (WiFi.status() == WL_CONNECTED) {
      connected_wifi = true;
    }
  } 

  cnt++;
}

内容的提问来源于stack exchange,提问作者Zico

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 00:45:11