test program for SIM808 GPRS + JPEG Camera library for LinkSprite LS-Y201 camera

Dependencies:   JPEGCamera mbed

Committer:
tgw
Date:
Fri Jun 09 02:24:22 2017 +0000
Revision:
2:9ad661c031a4
Parent:
0:0c9cdf074ba1
Child:
3:f307a059affe
Camera_LS_Y201_JPEGCamera_Test(NUCLEO-F401RE)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thesane 0:0c9cdf074ba1 1
thesane 0:0c9cdf074ba1 2 #include "mbed.h"
thesane 0:0c9cdf074ba1 3 #include "JPEGCamera.h"
thesane 0:0c9cdf074ba1 4
tgw 2:9ad661c031a4 5 Serial control(SERIAL_TX, SERIAL_RX); // tx, rx read from bluetooth module VERIFIED
tgw 2:9ad661c031a4 6 JPEGCamera camera(PA_9, PA_10); // TX, RX to camera
thesane 0:0c9cdf074ba1 7
thesane 0:0c9cdf074ba1 8 //Camera time
thesane 0:0c9cdf074ba1 9 Timer timer;
thesane 0:0c9cdf074ba1 10
thesane 0:0c9cdf074ba1 11 int main()
thesane 0:0c9cdf074ba1 12 {
thesane 0:0c9cdf074ba1 13 int message = 0;
thesane 0:0c9cdf074ba1 14
thesane 0:0c9cdf074ba1 15 control.baud(115200);
thesane 0:0c9cdf074ba1 16
thesane 0:0c9cdf074ba1 17 //Camera Initialization and picture sizing
thesane 0:0c9cdf074ba1 18 timer.start();
tgw 2:9ad661c031a4 19 if(camera.setPictureSize(JPEGCamera::SIZE160x120))
tgw 2:9ad661c031a4 20 {
tgw 2:9ad661c031a4 21 control.printf("D 3 \n");
tgw 2:9ad661c031a4 22 }
tgw 2:9ad661c031a4 23 else
tgw 2:9ad661c031a4 24 {
tgw 2:9ad661c031a4 25 control.printf("D 4 \n");
tgw 2:9ad661c031a4 26 }
thesane 0:0c9cdf074ba1 27 wait(3);
thesane 0:0c9cdf074ba1 28 //Continuously wait for commands
thesane 0:0c9cdf074ba1 29 while(1)
thesane 0:0c9cdf074ba1 30 {
thesane 0:0c9cdf074ba1 31 //Check for bytes over serial from bluetooth/xbee
thesane 0:0c9cdf074ba1 32 if(control.readable())
thesane 0:0c9cdf074ba1 33 {
thesane 0:0c9cdf074ba1 34 message=control.getc();
thesane 0:0c9cdf074ba1 35 //Take a picture (note that this takes a while to complete and will only only work for 999 pictures
thesane 0:0c9cdf074ba1 36 if (message==210)
thesane 0:0c9cdf074ba1 37 {
thesane 0:0c9cdf074ba1 38 if (camera.isReady())
thesane 0:0c9cdf074ba1 39 {
thesane 0:0c9cdf074ba1 40 if (camera.takePicture())
thesane 0:0c9cdf074ba1 41 {
thesane 0:0c9cdf074ba1 42 int image_size = camera.getImageSize();
thesane 0:0c9cdf074ba1 43 while (camera.isProcessing())
thesane 0:0c9cdf074ba1 44 {
thesane 0:0c9cdf074ba1 45 camera.processPicture(control);
thesane 0:0c9cdf074ba1 46 }
thesane 0:0c9cdf074ba1 47 }
thesane 0:0c9cdf074ba1 48 else
thesane 0:0c9cdf074ba1 49 {
thesane 0:0c9cdf074ba1 50 control.printf("D 1 \n");
thesane 0:0c9cdf074ba1 51 }
thesane 0:0c9cdf074ba1 52 }
thesane 0:0c9cdf074ba1 53 else
thesane 0:0c9cdf074ba1 54 {
thesane 0:0c9cdf074ba1 55 control.printf("D 0 \n");
thesane 0:0c9cdf074ba1 56 }
thesane 0:0c9cdf074ba1 57 }
thesane 0:0c9cdf074ba1 58 }
thesane 0:0c9cdf074ba1 59 }
thesane 0:0c9cdf074ba1 60 }