I am trying to add sounds to an LVGL application. When I add an RTOS task for a sound loop, the LVGL performance tanks. The screen flickers, goes black, sometimes doesn’t render. Particularly, when I start a sound playing, LVGL appears to just stop rendering to the screen.
I have tried pinning LVGL to one core and the sound loop to another core and this didn’t resolve the issues.
I am using an ESP32 and the ESP8266Audio library.
How type of screen used, how bus? How resolution? …
OK is displays with memory , but here for bigger area animation too limit audio.
I’m using a Panlee WT32SC01 Plus. I’m using LovyanGFX to paint the screen. The audio is delivered through a speaker on an I2S chip.
I have a sound playing successfully when I press a button, but the screen just goes black and stays that way.
Your display seems 8080 and have memory, then you need show your code here …
And i have tested other audio lib GitHub - schreibfaul1/ESP32-audioI2S: Play mp3 files from SD via I2S
Let me try that library and I will report back.
Similar issue. As soon as I call this the screen goes black.
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
show where you call this, normal is in setup
create code based on example from lib separate_audiotask.ino
and change add this
audio.loop();
if (!audio.isRunning()) {
sleep(1);
}
else delay(1);
Yes I call the line in setup. Want to clarify the issue is not playing the sound, that works. The issue is when I do that it halts LVGL somehow. I have validated that the LVGL refresh task is still calling lv_timer_handler(); every millisecond, and there are no errors reported from LVGL, but the screen just turns off.
Here is my sound.cpp file:
#include "audio.h"
#define I2S_DOUT 37
#define I2S_BCLK 36
#define I2S_LRC 35
namespace Sound
{
void setup();
void play();
void loop();
}
Audio audio;
void Sound::setup()
{
ESP_LOGI(MODULE_NAME_APP_SETUP, "Sound - Starting");
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // default 0...21
}
void Sound::play()
{
ESP_LOGI(MODULE_NAME_SOUND, "Playing Sound");
audio.connecttohost("http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/");
}
void Sound::loop()
{
audio.loop();
}
And the RTOSTasks are as such
xTaskCreate(lvglCallback, "tLVGLTimer", RTOS_LVGL_STACK_SIZE, (void *)0, RTOS_LVGL_PRIORITY, &tLVGLTimerHandle);
xTaskCreatePinnedToCore(soundCallback, "tSoundTimer", RTOS_SOUND_STACK_SIZE, (void *)0, RTOS_SOUND_PRIORITY, &tSoundTimerHandle, 0);
...
void RTOSTasks::lvglCallback(void *p)
{
while (1)
{
lv_timer_handler();
vTaskDelay(LVGL_CALLBACK_INTERVAL);
}
}
void RTOSTasks::soundCallback(void *p)
{
while (1)
{
Sound::loop();
vTaskDelay(SOUND_CALLBACK_INTERVAL);
}
}
Hmmm i mean pio 35 36 37 is reeserved, you cant use it…
Here is a minimal project I made that has LVGL and Sound. If you hit the “Play Sound” button the screen shuts off. This is a PlatformIO project.
codegrue/WS32SC01-LVGL-Sound (github.com)
As for the pins, here is the data sheet for the board:
WT32-SC01 PLUS Datasheet
[1] Audio amplifier (IIS interface) (Tab.7)
Description Module Pin
LRCK GPIO 35
BCLK GPIO 36
DOUT GPIO 37
mmar22
February 2, 2024, 2:04pm
11
Which pins can I use on an ESP32-S3 (luisllamas.es) read about PSRAM…
and your board JSON file enable psram.
I removed LVGL from the project and was able to reproduce the issue with just the LovyanGFX library. So sorry to post on this forum. If anyone is able to work with me further the minimal project is here:
SoundIssue2.zip
And here is a video of the issue. Whenever a sound plays (in this case an MP3 off the SD card) the screen turns off.
Thanks!
In case it helps others, the solution was the audio setup has to happen BEFORE the graphics setup.