Skip to content

Commit 7ec2b40

Browse files
Merge pull request #519 from arduino/benjamindannegard/giga-display-shield-image-tutorial
GIGA display shield image tutorial
2 parents 37f8adc + 6f71898 commit 7ec2b40

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

content/hardware/10.mega/shields/giga-display-shield/tutorials/basic-draw/basic-draw.md renamed to content/hardware/10.mega/shields/giga-display-shield/tutorials/draw-and-image/content.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This is a great tutorial for getting started with your shield and exploring what
1818

1919
## Downloading the Library and Core
2020

21-
Make sure the latest GIGA Core is installed in the Arduino IDE. **Tools > Board > Board Manager...**. Here you need to look for the **Arduino Mbed OS Giga Boards** and install it. Now you have to install the library needed for the graphical display features. To do this, go to **Tools > Manage libraries..**, search for **ArduinoGraphics**, and install it.
21+
Make sure the latest GIGA Core is installed in the Arduino IDE. **Tools > Board > Board Manager...**. Here you need to look for the **Arduino Mbed OS Giga Boards** and install it, the [Arduino_H7_Video library](https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/Arduino_H7_Video) is included in the core. Now you have to install the library needed for the graphical display features. To do this, go to **Tools > Manage libraries..**, search for **ArduinoGraphics**, and install it.
2222

2323
## Using Draw Feature in a Sketch
2424

@@ -81,7 +81,7 @@ Now that the drawing is done the `Display.endDraw()` function can be called.
8181
}
8282
```
8383

84-
The complete code can be found as an example in the **Arduino_H7_video** library, it is called **ArduinoLogoDrawing**. Now upload the entire sketch and you should see the Arduino logo being drawn on the display.
84+
The complete code can be found as an example in the **Arduino_H7_video** library, it is called **ArduinoLogoDrawing**. The full sketch is also below. Now upload the entire sketch and you should see the Arduino logo being drawn on the display.
8585

8686
### Full Sketch
8787

@@ -119,12 +119,81 @@ void loop() { }
119119
120120
```
121121

122-
## Testing It Out
122+
### Testing It Out
123123

124124
Now that it is all uploaded your GIGA Display Shield should look like the image below:
125125

126126
![Sketch running on the GIGA Display Shield](assets/draw-on-shield.jpg)
127127

128+
## Displaying Images
129+
130+
Now let's have a look at how we can use the **ArduinoGraphics** library to display images on the GIGA Display Shield.
131+
132+
### Converting an Image
133+
134+
Using an online image converter you can pick any image you would like to be displayed on the display shield. However keep in mind the display is 480x800 in size. The format of the converted image needs to be Binary RGB565. Using an online image converter like the [LVGL image converter tool](https://lvgl.io/tools/imageconverter) will let you pick this as an option. Simply pick the "Binary RGB565" option under "Output format", your desired color format and hit "Convert". You will now have an image that is ready for use in an Arduino sketch.
135+
136+
### Displaying the Image on the Display
137+
138+
We will be using the example sketch "ArduinoLogo" as the basis for the sketch that lets us display an image. The example sketch can be found under **File->Examples->Arduino_H7_Video->ArduinoLogo**.
139+
140+
Running the example sketch as is will display the Arduino logo on the screen, like in the image below:
141+
142+
[Arduino Logo on the GIGA Display Shield]()
143+
144+
Now to use the image that we converted in the last step. Use the macro inside the example sketch. This makes use of the `incbin.h` translation library. The necessary files are located in the folder for the example sketch.
145+
146+
At the start of the sketch you can see these lines commented out:
147+
```arduino
148+
/*
149+
#define INCBIN_PREFIX
150+
#include "incbin.h"
151+
INCBIN(test, "/home/user/Downloads/test.bin");
152+
*/
153+
```
154+
155+
Uncomment these lines, and change the path to the image to the correct one. For Mac and Linux users the syntax of the path is correct as `"/home/user/Downloads/test.bin"`. For Windows users the path needs to be an absolute path, like this: `"C:\USERNAME\Downloads\test.bin"`. Now we need to change the `Image` variable to use our image.
156+
157+
By default the image we import will be called `test`. The line `Image img_arduinologo(ENCODING_RGB16, (uint8_t *) texture_raw, 300, 300);` needs to have one argument changed, `texture_raw` should now be `testData`. So the line should be `Image img_arduinologo(ENCODING_RGB16, (uint8_t *) testData, 300, 300);`.
158+
159+
160+
### Full Sketch
161+
162+
```arduino
163+
/*
164+
ArduinoLogo
165+
166+
created 17 Apr 2023
167+
by Leonardo Cavagnis
168+
*/
169+
170+
#include "Arduino_H7_Video.h"
171+
#include "ArduinoGraphics.h"
172+
173+
#include "img_arduinologo.h"
174+
// Alternatively, any raw RGB565 image can be included on demand using this macro
175+
// Online image converter: https://lvgl.io/tools/imageconverter (Output format: Binary RGB565)
176+
/*
177+
#define INCBIN_PREFIX
178+
#include "incbin.h"
179+
INCBIN(test, "/home/user/Downloads/test.bin");
180+
*/
181+
182+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
183+
//Arduino_H7_Video Display(1024, 768, USBCVideo);
184+
185+
Image img_arduinologo(ENCODING_RGB16, (uint8_t *) texture_raw, 300, 300);
186+
187+
void setup() {
188+
Display.begin();
189+
190+
Display.beginDraw();
191+
Display.image(img_arduinologo, (Display.width() - img_arduinologo.width())/2, (Display.height() - img_arduinologo.height())/2);
192+
Display.endDraw();
193+
}
194+
195+
void loop() { }
196+
```
128197

129198
## Conclusion
130199

0 commit comments

Comments
 (0)