![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
testing n-Bed with a Logitech C270 camera
Fork of USBHostC270_example by
Diff: main.cpp
- Revision:
- 11:6a8eef89eb22
- Parent:
- 10:387c49b2fc7e
- Child:
- 13:237a886b0b78
--- 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(); + } } }