-
Notifications
You must be signed in to change notification settings - Fork 37
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
Gcode Thumbnail in progress screen #141
Comments
It currently only shows in the file print confirmation screen on klipper. Image needs to be a 32x32 png image. Will show later |
Wow, it is SO tiny? :) I just could not realise it is actual thumbnail! :) OK, got it, just a follow-up question regarding the GUI customisations - do you use a tool like SquareLine for the GUI or simply |
That's 32x32 pixels :)
I try to not hardcode pixel offsets etc, newer elements written by me try to use dynamic scaling (i should probably rewrite the gui again now that the backend has been rewritten). But no, i do indeed write everything manually. |
IC, I was waiting for the project code to be fully merged with all the features (like backend-frontend separation and serial console) before attempting to replace my stock Neopixel display with a custom one. Now I'm feeling ready to proceed and will definitely do some GUI enhancements. Just a good idea to keep those "inline" with the overall project ideology. Thank you! |
Great, it is now much more useable! Thank you!
Just my thoughts: Another idea could be to use a "helper" app on the host side. It can be implemented at least for the Serial Klipper setup: the "host" daemon can do upscaling and provide necessary higher resolution thumbnails to the display. Although this helper app can also be installed and run for wireless Klipper setups.
Nice, will take a look for better understanding! |
The issue is that a CYD is very memory constrained (we have ~100kb free!). LVGL at the moment also uses a static buffer for image decoding, and if the image is larger than 32x32 (say 64x64) the buffer is too small to decode it. LVGL also stores it in a 32bit per pixel format, so 16kb is needed just to store the uncompressed image. Which we don't have on some of the larger displays (specifically the 3.5" model, the framebuffer needs to live in ram for that and takes up a large amount of space)
Most certainly not, but its a start. I wish to only scale linearly if possible. |
OK, now I got your point.. Not played much with LVGL, but is it true also for greyscale images? Maybe we can discard the color / alpha information from the PNG to reduce this overhead? |
"The whole PNG image is decoded so during decoding RAM equals to image width x image height x 4 bytes are required." I wish :( |
And here the helper app can help... We can supply the display a prepared and lightweight image (maybe in some custom format) What I mean: if we do not care about colours, we can just supply a bitmap matrix. Anyway, this thumbnail will not be animated or transformed any further - it should be statically present on the single "Printing" panel at specific position |
But with a helper tool it won't work for wifi, and it's extra setup i wish to avoid at all costs |
here are some suggestions from ChatGPT: Optimizing PNG Decoding on ESP32 S3 with LVGLIf you're facing memory constraints on an ESP32 S3 when decoding and displaying PNG images using LVGL, here are several strategies to optimize and resolve the issue. This is particularly relevant for projects like CYD Klipper where memory is very limited (~100kB free). Problem DescriptionThe key challenges include:
Goal: Decode a PNG thumbnail (32x32, received from the printer) and display it on a higher-resolution screen with minimal memory usage. Solutions1. Reduce Color DepthLower the image storage format from 32 bits per pixel to 16 or 8 bits:
LVGL Configuration: #define LV_COLOR_DEPTH 16 // Or 8 for Indexed 8-bit 2. Decode PNG IncrementallyUse partial decoding to reduce memory usage:
Example (Pseudo-code): uint8_t line_buffer[DISPLAY_WIDTH * LV_COLOR_DEPTH / 8]; // Buffer for a single line
for (int y = 0; y < image_height; y++) {
decode_png_line(png_data, line_buffer, y);
draw_line_on_display(x, y, line_buffer);
} 3. Use JPEG Instead of PNGIf PNG is too memory-intensive, consider converting thumbnails on the printer side to JPEG or BMP:
On the Printer (Klipper): from PIL import Image
img = Image.open("thumbnail.png")
img.save("thumbnail.jpg", "JPEG", quality=85) 4. Upscale Low-Resolution ImagesIf the thumbnail remains small (32x32), use LVGL’s built-in scaling to display it at a higher resolution:
lv_img_set_zoom(img, scale_factor); For example, to upscale 32x32 to 128x128, use 5. Leverage PSRAMIf your ESP32 S3 includes external PSRAM:
#define CONFIG_SPIRAM_USE_CAPS_ALLOC 1
#define CONFIG_SPIRAM_SUPPORT 1
#define LV_MEM_ADR (void *)0x3F800000 // PSRAM address
#define LV_MEM_SIZE (8 * 1024 * 1024) // Size of PSRAM 6. Preconvert Images on the PrinterIf decoding PNGs is too complex, convert the image to a simpler format (e.g., RAW RGB565) on the printer side:
img = Image.open("thumbnail.png").convert("RGB").resize((128, 128))
img.save("thumbnail.raw", format="RAW")
SummaryTo optimize PNG decoding on ESP32 S3 for CYD Klipper:
Let me know if you need code examples or deeper integration tips! |
for me PSRAM and reducing color depth are the most promising solutions... |
Digging through the code I was surprised to discover there is Gcode thumbnail support of some kind.
I would expect seeing Gcode file thumbnail while printing, but I don't see anything like that on the Files Panel as well.
How exactly it should look like? Maybe you could share an example screenshot please?
The text was updated successfully, but these errors were encountered: