You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: 'Learn to display RAW Images on the GIGA Display from USB Storage.'
4
4
author: Pedro Sousa Lima
5
5
tags: [Display, USB]
@@ -33,24 +33,29 @@ This guide explores how to read and display raw RGB565 images from a USB drive o
33
33
## Preparing Your Image
34
34
35
35
To ensure your image is in the correct format (800x480, 16-bit RGB565), you can use an online converter such as the [**LVGL Image Converter**](https://lvgl.io/tools/imageconverter). Select **RGB565** as the output format and set the resolution to 800x480 before saving the file to your USB drive. Make sure the USB drive is formatted for FAT32.
36
+
For testing we used the image:
37
+

38
+
39
+
For image convertion we selected the following settings:
With the following code the USB host is initialized, enabling support for mass storage devices. The display is also set up using the `Arduino_H7_Video` class.
Once mounted, the USB drive is scanned for available files:
56
+
Once mounted, the USB drive is scanned for available files. Again, make sure the USB is in FAT32 format:
52
57
53
-
```cpp
58
+
```arduino
54
59
void listRootDirectory() {
55
60
fileCount = 0;
56
61
DIR* dir = opendir("/usb/");
@@ -69,7 +74,7 @@ void listRootDirectory() {
69
74
70
75
Users can enter a file number in the Serial Monitor to select an image for display.
71
76
72
-
```cpp
77
+
```arduino
73
78
void handleUserInput() {
74
79
if (Serial.available() > 0) {
75
80
int sel = Serial.parseInt();
@@ -84,12 +89,11 @@ void handleUserInput() {
84
89
85
90
### Reading and Displaying RAW Images
86
91
87
-
The file is read row-by-row (800 pixels per row, 2 bytes per pixel). If the entire image (800x480 pixels) were loaded into memory at once, it would require approximately 768 KB of RAM (800 \* 480 \* 2 bytes). However, by processing only one row at a time (800 * 2 bytes), the memory usage is reduced to just `1.6 KB`, making this approach much more efficient and feasible for devices with restricted memory (like GIGA). This approach minimizes memory usage by processing smaller chunks of the image at one time, avoiding large allocations that may exceed available RAM (512 KB for the GIGA).
88
-
To manage this efficiently, we use `malloc()` and `free()` for dynamic memory allocation, ensuring that only the necessary amount of RAM is used rather than pre-allocating a large buffer. This approach helps optimize memory use while preventing fragmentation.
89
-
Similarly, `fopen()` and `fclose()` are used for file management. `fopen()` allows us to open the image file and read data as needed, rather than loading everything at once. `fclose()` ensures that the file is properly closed after reading, freeing up system resources and preventing potential memory leaks.
92
+
The file is read row-by-row (800 pixels per row, 2 bytes per pixel). If the entire image (800x480 pixels) were loaded into memory at once, it would require approximately 768 KB of RAM (800 \* 480 \* 2 bytes). However, by processing only one row at a time (800 * 2 bytes), the memory usage is reduced to just `1.6 KB`, making this approach much more efficient and feasible for devices with restricted memory (like the GIGA). This approach minimizes memory usage by processing smaller chunks of the image at one time, avoiding large allocations that may exceed available RAM (512 KB for the GIGA).
93
+
We use, `fopen()` and `fclose()` are used for file management. `fopen()` allows us to open the image file and read data as needed, rather than loading everything at once. `fclose()` ensures that the file is properly closed after reading, freeing up system resources and preventing potential memory leaks.
This project demonstrates how to read and display **16-bit RGB565 images** from a USB drive onto the Arduino GIGA Display Shield. The row-by-row approach optimizes memory usage while ensuring smooth rendering. This technique is useful for **digital signage, interactive kiosks, and embedded GUI projects**.
275
+
This project demonstrates how to read and display **16-bit RGB565 images** from a USB drive onto the Arduino GIGA Display. The row-by-row approach optimizes memory usage while ensuring smooth rendering.
0 commit comments