Open VictorLamoine opened 4 months ago
The other demos are working fine, deform_init
most probably goes out of memory but I've not tried to debug more yet.
I'm more curious about the slow speed of drawing issue 😄
Enabling the double buffering solves the FPS issue, I now get ~ 20 FPS 👍🏼 Triple buffering seems to require too much memory for my µC!
Depending on the effect you should get around 25FPS with 320x240 display.
Looking at your config you do not have buffering enabled. You need to enable double buffering to have any decent speeds.
CONFIG_HAGL_HAL_USE_DOUBLE_BUFFERING=y
You could try to use the M5Stack config as basis for your board: https://github.com/tuupola/esp_effects/blob/master/sdkconfig.m5stack
For future viewers of this issue, my little demo updated with double buffering support:
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/event_groups.h>
#include <esp_log.h>
#include <font6x9.h>
#include <aps.h>
#include <fps.h>
#include <hagl_hal.h>
#include <hagl.h>
static EventGroupHandle_t event;
static hagl_backend_t *display;
static const uint8_t RENDER_FINISHED = (1 << 0);
void
flush_task(void *params)
{
while (1) {
EventBits_t bits = xEventGroupWaitBits(
event,
RENDER_FINISHED,
pdTRUE,
pdFALSE,
0
);
/* Flush only when RENDER_FINISHED is set. */
if ((bits & RENDER_FINISHED) != 0 ) {
hagl_flush(display);
}
vTaskDelay(20 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}
void
app_main()
{
vTaskDelay(2000 / portTICK_PERIOD_MS);
event = xEventGroupCreate();
#ifdef HAGL_HAS_HAL_BACK_BUFFER
xTaskCreatePinnedToCore(flush_task, "Flush", 4096, NULL, 1, NULL, 0);
#endif
display = hagl_init();
hagl_clear(display);
xEventGroupSetBits(event, RENDER_FINISHED);
// Draw lines
for (uint16_t i = 1; i < 100; i++) {
int16_t x0 = rand() % display->width;
int16_t y0 = rand() % display->height;
int16_t x1 = rand() % display->width;
int16_t y1 = rand() % display->height;
hagl_color_t color = rand() % 0xffff;
hagl_draw_line(display, x0, y0, x1, y1, color);
xEventGroupSetBits(event, RENDER_FINISHED);
}
vTaskDelay(10 * portTICK_PERIOD_MS);
// Draw disks
for (uint16_t i = 1; i < 100; i++) {
int16_t x0 = rand() % display->width;
int16_t y0 = rand() % display->height;
int16_t radius = rand() % 50;
hagl_color_t color = rand() % 0xffff;
hagl_fill_circle(display, x0, y0, radius, color);
xEventGroupSetBits(event, RENDER_FINISHED);
}
vTaskDelay(10 * portTICK_PERIOD_MS);
// Draw texts
for (uint16_t i = 1; i < 100; i++) {
int16_t x0 = rand() % display->width;
int16_t y0 = rand() % display->height;
hagl_color_t color = rand() % 0xffff;
wchar_t message[] = L"Hello World";
hagl_put_text(display, message, x0, y0, color, font6x9);
xEventGroupSetBits(event, RENDER_FINISHED);
}
}
It works great, thanks a lot for the hard work!
I'm using a ESP32 WROOM board and a ILI9341 TFT display.
The provided example is very slow (0 FPS) and crashes. I'm not sure exactly what to expect in terms of speed. Here is a short video.
This example works well, is the display writing speed what is expected? Video
Any idea of what is going wrong here?