Description.

Dependencies:   Camera_LS_Y201 FatFileSystemSD Motor SDFileSystem Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
lndv3
Date:
Fri Oct 12 16:44:04 2012 +0000
Commit message:
Commit.

Changed in this revision

Camera_LS_Y201.lib Show annotated file Show diff for this revision Revisions of this file
FatFileSystemSD.lib Show annotated file Show diff for this revision Revisions of this file
Motor.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
Servo.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c425cf9d5096 Camera_LS_Y201.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Camera_LS_Y201.lib	Fri Oct 12 16:44:04 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/lndv3/code/Camera_LS_Y201/#e92ce527b8b0
diff -r 000000000000 -r c425cf9d5096 FatFileSystemSD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FatFileSystemSD.lib	Fri Oct 12 16:44:04 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/carlos_nascimento08/code/FatFileSystemSD/#6ce49c16703c
diff -r 000000000000 -r c425cf9d5096 Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Fri Oct 12 16:44:04 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r c425cf9d5096 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Fri Oct 12 16:44:04 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/lndv3/code/SDFileSystem/#97e0c0200e51
diff -r 000000000000 -r c425cf9d5096 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Fri Oct 12 16:44:04 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/lndv3/code/Servo/#2176f8595b34
diff -r 000000000000 -r c425cf9d5096 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 12 16:44:04 2012 +0000
@@ -0,0 +1,134 @@
+#include "mbed.h"
+#include "Servo.h"
+#include "Camera_LS_Y201.h"
+#include "SDFileSystem.h"
+#include "Motor.h"
+
+#define USE_SDCARD 1
+
+#if USE_SDCARD
+#define FILENAME    "/sd/IMG_%04d.jpg"
+SDFileSystem fs(p5, p6, p7, p8, "sd");
+#else
+#define FILENAME    "/local/IMG_%04d.jpg"
+LocalFileSystem fs("local");
+#endif
+
+Camera_LS_Y201 cam1(p13, p14);
+
+typedef struct work {
+    FILE *fp;
+} work_t;
+
+work_t work;
+
+void callback_func(int done, int total, uint8_t *buf, size_t siz)
+{
+    fwrite(buf, siz, 1, work.fp);
+
+    static int n = 0;
+    int tmp = done * 100 / total;
+    if (n != tmp) {
+        n = tmp;
+    }
+}
+
+int capture(Camera_LS_Y201 *cam, char *filename)
+{
+    
+    if (cam->takePicture() != 0) {
+        return -1;
+    }
+    
+    work.fp = fopen(filename, "wb");
+    if (work.fp == NULL) {
+        return -2;
+    }
+    
+    if (cam->readJpegFileContent(callback_func) != 0) {
+        fclose(work.fp);
+        return -3;
+    }
+    fclose(work.fp);
+
+    cam->stopTakingPictures();
+
+    return 0;
+}
+
+Motor M_A(p25, p27, p28);    // pwm, fwd, rev
+Motor M_B(p26, p29, p30);    // pwm, fwd, rev
+
+Servo servo_01(p23);
+Servo servo_02(p24);
+
+int main()
+{
+    int cnt = 0;
+
+    int n = 3;
+    int m = 3;
+
+    float range = 0.0009;
+    float degrees = 90.0;
+    float init_pos_01 = -90.0;
+    float init_pos_02 = 30.0;
+    
+    cam1.reset();
+    cam1.setImageSize(Camera_LS_Y201::ImageSize160x120);
+
+    servo_01.calibrate(range,degrees);
+    servo_02.calibrate(range,degrees);
+    
+    char fname[64];
+    int r;
+    
+    for(int kk=0; kk<=1; kk++) {
+        
+        for(int i=0; i<=n; i++) {
+
+            servo_01.position(init_pos_01 + ((2*degrees)*i/n));
+
+            for(int j=0; j<m; j++) {
+                
+                if(i%2==0) {
+                    servo_02.position((j*(degrees/m)) + init_pos_02);
+                } else {
+                    servo_02.position((m-j-1)*(degrees/m) + init_pos_02);
+                }
+                
+                // A wait to make certain the servos have moved into place.
+                wait(0.75);
+               
+                snprintf(fname, sizeof(fname) - 1, FILENAME, cnt);
+                r = capture(&cam1, fname);
+                
+                // Only move to the next position if the write is successful.
+                if(r == 0) {
+                    cnt++;
+                }
+                else {
+                    j--;
+                }
+                
+            }
+
+        }
+
+        if (kk==0) {
+            M_A.speed(0.5);
+            M_B.speed(-0.5);
+            wait(1.525);
+            M_A.speed(0.0);
+            M_B.speed(0.0);
+            wait(0.5);
+            M_A.speed(-0.5);
+            M_B.speed(-0.5);
+            wait(0.775);
+            M_A.speed(0.0);
+            M_B.speed(0.0);
+        }
+
+    }
+    
+}
\ No newline at end of file
diff -r 000000000000 -r c425cf9d5096 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 12 16:44:04 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc
\ No newline at end of file