Hey, after successfully getting a hello world program up and running, I’m now experimenting with how to use LVGL.
I thought that I’d try to update some text in a loop, but when I do that, I run into this error: [Error] (0.504, +504) _lv_inv_area: Asserted at expression: !disp->rendering_in_progress (Invalidate area is not allowed during rendering.) lv_refr.c:257.
What am I doing wrong here?
What MCU/Processor/Board and compiler are you using?
Ideally, I’d like to be able to print something to the screen whenever I want, since I want to print debugging messages to the screen when necessary.
What have you tried so far?
The code I have is given below.
Code to reproduce
#include <Arduino.h>
#include <drivers/display/st7789/lv_st7789.h>
#include <lvgl.h>
#include "display.h"
#include "hardware_setup.h"
lv_obj_t* display_text;
void ui_init()
{
const auto screen = lv_screen_active();
lv_obj_set_style_bg_color(screen, lv_color_hex(0x003a57), LV_PART_MAIN);
display_text = lv_label_create(screen);
lv_label_set_text(display_text, "Hello, world!");
lv_obj_set_style_text_color(screen, lv_color_hex(0xffffff), LV_PART_MAIN);
lv_obj_align(display_text, LV_ALIGN_CENTER, 0, 0);
}
void setup() {
Serial.begin(115200);
sleep(1); // Wait a bit for Serial to become ready. Printing immediately doesn't work
Display::init();
ui_init();
}
void loop() {
lv_label_set_text(display_text, "Hello, world!");
delayMicroseconds(100000);
}
Here, Display::init() contains initialization code specific to my setup. It contains a call to lv_init() and does things like setting up my draw buffers.
Right, I don’t quite understand how lvgl works. I’m still trying to figure that out. A walkthrough explaining not only the “what”, but also the “why” and “how” of the basic workings of lvgl would be really nice, but I haven’t found that so far.
Well, as my linked question indicates, the correct usage of lv_timer_handler() is not quite clear to me.
The timer handler documentation is very sparse, mentioning only that:
To handle the tasks of LVGL you need to call lv_timer_handler() periodically in one of the following:
while(1) of main() function
timer interrupt periodically (lower priority than lv_tick_inc())
an OS task periodically
Therefore, I do call the function periodically using a timer interrupt:
NO your code interrupt call in same place inc and handler ! Maybe read precisely lower priority as lv_tick_inc say cleanly you cant call on same place.
But for clean you primary need understand what you do. And for beginer is first point most simple use while… second two variant is for profesionals …
Then do what i write activate lv_conf custom tick and use loop…
And one additional info v 9.0 is born some weeks and i agree with you , documents is … For beginer i mean good start point is v 8