-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(display): add save screenshot to file support #5481
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I think this PR should not be added to display and draw_buf, because:
- display/draw_buf should contain only tightly related functions, and not any unrelated things. Meaning: do not add function to create a file in file system to write actual screen buffer into it. That should be done in a separate code (higher level of architecture).
- -> Please avoid the "god object" anti-pattern!
- There is already a feature to take screenshots: snapshot
- Do not add a function that will be used (only) for testing / debugging
- display/draw_buf should not know about FS module
- if FS is not enabled in
lv_conf.h
, then saving would throw error
How about adding utils directly in It's really useful to debug drawing issues, we have been using the same method since v8 together with obj screenshot. The code is not only used for debugging but can also be used by application. For example, current app view can be saved to file system as an app preview image, and then be used in background task manager. |
Yes, if that is really needed, then it can be added to |
bcbcdea
to
3793f74
Compare
What about making it a snapshot feature, like It would be even better to have a |
It could also be really useful. Let's prepare it in another PR after #5487 is reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because file operations (especially saving many kilobytes to flash) can take many hundred miliseconds, it is better to duplicate the draw buf in memory, and saving that to file. Memory copy finishes faster, so even if source draw buf is not locked, the chance of “transient” state is less than saving the source directly to file system.
So, you have to decide: block drawing for a few ten-hundred miliseconds to save draw buf to filesystem, or duplicate it (more memory needed) and save that snapshot.
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
efc5059
to
cc569f2
Compare
LVGL operates on a single thread, which prevents the use of its API in a separate thread for file writing. It is advisable to allow the user to determine the best approach, whether that involves duplicating a new draw buffer for a different thread or creating a static loading UI that displays This API could serve as an initial step for users who wish to optimize it. Additionally, this API is not solely beneficial for debugging. It can also be utilized to save PNG decoded images as .bin images, for instance. |
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: Xu Xingliang <xuxingliang@xiaomi.com>
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: Xu Xingliang <xuxingliang@xiaomi.com>
Description of the feature or fix
Added screenshot saving file function to facilitate debugging of images during the drawing process.
Thanks to draw_buf, which unifies the data structure of the drawing buffer, it is extremely convenient to expand related functions later.
Notes
lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py
(astyle needs to be installed) and follow the Code Conventions