Skip to content

Commit 21b1e60

Browse files
facchinmpennam
authored andcommitted
Giga: add display examples
1 parent 70c3d04 commit 21b1e60

File tree

13 files changed

+12250
-0
lines changed

13 files changed

+12250
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#include "camera.h"
2+
#include "Portenta_lvgl.h"
3+
#include "Portenta_Video.h"
4+
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"
12+
HM01B0 himax;
13+
Camera cam(himax);
14+
#define IMAGE_MODE CAMERA_GRAYSCALE
15+
#endif
16+
17+
/*
18+
Other buffer instantiation options:
19+
FrameBuffer fb(0x30000000);
20+
FrameBuffer fb(320,240,2);
21+
*/
22+
FrameBuffer fb;
23+
24+
unsigned long lastUpdate = 0;
25+
26+
27+
void blinkLED(uint32_t count = 0xFFFFFFFF)
28+
{
29+
pinMode(LED_BUILTIN, OUTPUT);
30+
while (count--) {
31+
digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the voltage level)
32+
delay(50); // wait for a second
33+
digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the voltage LOW
34+
delay(50); // wait for a second
35+
}
36+
}
37+
void LCD_ST7701_Init();
38+
39+
uint32_t palette[256];
40+
41+
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+
// Init the cam QVGA, 30FPS
49+
if (!cam.begin(CAMERA_R320x240, IMAGE_MODE, 30)) {
50+
blinkLED();
51+
}
52+
53+
for (int i = 0; i < 256; i++) {
54+
palette[i] = 0xFF000000 | (i << 16) | (i << 8) | i;
55+
}
56+
57+
giga_init_video();
58+
LCD_ST7701_Init();
59+
60+
blinkLED(5);
61+
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);
67+
}
68+
69+
#include "avir.h"
70+
71+
void loop() {
72+
73+
lastUpdate = millis();
74+
75+
// Grab frame and write to serial
76+
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++) {
82+
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+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
86+
((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
93+
}
94+
}
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);
98+
} else {
99+
blinkLED(20);
100+
}
101+
}

0 commit comments

Comments
 (0)