Git Product home page Git Product logo

Comments (5)

kisvegabor avatar kisvegabor commented on June 4, 2024

buf 1 flushing to display
as buf 1 is being written to the display copy the invalid areas from the buffer to buf 2
buf 2 gets updated by LVGL
hold program until buf 1 is fully flushed.
write buf 2 to the display

I assume that you are using a display with RGB interface. If so one step is missing from here: when do you switch the frame buffers buffers? With #6120 it will work like this:

  1. buf1 flushing to screen: the flashing is fast as LVGL already rendered everything to the correct place, and we just need to wat for VSYNC. At this point still buf2 is shown.
  2. LVGL wants to render to buf2, but it need to wait for VSYNC to not draw to the active buffer
  3. Buffers are swapped, now buf1 is on the screen, buf2 can be used for rendedring
  4. Sync buf2 from buf1
  5. Draw to buf2
  6. Flush buf2, same as 1)

If you are using an SPI/parallel based display with a display controller PARTIAL mode should be better choice.

from lvgl.

kdschlosser avatar kdschlosser commented on June 4, 2024

I am testing this using SDL locally but the same thing is being seen wen running an actual MCU with a display that has and RGB connection

I am not able to wrap my head around the order in which things are being done. It looks like the copying of the buffer is being done before the invalidated areas are rendered but the notes in the file say otherwise.

Are the notes incorrect?

I feel like there is a stall in the code that is causing a wait until the buffer gets emptied before doing anything. Even when removing that one wait that is in the code I still end up with a 15 millisecond hang when calling lv_task_handler. That seems like a very large amount of time for rendering 2 sliders. While I know the pixel count is high at 800 x 480 having that kind of a stall seems to be pretty excessive. This is also running on a PC and not a micro controller so the stall would be even longer on a microcontroller.

from lvgl.

kdschlosser avatar kdschlosser commented on June 4, 2024

This is what a user is running as a test...

scrn = lv.screen_active()
lslider = lv.slider(scrn)
lslider.set_style_size(225, 480, lv.PART.MAIN)
lslider.align(lv.ALIGN.TOP_LEFT, 0, 0)
rslider = lv.slider(scrn)
rslider.set_style_size(225, 480, lv.PART.MAIN)
rslider.align(lv.ALIGN.TOP_RIGHT, 0, 0)


slider_1_inc = 1
slider_2_inc = -1
slider_1_value = 0
slider_2_value = 100

while True:
    time.sleep_ms(10)
    lslider.set_value(slider_1_value, lv.ANIM.OFF)

    slider_1_value += slider_1_inc
    if slider_1_value in (0, 100):
        slider_1_inc = -slider_1_inc

    rslider.set_value(slider_2_value, lv.ANIM.OFF)

    slider_2_value += slider_2_inc
    if slider_2_value in (0, 100):
        slider_2_inc = -slider_2_inc

    start_time = time.ticks_ms()
    lv.refr_now(lv.display_get_default())
    stop_time = time.ticks_ms()
    print('refr time:', time.tick_diff(stop_time, start_time))
    print()
    lv.tick_inc(10)

This test is only testing how long it takes for lv_refr_now to run after updating the 2 slider widgets

This is what I am getting for output

refr time: 185
refr time: 186
refr time: 186

Now change the code so a refresh is done after each widget has it's value changed

scrn = lv.screen_active()
lslider = lv.slider(scrn)
lslider.set_style_size(225, 480, lv.PART.MAIN)
lslider.align(lv.ALIGN.TOP_LEFT, 0, 0)
rslider = lv.slider(scrn)
rslider.set_style_size(225, 480, lv.PART.MAIN)
rslider.align(lv.ALIGN.TOP_RIGHT, 0, 0)


slider_1_inc = 1
slider_2_inc = -1
slider_1_value = 0
slider_2_value = 100

while True:
    time.sleep_ms(10)
    lslider.set_value(slider_1_value, lv.ANIM.OFF)
    lv.refr_now(lv.display_get_default())

    slider_1_value += slider_1_inc
    if slider_1_value in (0, 100):
        slider_1_inc = -slider_1_inc

    rslider.set_value(slider_2_value, lv.ANIM.OFF)

    slider_2_value += slider_2_inc
    if slider_2_value in (0, 100):
        slider_2_inc = -slider_2_inc

    start_time = time.ticks_ms()
    lv.refr_now(lv.display_get_default())
    stop_time = time.ticks_ms()
    print('refr time:', time.tick_diff(stop_time, start_time))
    print()
    lv.tick_inc(10)

so now I am only doing a refresh of one of the sliders and this is the output

refr time: 98
refr time: 98
refr time: 98
refr time: 98

The flickering and tearing is also reduced by 95%

98 milliseconds seems like a really long time for the refresh to run for. This is an RGB565 display that is 800 x 480 connected using an RGB bus with double buffering.

from lvgl.

kdschlosser avatar kdschlosser commented on June 4, 2024

forgot to mention that is running on an ESP32-S3

from lvgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.