Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBHost_custom_Addiso
Fork of USBHostC270_example_GR-PEACH by
Diff: main.cpp
- Revision:
- 11:6a8eef89eb22
- Parent:
- 10:387c49b2fc7e
- Child:
- 13:fa85d3614acf
diff -r 387c49b2fc7e -r 6a8eef89eb22 main.cpp
--- a/main.cpp Sun Mar 17 13:22:13 2013 +0000
+++ b/main.cpp Mon Mar 18 12:34:47 2013 +0000
@@ -8,11 +8,7 @@
pc.baud(921600);
USBHostMSD* msd = new USBHostMSD("usb"); // USB flash drive
-
USBHostC270* cam = new USBHostC270(C270_MJPEG, C270_160x120, _5FPS); // Logitech C270
- while(!cam->connect()) {
- Thread::wait(500);
- }
uint8_t buf[1024*3];
Timer interval_t;
@@ -20,7 +16,7 @@
interval_t.start();
int shot = 0;
while(1) {
- if (interval_t.read() > 10) {
+ if (interval_t.read() > 10 && cam->connected()) {
int r = cam->readJPEG(buf, sizeof(buf));
char path[32];
snprintf(path, sizeof(path), "/usb/image%02d.jpg", shot % 20);
@@ -38,7 +34,13 @@
}
if (!msd->connected()) {
msd->connect();
+ Thread::wait(500);
}
- cam->poll();
+ if (!cam->connected()) {
+ cam->connect();
+ Thread::wait(500);
+ } else {
+ cam->poll();
+ }
}
}
