• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

LVGL log lines printed twice on Serial monitor

Q&A Forum › Category: Arduino › LVGL log lines printed twice on Serial monitor
0 Vote Up Vote Down
Gilbert Hersschens asked 5 months ago

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.

Question Tags: LVGL
10 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

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

0 Vote Up Vote Down
Gilbert Hersschens answered 5 months ago

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);
  }
}

Screenshot Serial monitor
 
Arduino IDE: 2.3.3
ESP chip: ESP-WROOM-32
Board selection: ESP32 Dev Module
Flash Partition scheme: HHUGE AOO

0 Vote Up Vote Down
Gilbert Hersschens answered 5 months ago

Looks like inserting the sccreenshot didn’t go well. Can you help?

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

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

0 Vote Up Vote Down
Gilbert Hersschens answered 5 months ago

https://drive.google.com/file/d/1-BrMoA3HQXao_DrqVHGImHOsoHMSfU99/view?usp=sharing

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

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

0 Vote Up Vote Down
Gilbert Hersschens answered 5 months ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

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

0 Vote Up Vote Down
Gilbert Hersschens answered 5 months ago

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.

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

Hi.
Thanks for letting me know.
I didn’t know about it.
I’ll take a look into it.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.