Reputation: 253
I'm trying to display graphics using tft_espi while doing wifi stuff, but it seems that turning on the wifi module causes display updates to cease working. I've tried rewriting the code using FreeRTOS and arduino, no dice. It seems like you can turn on WiFi and keep it on while displaying stuff no problem, but turning on WiFi breaks things. Any tips would be appreciated. Sister post on the Seeed Studio (manufacturers of the device and display): https://forum.seeedstudio.com/t/xiao-esp32c3-with-round-display-touch-not-working-with-wifi/283388/11
Edit: I've written a much simpler application that shows the fault. There is a simple animation in the center, and two buttons to change the color of the animation. After 10 cycles of the animation, I turn on WiFi and try to connect, and everything freezes:
#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++;
}
Upvotes: 1
Views: 154