1
- #include " camera.h"
2
- #include " Portenta_lvgl.h"
3
- #include " Portenta_Video.h"
1
+ #include " arducam_dvp.h"
2
+ #include " Arduino_H7_Video.h"
3
+ #include " dsi.h"
4
+ #include " SDRAM.h"
4
5
5
- #if 0
6
- #include "gc2145.h"
7
- GC2145 galaxyCore;
8
- Camera cam(galaxyCore);
9
- #define IMAGE_MODE CAMERA_RGB565
10
- #else
11
- #include " himax.h"
6
+ // This example only works with Greyscale cameras (due to the palette + resize&rotate algo)
7
+ #define ARDUCAM_CAMERA_HM01B0
8
+
9
+ #ifdef ARDUCAM_CAMERA_HM01B0
10
+ #include " Himax_HM01B0/himax.h"
12
11
HM01B0 himax;
13
12
Camera cam (himax);
14
13
#define IMAGE_MODE CAMERA_GRAYSCALE
14
+ #elif defined(ARDUCAM_CAMERA_HM0360)
15
+ #include " Himax_HM0360/hm0360.h"
16
+ HM0360 himax;
17
+ Camera cam (himax);
18
+ #define IMAGE_MODE CAMERA_GRAYSCALE
19
+ #elif defined(ARDUCAM_CAMERA_OV767X)
20
+ #include " OV7670/ov767x.h"
21
+ // OV7670 ov767x;
22
+ OV7675 ov767x;
23
+ Camera cam (ov767x);
24
+ #define IMAGE_MODE CAMERA_RGB565
25
+ #error "Unsupported camera (at the moment :) )"
26
+ #elif defined(ARDUCAM_CAMERA_GC2145)
27
+ #include " GC2145/gc2145.h"
28
+ GC2145 galaxyCore;
29
+ Camera cam (galaxyCore);
30
+ #define IMAGE_MODE CAMERA_RGB565
31
+ #error "Unsupported camera (at the moment :) )"
15
32
#endif
16
33
17
- /*
18
- Other buffer instantiation options:
19
- FrameBuffer fb(0x30000000);
20
- FrameBuffer fb(320,240,2);
21
- */
34
+ // The buffer used to capture the frame
22
35
FrameBuffer fb;
23
-
24
- unsigned long lastUpdate = 0 ;
25
-
36
+ // The buffer used to rotate and resize the frame
37
+ FrameBuffer outfb;
38
+ // The buffer used to rotate and resize the frame
39
+ Arduino_H7_Video Display (800 , 480 , GigaDisplayShield);
26
40
27
41
void blinkLED (uint32_t count = 0xFFFFFFFF )
28
42
{
@@ -34,68 +48,50 @@ void blinkLED(uint32_t count = 0xFFFFFFFF)
34
48
delay (50 ); // wait for a second
35
49
}
36
50
}
37
- void LCD_ST7701_Init ();
38
51
39
52
uint32_t palette[256 ];
40
53
41
54
void setup () {
42
- pinMode (PA_1, OUTPUT);
43
- digitalWrite (PA_1, HIGH);
44
-
45
- pinMode (PD_4, OUTPUT);
46
- digitalWrite (PD_4, LOW);
47
-
48
55
// Init the cam QVGA, 30FPS
49
56
if (!cam.begin (CAMERA_R320x240, IMAGE_MODE, 30 )) {
50
57
blinkLED ();
51
58
}
52
59
60
+ // Setup the palette to convert 8 bit greyscale to 32bit greyscale
53
61
for (int i = 0 ; i < 256 ; i++) {
54
62
palette[i] = 0xFF000000 | (i << 16 ) | (i << 8 ) | i;
55
63
}
56
64
57
- giga_init_video ();
58
- LCD_ST7701_Init ( );
65
+ Display. begin ();
66
+ dsi_configueCLUT (( uint32_t *)palette );
59
67
60
- blinkLED ( 5 );
68
+ outfb. setBuffer (( uint8_t *)SDRAM. malloc ( 1024 * 1024 ) );
61
69
62
- stm32_configue_CLUT (( uint32_t *)palette);
63
- stm32_LCD_Clear (0 );
64
- stm32_LCD_Clear ( 0 );
65
- stm32_LCD_Clear (0 );
66
- stm32_LCD_Clear ( 0 );
70
+ // clear the display (gives a nice black background)
71
+ dsi_lcdClear (0 );
72
+ dsi_drawCurrentFrameBuffer ( );
73
+ dsi_lcdClear (0 );
74
+ dsi_drawCurrentFrameBuffer ( );
67
75
}
68
76
69
- #include " avir.h"
70
-
71
77
void loop () {
72
78
73
- lastUpdate = millis ();
74
-
75
- // Grab frame and write to serial
79
+ // Grab frame and write to another framebuffer
76
80
if (cam.grabFrame (fb, 3000 ) == 0 ) {
77
- // avir :: CImageResizer<> ImageResizer( 8 );
78
- // ImageResizer.resizeImage( (uint8_t*)fb.getBuffer(), 320, 240, 0, (uint8_t*)outfb.getBuffer(), 480, 320, 1, 0 );
79
- static FrameBuffer outfb (0x30000000 );
80
- // static FrameBuffer outfb(getFramebufferEnd());
81
- for (int i = 0 ; i < 300 ; i++) {
81
+
82
+ // double the resolution and transpose (rotate by 90 degrees) in the same step
83
+ // this only works if the camera feed is 320x240 and the area where we want to display is 640x480
84
+ for (int i = 0 ; i < 320 ; i++) {
82
85
for (int j = 0 ; j < 240 ; j++) {
83
- // ((uint8_t*)outfb.getBuffer())[j * 240 + (320 - i)] = ((uint8_t*)fb.getBuffer())[i * 320 + j];
84
- #if 1
85
86
((uint8_t *)outfb.getBuffer ())[j * 2 + (i * 2 ) * 480 ] = ((uint8_t *)fb.getBuffer ())[i + j * 320 ];
86
87
((uint8_t *)outfb.getBuffer ())[j * 2 + (i * 2 ) * 480 + 1 ] = ((uint8_t *)fb.getBuffer ())[i + j * 320 ];
87
- ((uint8_t *)outfb.getBuffer ())[j * 2 + (i*2 +1 ) * 480 ] = ((uint8_t *)fb.getBuffer ())[i + j * 320 ];
88
- ((uint8_t *)outfb.getBuffer ())[j * 2 + (i*2 +1 ) * 480 + 1 ] = ((uint8_t *)fb.getBuffer ())[i + j * 320 ];
89
- #endif
90
- #if 0
91
- ((uint8_t*)outfb.getBuffer())[j + i * 240] = ((uint8_t*)fb.getBuffer())[i + j * 320];
92
- #endif
88
+ ((uint8_t *)outfb.getBuffer ())[j * 2 + (i * 2 + 1 ) * 480 ] = ((uint8_t *)fb.getBuffer ())[i + j * 320 ];
89
+ ((uint8_t *)outfb.getBuffer ())[j * 2 + (i * 2 + 1 ) * 480 + 1 ] = ((uint8_t *)fb.getBuffer ())[i + j * 320 ];
93
90
}
94
91
}
95
- // stm32_LCD_DrawImage((void*)outfb.getBuffer(), (void*)getNextFrameBuffer(), 240, 320, DMA2D_INPUT_L8);
96
- stm32_LCD_DrawImage ((void *)outfb.getBuffer (), (void *)getNextFrameBuffer (), 480 , 640 , DMA2D_INPUT_L8);
97
- // stm32_LCD_DrawImage((void*)fb.getBuffer(), (void*)getNextFrameBuffer(), 320, 240, DMA2D_INPUT_L8);
92
+ dsi_lcdDrawImage ((void *)outfb.getBuffer (), (void *)dsi_getCurrentFrameBuffer (), 480 , 640 , DMA2D_INPUT_L8);
93
+ dsi_drawCurrentFrameBuffer ();
98
94
} else {
99
95
blinkLED (20 );
100
96
}
101
- }
97
+ }
0 commit comments