Xbee-Smart-Home-Inside RX Test
Dependencies: Si7021 mbed-rtos JPEGCamera mbed
Fork of Xbee-Smart-Home-Inside by
Diff: main.cpp
- Revision:
- 1:e9068d048f58
- Parent:
- 0:5b1386641010
- Child:
- 2:21031e885513
--- a/main.cpp Mon Apr 17 12:34:06 2017 +0000 +++ b/main.cpp Mon Apr 17 17:55:01 2017 +0000 @@ -1,15 +1,16 @@ -/** - * XBee Example Test - * A test application that demonstrates the ability - * of transmitting serial data via an XBee module with - * an mbed microprocesor. - * By: Vlad Cazan - * Date: Tuesday, September 29th 2009 - */ +#include "mbed.h" +#include "rtos.h" +#include "JPEGCamera.h" -#include "mbed.h" +AnalogIn ambient(p15); +Mutex getMutex; +Mutex putMutex; + +Thread t1; +Thread t2; Serial xbee1(p9, p10); //Creates a variable for serial comunication through pin 9 and 10 +JPEGCamera camera(p13, p14); // TX, RX DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset @@ -33,4 +34,33 @@ else {myled = 1;} //Turn Led 3 on for succcessfull communication } } + t1.start(callback(ambient_sensor()); + + +} + +void ambinet_sensor(){ + float amb_val = ambient(); + // Scale to proper unit + putMutex.lock(); + xbee.puts(amb_val); + putMutex.unlock(); +} + +void cameraThread(){ + LocalFileSystem local("local"); //save images on mbed + camera.setPictureSize(JPEGCamera::SIZE160x120); + while(1){ + if (camera.isReady()){ + char filename[32]; + sprintf(filename, "/local/pict.jpg"); + printf("Picture: %s ", filename); + if (camera.takePicture(filename)) { + while (camera.isProcessing()) { + camera.processPicture(); + } + break; + } + } + } } \ No newline at end of file