Camera program for buzz booth

Dependencies:   JPEGCamera mbed

Files at this revision

API Documentation at this revision

Comitter:
bfoley13
Date:
Tue Dec 08 00:41:58 2015 +0000
Commit message:
Camera for buzz booth

Changed in this revision

JPEGCamera.lib Show annotated file Show diff for this revision Revisions of this file
emic2.h 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 a9083c11b10b JPEGCamera.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JPEGCamera.lib	Tue Dec 08 00:41:58 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/yamaguch/code/JPEGCamera/#27417b6a951d
diff -r 000000000000 -r a9083c11b10b emic2.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emic2.h	Tue Dec 08 00:41:58 2015 +0000
@@ -0,0 +1,42 @@
+#define speakf printf
+class emic2 : public Stream
+{
+public :
+    emic2(PinName tx, PinName rx): _cmd(tx,rx) {
+        _cmd.baud(9600);
+        _cmd.putc('X'); //stop talking if reset and not a power on
+        _cmd.putc('\r'); // Send a CR in case the system is already up
+        wait(1); //delay for emic power on boot or reset respone
+        while (_cmd.getc() != ':');   // When the Emic 2 has initialized and is ready, it will send a single ':'
+        while (_cmd.readable()) _cmd.getc();//flush out buffer just in case
+    };
+    void ready() {
+        while (_cmd.getc() != ':');
+        while (_cmd.readable()) _cmd.getc();//flush out recieve buffer just in case
+    };
+    int readable() {
+        return _cmd.readable();
+    };
+    int getc() {
+        return _cmd.getc();
+    }
+    void volume(int x) {
+        speakf("V%D\r",x);
+        ready();
+    }
+    void voice(int x) {
+        speakf("N%D\r",x);
+        ready();
+    }
+protected :
+    Serial     _cmd;
+    //used by printf - supply it and printf works!
+    virtual int _putc(int c) {
+        _cmd.putc(c);
+        return 0;
+    };
+    virtual int _getc() {
+        return -1;
+    };
+};
+
diff -r 000000000000 -r a9083c11b10b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 08 00:41:58 2015 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "JPEGCamera.h"
+#include "emic2.h"
+ 
+DigitalOut myled1(LED1); //show successful picture was taken 
+DigitalOut myled2(LED2); //show end of sequence
+DigitalOut myled3(LED3); //show picture take failed
+DigitalOut myled4(LED4); //show camera is not ready
+Serial pc(USBTX, USBRX);
+
+DigitalIn handShake(p21);
+JPEGCamera camera(p9, p10); // TX, RX
+emic2 myTTS(p13, p14); //serial RX,TX pins to emic
+int picNum = 0;
+char filename[32];
+    
+char* takePic(){
+    LocalFileSystem local("local"); //save images on mbed
+    Timer timer;
+    timer.start();
+
+    camera.setPictureSize(JPEGCamera::SIZE320x240);
+    
+    if (camera.isReady()) {
+        sprintf(filename, "/local/pict%03d.jpg", picNum++);
+        printf("Picture: %s ", filename);
+        if (camera.takePicture(filename)) {
+            while (camera.isProcessing()) {
+                camera.processPicture();
+            }
+            myled1 = 1; //show successful picture was taken 
+            wait(2.0);
+            myled1 = 0;
+        } else {
+            printf("take picture failed\n");
+            myled3 = 1; //show picture take failed
+            wait(2.0);
+            myled3 = 0;
+        }
+    } else {
+        printf("camera is not ready\n");
+        myled4 = 1; //show camera is not ready
+        wait(2.0);
+        myled4 = 0;
+    }
+        
+    myled2 = 1; //show end of sequence
+    wait(2.0);
+    myled2 = 0;
+    printf("time = %f\n", timer.read());
+    
+    return filename;
+}
+
+
+int main()
+{
+    myTTS.volume(18); //max volume
+    while(1) {
+        if (handShake == 0) {
+            wait(0.5);
+            //Buzz speaks
+            myTTS.speakf("S");//Speak command starts with "S"
+            myTTS.speakf("Hello! My name is Buzz, the GT Yellow Jacket. I am going to take a picture. Smile!", 8);  // Send the desired string to convert to speech
+            myTTS.speakf("\r"); //marks end of speak command
+            myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
+            
+            char* file = takePic();
+            
+        }
+
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r a9083c11b10b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 08 00:41:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file