I’m starting to learn about LVGL and CYD. In my current sketch (based on https://randomnerdtutorials.com/lvgl-cheap-yellow-display-esp32-2432s028r/) I notice that all log statements are printed twice in the Serial monitor. No big deal, but I wonder why… There is only one “LV_LOG_USER(some string)” statement in the code.
Hi.
It is printed when it detects the events.
Maybe the events are being detected twice?
Or do you get the exact same information repeatedly?
Regards,
SAra
I get exactly the same line twice, with exactly the same timestamp for all events (buttons and slider). The response of CYD when I touch the buttons or the slider is correct.
The code includes an even count. It increments in steps of 1, which means that the evnts are not detected twice.
int btn1_count = 0;
// Callback that is triggered when btn1 is clicked
static void event_handler_btn1(lv_event_t * e) {
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_CLICKED) {
btn1_count++;
LV_LOG_USER(“Button clicked %d”, (int)btn1_count);
}
}
Arduino IDE: 2.3.3
ESP chip: ESP-WROOM-32
Board selection: ESP32 Dev Module
Flash Partition scheme: HHUGE AOO
Hi.
Use Imgur.com free image hosting service, or google drive, or dropox to upload images. Then, share a link to the file.
Regards,
Sara
Hi again.
Thanks for sharing.
To be honest, I don’t know why that is happening…
I’m not sure how to fix that…
But, is the interface working as expected?
Regards,
Sara
Yes, other than the messages on Serial monitor, everything is working as expected. I modified the sketch to display current date and time i.s.o. “Hello World” and it took me some time to realize that I couldn’t use a formatting string like
“%Y-%m-%d T %H:%M:%S” to populate a char buffer. But I worked around that by using itoa() and strcat() with all members of the tm struct and I’m happy with the result.
Thanks for looking into the issue. I’ll post it on the LVGL forum and see what happens.
I also need to figure out what exacly is the purpose of the timing in the loop
lv_task_handler(); // let the GUI do its work
lv_tick_inc(5); // tell LVGL how much time has passed
delay(5); // let this time pass
I’m not there yet, but the final program will make http calls to retrieve data from Google calendar, and the call blocks for about 4 seconds. Not sure if that will mess up the display functions. If you have any experience with blocking calls interfering with LVGL, please share.
Gilbert
Hi.
I don’t think it will mess it up.
We have a tutorial that requests data from the internet to display on the OLED.
In our case, it’s a clock. It may be useful: https://randomnerdtutorials.com/esp32-cyd-lvgl-digital-clock/
Regards,
Sara
Thanks, Sara. I included the code from https://randomnerdtutorials.com/lvgl-cheap-yellow-display-esp32-2432s028r/ in my sketch which does all the web stuff and the result is acceptable. When I retrieve data from Google calendar, the http call blocks for about 4 seconds, during which the CYD display freezes: no updates of time/date and no response to button touches. When the http call returns, everything is back to normal. My sketch also includes synching with an NTP time server (like your example for the diigital clock, but I use the time library and sntp_set_time_sync_notification_cb(…) to get the ntp time in the background. No need to decode JSON objects to get the real time.
https://drive.google.com/file/d/1-E87zOfwMG83dCne9nJ46kqsuCXM0fLV/view?usp=sharing
BTW, there is a compatibility problem when you use the latest versions of the “TFT_eSPI” library and the “esp32” boards platform’s “WebServer” library. See https://forum.arduino.cc/t/ide-2-3-3-compiling-problem/1316207/4. Maybe you already know about it. Simply putting “#include <TFT_eSPI.h>” at the end of the list of “#include” statements fixes the problem. I didn’t get any crashes (so far…) as described further on into the issue.