Skip to content

Commit 82fdec8

Browse files
Merge pull request #525 from arduino/benjamindannegard/display-shield-camera-update
[GIGA Display Shield] Camera tutorial update
2 parents c5f0a7d + d7b87a1 commit 82fdec8

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

content/hardware/10.mega/shields/giga-display-shield/product.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: GIGA Display Shield
33
url_shop: https://store.arduino.cc/
4-
url_guide: /tutorials/basic-draw
4+
url_guide: /tutorials/getting-started
55
core: arduino:mbed_giga
66
---
77

content/hardware/10.mega/shields/giga-display-shield/tutorials/camera-tutorial/content.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ The GIGA Display Shield comes with an Arducam camera connector. In this tutorial
1414
- [Arduino GIGA R1 WiFi](/hardware/giga-r1)
1515
- [Arduino GIGA Display Shield]()
1616
- [Arduino IDE](https://www.arduino.cc/en/software)
17-
- HM01B0 or HM0360 camera
18-
- [Arducam_dvp library](https://www.arduino.cc/reference/en/libraries/arducam_dvp/)
17+
- HM01B0, HM0360, GC2145 or OV7675 camera
1918

2019
## Downloading the Library and Core
2120

22-
The Arduino Mbed OS Giga Boards core contains most of the libraries you need to work with the shield's camera connector. To install the core for GIGA boards, navigate to **Tools > Board > Boards Manager** or click the Boards Manager icon in the left tab of the IDE. In the Boards Manager tab, search for giga and install the latest Arduino Mbed OS Giga Boards version, the [Arduino_H7_Video library](https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/Arduino_H7_Video) library is included in the core. Now open the library tab on the left, search for **Arducam_dvp**, and install this library.
21+
The Arduino Mbed OS Giga Boards core contains most of the libraries you need to work with the shield's camera connector. To install the core for GIGA boards, navigate to **Tools > Board > Boards Manager** or click the Boards Manager icon in the left tab of the IDE. In the Boards Manager tab, search for giga and install the latest Arduino Mbed OS Giga Boards version, the [Arduino_H7_Video library](https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/Arduino_H7_Video) library is included in the core. Now open the library tab on the left, search for [**Arducam_dvp**](https://www.arduino.cc/reference/en/libraries/arducam_dvp/), and install this library.
2322

2423
![Library tab in the Arduino IDE](assets/ide-library.svg)
2524

@@ -29,6 +28,8 @@ The GIGA Display Shield is compatible with the following cameras:
2928

3029
- [HM01B0](https://www.arducam.com/product/hm01b0-qvga-monochrome-dvp-camera-module-for-arduino-giga-r1-wifi-board/)
3130
- [HM0360](https://www.arducam.com/product/hm0360-vga-monochrome-dvp-camera-module-for-arduino-giga-r1-wifi-board/)
31+
- [GC2145](https://www.arducam.com/product/2mp-gc2145-color-dvp-camera-module-for-arduino-giga-r1-wifi-board/)
32+
- [OV7675](https://store.arduino.cc/products/arducam-camera-module?queryID=undefined)
3233

3334
Connect the camera to the connector on the front of the display shield as shown in the image below.
3435

@@ -67,13 +68,11 @@ Camera cam(himax);
6768
OV7675 ov767x;
6869
Camera cam(ov767x);
6970
#define IMAGE_MODE CAMERA_RGB565
70-
#error "Unsupported camera (at the moment :) )"
7171
#elif defined(ARDUCAM_CAMERA_GC2145)
7272
#include "GC2145/gc2145.h"
7373
GC2145 galaxyCore;
7474
Camera cam(galaxyCore);
7575
#define IMAGE_MODE CAMERA_RGB565
76-
#error "Unsupported camera (at the moment :) )"
7776
#endif
7877
7978
// The buffer used to capture the frame
@@ -108,9 +107,11 @@ void setup() {
108107
}
109108
110109
Display.begin();
111-
dsi_configueCLUT((uint32_t*)palette);
112110
113-
outfb.setBuffer((uint8_t*)SDRAM.malloc(1024*1024));
111+
if (IMAGE_MODE == CAMERA_GRAYSCALE) {
112+
dsi_configueCLUT((uint32_t*)palette);
113+
}
114+
outfb.setBuffer((uint8_t*)SDRAM.malloc(1024 * 1024));
114115
115116
// clear the display (gives a nice black background)
116117
dsi_lcdClear(0);
@@ -119,6 +120,8 @@ void setup() {
119120
dsi_drawCurrentFrameBuffer();
120121
}
121122
123+
#define HTONS(x) (((x >> 8) & 0x00FF) | ((x << 8) & 0xFF00))
124+
122125
void loop() {
123126
124127
// Grab frame and write to another framebuffer
@@ -128,13 +131,20 @@ void loop() {
128131
// this only works if the camera feed is 320x240 and the area where we want to display is 640x480
129132
for (int i = 0; i < 320; i++) {
130133
for (int j = 0; j < 240; j++) {
131-
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
132-
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
133-
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
134-
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
134+
if (IMAGE_MODE == CAMERA_GRAYSCALE) {
135+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
136+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
137+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
138+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
139+
} else {
140+
((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
141+
((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480 + 1] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
142+
((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
143+
((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480 + 1] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
144+
}
135145
}
136146
}
137-
dsi_lcdDrawImage((void*)outfb.getBuffer(), (void*)dsi_getCurrentFrameBuffer(), 480, 640, DMA2D_INPUT_L8);
147+
dsi_lcdDrawImage((void*)outfb.getBuffer(), (void*)dsi_getCurrentFrameBuffer(), 480, 640, IMAGE_MODE == CAMERA_GRAYSCALE ? DMA2D_INPUT_L8 : DMA2D_INPUT_RGB565);
138148
dsi_drawCurrentFrameBuffer();
139149
} else {
140150
blinkLED(20);
@@ -145,4 +155,3 @@ void loop() {
145155
## Conclusion
146156

147157
This tutorial went through how to connect a compatible camera to the shield and also how to test it out quickly with the example sketch included in the core. Now you should see a live feed from the camera on your GIGA Display Shield!
148-

0 commit comments

Comments
 (0)