Lvgl snapshot_take

I am wanting to snapshot the current display. It seems to mostly work, but I’m only getting part of the image. Maybe because of double buffering? Is there a better way? I am running on ESP32 with ST7735 driver. The screen is currently set to a green background, which seems to be about right in the captured image.

import lvgl as lv
import utime


# Global variable to store the pixel data
snapshot = None

def take(file_name="/app/mcc/images/snapshot.bin"):
    global snapshot  # Indicate that we're using the global variable

    scr = lv.screen_active()

    # Take a snapshot of the screen
    start_time = utime.ticks_us()
    snapshot = lv.snapshot_take(scr, lv.COLOR_FORMAT.NATIVE)

    end_time = utime.ticks_us()
    #print(f"Snapshot taken in {utime.ticks_diff(end_time, start_time)} microseconds")



Image has now changed to all noise.

I’ve now changed the background to blue. The blue sorta moves up and down? Occasionally filling the buffer, and then being emptied.


Created bug ticket:

lv.snapshot_take works fine. The problem is/was getting the data out of the snapshot. it’s a C Array uint8[]. I need to get it into a bytearray response for a httpserver.

response = bytearray(snapshot.snapshot.data_size)
for i in range(snapshot.snapshot.data_size):
response[i] =[I]

This works well enough, but it’s slow. Can you recommend a fast way to use the snapshot? I tried uctypes.bytes_at, but that is what was giving me the noise above.

I’ve tested the snapshot and I can confirm it really works.

Unfortunately I cannot comment on the MicroPython part. :frowning: