Skip to content

Commit 27cba45

Browse files
authored
Merge pull request #2696 from adafruit/memento_arduino_basic
Adding basic camera example for Arduino
2 parents 2614d98 + d7a1005 commit 27cba45

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

MEMENTO/Arduino_Basic_Camera/.pycamera_s3.test.only

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

0 commit comments

Comments
 (0)