@@ -14,7 +14,7 @@ The GIGA Display Shield comes with an Arducam camera connector. In this tutorial
14
14
- [ Arduino GIGA R1 WiFi] ( /hardware/giga-r1 )
15
15
- [ Arduino GIGA Display Shield] ( )
16
16
- [ Arduino IDE] ( https://www.arduino.cc/en/software )
17
- - HM01B0 or HM0360 camera
17
+ - HM01B0, HM0360, GC2145 or OV7675 camera
18
18
- [ Arducam_dvp library] ( https://www.arduino.cc/reference/en/libraries/arducam_dvp/ )
19
19
20
20
## Downloading the Library and Core
@@ -29,6 +29,8 @@ The GIGA Display Shield is compatible with the following cameras:
29
29
30
30
- [ HM01B0] ( https://www.arducam.com/product/hm01b0-qvga-monochrome-dvp-camera-module-for-arduino-giga-r1-wifi-board/ )
31
31
- [ HM0360] ( https://www.arducam.com/product/hm0360-vga-monochrome-dvp-camera-module-for-arduino-giga-r1-wifi-board/ )
32
+ - [ GC2145]
33
+ - [ OV7675]
32
34
33
35
Connect the camera to the connector on the front of the display shield as shown in the image below.
34
36
@@ -67,13 +69,11 @@ Camera cam(himax);
67
69
OV7675 ov767x;
68
70
Camera cam(ov767x);
69
71
#define IMAGE_MODE CAMERA_RGB565
70
- #error "Unsupported camera (at the moment :) )"
71
72
#elif defined(ARDUCAM_CAMERA_GC2145)
72
73
#include "GC2145/gc2145.h"
73
74
GC2145 galaxyCore;
74
75
Camera cam(galaxyCore);
75
76
#define IMAGE_MODE CAMERA_RGB565
76
- #error "Unsupported camera (at the moment :) )"
77
77
#endif
78
78
79
79
// The buffer used to capture the frame
@@ -108,9 +108,11 @@ void setup() {
108
108
}
109
109
110
110
Display.begin();
111
- dsi_configueCLUT((uint32_t*)palette);
112
111
113
- outfb.setBuffer((uint8_t*)SDRAM.malloc(1024*1024));
112
+ if (IMAGE_MODE == CAMERA_GRAYSCALE) {
113
+ dsi_configueCLUT((uint32_t*)palette);
114
+ }
115
+ outfb.setBuffer((uint8_t*)SDRAM.malloc(1024 * 1024));
114
116
115
117
// clear the display (gives a nice black background)
116
118
dsi_lcdClear(0);
@@ -119,6 +121,8 @@ void setup() {
119
121
dsi_drawCurrentFrameBuffer();
120
122
}
121
123
124
+ #define HTONS(x) (((x >> 8) & 0x00FF) | ((x << 8) & 0xFF00))
125
+
122
126
void loop() {
123
127
124
128
// Grab frame and write to another framebuffer
@@ -128,13 +132,20 @@ void loop() {
128
132
// this only works if the camera feed is 320x240 and the area where we want to display is 640x480
129
133
for (int i = 0; i < 320; i++) {
130
134
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];
135
+ if (IMAGE_MODE == CAMERA_GRAYSCALE) {
136
+ ((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
137
+ ((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
138
+ ((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
139
+ ((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
140
+ } else {
141
+ ((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
142
+ ((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480 + 1] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
143
+ ((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
144
+ ((uint16_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480 + 1] = HTONS(((uint16_t*)fb.getBuffer())[i + j * 320]);
145
+ }
135
146
}
136
147
}
137
- dsi_lcdDrawImage((void*)outfb.getBuffer(), (void*)dsi_getCurrentFrameBuffer(), 480, 640, DMA2D_INPUT_L8);
148
+ dsi_lcdDrawImage((void*)outfb.getBuffer(), (void*)dsi_getCurrentFrameBuffer(), 480, 640, IMAGE_MODE == CAMERA_GRAYSCALE ? DMA2D_INPUT_L8 : DMA2D_INPUT_RGB565 );
138
149
dsi_drawCurrentFrameBuffer();
139
150
} else {
140
151
blinkLED(20);
0 commit comments