Hi all!
Please let me know if this is the wrong area to post this question.
I am currently successfully running LVGL on a SPI TFT display and am attempting to integrate an RFID module as well. The RFID module works flawlessly by itself but does not function if I am using the TFT screen with LVGL:
I narrowed down the issue to the invocation of lv_tft_espi_create(). Removing this function restores all functionality to the RFID reader, but obviously I need the SPI settings to create the display object.
Is there anyway I can get both of these modules to work in tandem? Someone suggested I look into SPITransactions but I'm completely stumped on how to apply it correctly.
This is my, very bad, initial attempt at implementation.
#include <Arduino.h>
#include <lvgl.h>
#include <TFT_eSPI.h>
#include <MFRC522.h>
#include <SPI.h>
#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 10 * (LV_COLOR_DEPTH / 8))
void *draw_buf;
TFT_eSPI tft = TFT_eSPI();
// Define SPI settings for TFT and RFID
SPISettings tftSPISettings(20000000, MSBFIRST, SPI_MODE0); // Matched the SPI_FREQUENCY in my TFT config: 20MHz
SPISettings rfidSPISettings(10000000, MSBFIRST, SPI_MODE0);
void setup()
{
Serial.begin(115200);
SPI.begin();
SPI.beginTransaction(tftSPISettings); // BEGIN TFT SPI TRANSACTION
lv_init();
lv_tick_set_cb(lv_millis);
draw_buf = heap_caps_malloc(DRAW_BUF_SIZE, MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
// This is the problematic line:
lv_display_t *disp = lv_tft_espi_create(TFT_HOR_RES, TFT_VER_RES, draw_buf, DRAW_BUF_SIZE);
lv_display_set_rotation(disp, LVGL_SCREEN_ROTATION);
lv_indev_t *indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_touchpad_read);
calibrateTouch();
tft.fillScreen(TFT_BLACK);
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, LVGL_Arduino.c_str());
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
SPI.endTransaction(); // END TFT SPI TRANSACTION
SPI.beginTransaction(rfidSPISettings); // BEGIN RFID SPI TRANSACTION
mfrc522.PCD_Init();
SPI.endTransaction(); // END RFID SPI TRANSACTION
}
void loop()
{
SPI.beginTransaction(tftSPISettings); // BEGIN TFT SPI TRANSACTION
lv_task_handler();
SPI.endTransaction(); // END TFT SPI TRANSACTION
}
An member at the LVGL forum seemed to have some recommendations for me but I had some trouble following...
Any help would be super appreciated; I'm not sure how to proceed here at all.
EDIT- It's worth mentioning that there was a pins conflict that was previously not allowing the RC522 module to read any data, even without initializing the TFT eSPI. The conflict was that the TFT's T_DO & MISO pins were using the MISO pin, along with the RC522's MISO pin. This was fixed by moving the T_DO to an unused pin.


