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

Dependencies:   JPEGCamera mbed

main.cpp

Committer:
thesane
Date:
2014-10-13
Revision:
1:68d8660363d5
Parent:
0:0c9cdf074ba1

File content as of revision 1:68d8660363d5:


#include "mbed.h"
#include "JPEGCamera.h"

Serial control(p28, p27); // tx, rx read from bluetooth module VERIFIED
JPEGCamera camera(p13, p14); // TX, RX to camera

//Camera time
Timer timer;

int main()
{
    int message = 0;
    
    control.baud(115200);
    
    //Camera Initialization and picture sizing
    timer.start();
    camera.setPictureSize(JPEGCamera::SIZE160x120);
    wait(3);
    //Continuously wait for commands
    while(1) 
    {
        //Check for bytes over serial from bluetooth/xbee
        if(control.readable()) 
        {
            message=control.getc();    
            //Take a picture (note that this takes a while to complete and will only only work for 999 pictures
            if (message==210)
            {
                if (camera.isReady()) 
                {
                    if (camera.takePicture()) 
                    {
                        int image_size = camera.getImageSize();
                        while (camera.isProcessing()) 
                        {
                            camera.processPicture(control);
                        }
                    }    
                    else 
                    {
                        control.printf("D 1 \n");
                    }
                } 
                else 
                {
                    control.printf("D 0 \n");
                }
            }
        }
    }
}