Skip to content

Commit 9bd795b

Browse files
committed
Adding basic camera example for Arduino
1 parent 2614d98 commit 9bd795b

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

MEMENTO/Arduino_Basic_Camera/.pycamera_s3.test.only

Whitespace-only changes.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include "Adafruit_PyCamera.h"
2+
#include <Arduino.h>
3+
4+
Adafruit_PyCamera pycamera;
5+
framesize_t validSizes[] = {FRAMESIZE_QQVGA, FRAMESIZE_QVGA, FRAMESIZE_HVGA,
6+
FRAMESIZE_VGA, FRAMESIZE_SVGA, FRAMESIZE_XGA,
7+
FRAMESIZE_HD, FRAMESIZE_SXGA, FRAMESIZE_UXGA,
8+
FRAMESIZE_QXGA, FRAMESIZE_QSXGA};
9+
10+
void setup() {
11+
Serial.begin(115200);
12+
// while (!Serial) yield();
13+
// delay(1000);
14+
15+
// Serial.setDebugOutput(true);
16+
Serial.println("PyCamera Basic Example");
17+
if (!pycamera.begin()) {
18+
Serial.println("Failed to initialize PyCamera interface");
19+
while (1)
20+
yield();
21+
}
22+
Serial.println("PyCamera hardware initialized!");
23+
24+
pycamera.photoSize = FRAMESIZE_SVGA;
25+
}
26+
27+
void loop() {
28+
29+
pycamera.readButtons();
30+
// Serial.printf("Buttons: 0x%08X\n\r", pycamera.readButtons());
31+
32+
// pycamera.timestamp();
33+
pycamera.captureFrame();
34+
35+
// once the frame is captured we can draw ontot he framebuffer
36+
if (pycamera.justPressed(AWEXP_SD_DET)) {
37+
Serial.println(F("SD Card removed"));
38+
pycamera.endSD();
39+
pycamera.fb->setCursor(0, 32);
40+
pycamera.fb->setTextSize(2);
41+
pycamera.fb->setTextColor(pycamera.color565(255, 0, 0));
42+
pycamera.fb->print(F("SD Card removed"));
43+
delay(200);
44+
}
45+
if (pycamera.justReleased(AWEXP_SD_DET)) {
46+
Serial.println(F("SD Card inserted!"));
47+
pycamera.initSD();
48+
pycamera.fb->setCursor(0, 32);
49+
pycamera.fb->setTextSize(2);
50+
pycamera.fb->setTextColor(pycamera.color565(255, 0, 0));
51+
pycamera.fb->print(F("SD Card inserted"));
52+
delay(200);
53+
}
54+
55+
pycamera.blitFrame();
56+
57+
if (pycamera.justPressed(SHUTTER_BUTTON)) {
58+
Serial.println("Snap!");
59+
if (pycamera.takePhoto("IMAGE", pycamera.photoSize)) {
60+
pycamera.fb->setCursor(120, 100);
61+
pycamera.fb->setTextSize(2);
62+
pycamera.fb->setTextColor(pycamera.color565(255, 255, 255));
63+
pycamera.fb->print("Snap!");
64+
pycamera.speaker_tone(100, 50); // tone1 - B5
65+
// pycamera.blitFrame();
66+
}
67+
}
68+
69+
delay(100);
70+
}

0 commit comments

Comments
 (0)