modify for C210 webcam and Startboard Orange.

Dependencies:   TextLCD USBHost mbed

Fork of USBHostC270_example by Norimasa Okamoto

Norimasa Okamoto さんの http://mbed.org/users/va009039/code/USBHostC270_example/ を C210 webcam と StarBoard Orange での SD カード保存用に変更。

Revision:
11:944c66b16508
Parent:
10:387c49b2fc7e
Child:
12:c827ed52021d
--- a/main.cpp	Sun Mar 17 13:22:13 2013 +0000
+++ b/main.cpp	Tue Mar 19 12:21:08 2013 +0000
@@ -1,13 +1,15 @@
-#include "USBHostMSD.h"
+// #include "USBHostMSD.h"
 #include "USBHostC270.h"
+#include "SDFileSystem.h"
 
 Serial pc(USBTX, USBRX);
 BusOut leds(LED1, LED2, LED3);
+SDFileSystem  sd(p5, p6, p7, p8,  "sd");
 
 int main() {
     pc.baud(921600);
 
-    USBHostMSD* msd = new USBHostMSD("usb"); // USB flash drive
+    // USBHostMSD* msd = new USBHostMSD("usb"); // USB flash drive
 
     USBHostC270* cam = new USBHostC270(C270_MJPEG, C270_160x120, _5FPS); // Logitech C270
     while(!cam->connect()) {
@@ -20,14 +22,18 @@
     interval_t.start();
     int shot = 0;
     while(1) {
-        if (interval_t.read() > 10) {
+        if (interval_t.read_ms() > 2000) {
+            printf("start\r\n");
             int r = cam->readJPEG(buf, sizeof(buf));
             char path[32];
-            snprintf(path, sizeof(path), "/usb/image%02d.jpg", shot % 20);
-            printf("%d %s %d bytes\n", shot, path, r);
-            if (msd->connected()) {
+            // snprintf(path, sizeof(path), "/usb/image%02d.jpg", shot % 20);
+            snprintf(path, sizeof(path), "/sd/image%02d.jpg", shot % 20);
+            printf("%d %s %d bytes\r\n", shot, path, r);
+            // if (msd->connected()) 
+            {
                 FILE* fp = fopen(path, "wb");
                 if (fp) {
+                    printf("write\r\n");
                     fwrite(buf, r, 1, fp);
                     fclose(fp);
                 }
@@ -35,10 +41,9 @@
                 leds = shot % 8;
             }
             interval_t.reset();
+            printf("end\r\n");
         }
-        if (!msd->connected()) {
-            msd->connect();
-        }
+        // if (!msd->connected()) msd->connect();
         cam->poll();    
     }
 }