test program for Bluetooth JPEG Camera library for LinkSprite LS-Y201 camera

Dependencies:   JPEGCamera mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 #include "mbed.h"
00003 #include "JPEGCamera.h"
00004 
00005 Serial control(p28, p27); // tx, rx read from bluetooth module VERIFIED
00006 JPEGCamera camera(p13, p14); // TX, RX to camera
00007 
00008 //Camera time
00009 Timer timer;
00010 
00011 int main()
00012 {
00013     int message = 0;
00014     
00015     control.baud(115200);
00016     
00017     //Camera Initialization and picture sizing
00018     timer.start();
00019     camera.setPictureSize(JPEGCamera::SIZE160x120);
00020     wait(3);
00021     //Continuously wait for commands
00022     while(1) 
00023     {
00024         //Check for bytes over serial from bluetooth/xbee
00025         if(control.readable()) 
00026         {
00027             message=control.getc();    
00028             //Take a picture (note that this takes a while to complete and will only only work for 999 pictures
00029             if (message==210)
00030             {
00031                 if (camera.isReady()) 
00032                 {
00033                     if (camera.takePicture()) 
00034                     {
00035                         int image_size = camera.getImageSize();
00036                         while (camera.isProcessing()) 
00037                         {
00038                             camera.processPicture(control);
00039                         }
00040                     }    
00041                     else 
00042                     {
00043                         control.printf("D 1 \n");
00044                     }
00045                 } 
00046                 else 
00047                 {
00048                     control.printf("D 0 \n");
00049                 }
00050             }
00051         }
00052     }
00053 }