Skip to content

Commit de42d40

Browse files
Added new cameras
1 parent 7ec2b40 commit de42d40

File tree

1 file changed

+21
-10
lines changed
  • content/hardware/10.mega/shields/giga-display-shield/tutorials/camera-tutorial

1 file changed

+21
-10
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ 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
17+
- HM01B0, HM0360, GC2145 or OV7675 camera
1818
- [Arducam_dvp library](https://www.arduino.cc/reference/en/libraries/arducam_dvp/)
1919

2020
## Downloading the Library and Core
@@ -29,6 +29,8 @@ The GIGA Display Shield is compatible with the following cameras:
2929

3030
- [HM01B0](https://www.arducam.com/product/hm01b0-qvga-monochrome-dvp-camera-module-for-arduino-giga-r1-wifi-board/)
3131
- [HM0360](https://www.arducam.com/product/hm0360-vga-monochrome-dvp-camera-module-for-arduino-giga-r1-wifi-board/)
32+
- [GC2145]
33+
- [OV7675]
3234

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

@@ -67,13 +69,11 @@ Camera cam(himax);
6769
OV7675 ov767x;
6870
Camera cam(ov767x);
6971
#define IMAGE_MODE CAMERA_RGB565
70-
#error "Unsupported camera (at the moment :) )"
7172
#elif defined(ARDUCAM_CAMERA_GC2145)
7273
#include "GC2145/gc2145.h"
7374
GC2145 galaxyCore;
7475
Camera cam(galaxyCore);
7576
#define IMAGE_MODE CAMERA_RGB565
76-
#error "Unsupported camera (at the moment :) )"
7777
#endif
7878
7979
// The buffer used to capture the frame
@@ -108,9 +108,11 @@ void setup() {
108108
}
109109
110110
Display.begin();
111-
dsi_configueCLUT((uint32_t*)palette);
112111
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));
114116
115117
// clear the display (gives a nice black background)
116118
dsi_lcdClear(0);
@@ -119,6 +121,8 @@ void setup() {
119121
dsi_drawCurrentFrameBuffer();
120122
}
121123
124+
#define HTONS(x) (((x >> 8) & 0x00FF) | ((x << 8) & 0xFF00))
125+
122126
void loop() {
123127
124128
// Grab frame and write to another framebuffer
@@ -128,13 +132,20 @@ void loop() {
128132
// this only works if the camera feed is 320x240 and the area where we want to display is 640x480
129133
for (int i = 0; i < 320; i++) {
130134
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+
}
135146
}
136147
}
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);
138149
dsi_drawCurrentFrameBuffer();
139150
} else {
140151
blinkLED(20);

0 commit comments

Comments
 (0)