![](/media/cache/profiles/6f7790bb54a7c5d3dea27385488a604a.jpg.50x50_q85.jpg)
putting strings to xbee
Dependencies: BMP085 SDFileSystem mbed JPEGCamera
Fork of SaibiCansat2014 by
camera.cpp@4:05e46365f442, 2014-07-15 (annotated)
- Committer:
- TakashiSasaki
- Date:
- Tue Jul 15 08:22:19 2014 +0000
- Revision:
- 4:05e46365f442
- Child:
- 5:8a4b2ffa8d71
camera.cpp is copied from main.cpp of kamera-tesuto2 project.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TakashiSasaki | 4:05e46365f442 | 1 | #include "mbed.h" |
TakashiSasaki | 4:05e46365f442 | 2 | #include "JPEGCamera.h" |
TakashiSasaki | 4:05e46365f442 | 3 | #include "SDFileSystem.h" |
TakashiSasaki | 4:05e46365f442 | 4 | |
TakashiSasaki | 4:05e46365f442 | 5 | DigitalOut myled1(LED1); //show successful picture was taken |
TakashiSasaki | 4:05e46365f442 | 6 | DigitalOut myled2(LED2); //show end of sequence |
TakashiSasaki | 4:05e46365f442 | 7 | DigitalOut myled3(LED3); //show picture take failed |
TakashiSasaki | 4:05e46365f442 | 8 | DigitalOut myled4(LED4); //show camera is not ready |
TakashiSasaki | 4:05e46365f442 | 9 | |
TakashiSasaki | 4:05e46365f442 | 10 | //SDFileSystem sd(p5,p6,p7,p8,"sd"); |
TakashiSasaki | 4:05e46365f442 | 11 | //AnalogIn ain(p15); |
TakashiSasaki | 4:05e46365f442 | 12 | |
TakashiSasaki | 4:05e46365f442 | 13 | LocalFileSystem local("local"); |
TakashiSasaki | 4:05e46365f442 | 14 | #define FILENAME "/sd/pict%03d.jpg" |
TakashiSasaki | 4:05e46365f442 | 15 | |
TakashiSasaki | 4:05e46365f442 | 16 | int main_camera() { |
TakashiSasaki | 4:05e46365f442 | 17 | |
TakashiSasaki | 4:05e46365f442 | 18 | printf("%s\n", __FILE__); //sourcefilename printout |
TakashiSasaki | 4:05e46365f442 | 19 | printf("start!!\n"); |
TakashiSasaki | 4:05e46365f442 | 20 | |
TakashiSasaki | 4:05e46365f442 | 21 | JPEGCamera camera(p9, p10); // TX, RX |
TakashiSasaki | 4:05e46365f442 | 22 | LocalFileSystem local("local"); //save images on mbed |
TakashiSasaki | 4:05e46365f442 | 23 | Timer timer; |
TakashiSasaki | 4:05e46365f442 | 24 | timer.start(); |
TakashiSasaki | 4:05e46365f442 | 25 | camera.setPictureSize(JPEGCamera::SIZE320x240); |
TakashiSasaki | 4:05e46365f442 | 26 | |
TakashiSasaki | 4:05e46365f442 | 27 | FILE *fp; |
TakashiSasaki | 4:05e46365f442 | 28 | if ((fp==fopen(FILENAME,"wb")) == NULL) ; |
TakashiSasaki | 4:05e46365f442 | 29 | |
TakashiSasaki | 4:05e46365f442 | 30 | |
TakashiSasaki | 4:05e46365f442 | 31 | for (int i = 0; i < 2; i++) { |
TakashiSasaki | 4:05e46365f442 | 32 | |
TakashiSasaki | 4:05e46365f442 | 33 | if (camera.isReady()) { |
TakashiSasaki | 4:05e46365f442 | 34 | char filename[32]; |
TakashiSasaki | 4:05e46365f442 | 35 | sprintf(filename, "/sd/pict%03d.jpg", i); |
TakashiSasaki | 4:05e46365f442 | 36 | printf("Picture: %s ", filename); |
TakashiSasaki | 4:05e46365f442 | 37 | if (camera.takePicture(filename)) { |
TakashiSasaki | 4:05e46365f442 | 38 | while (camera.isProcessing()) { |
TakashiSasaki | 4:05e46365f442 | 39 | camera.processPicture(); |
TakashiSasaki | 4:05e46365f442 | 40 | } |
TakashiSasaki | 4:05e46365f442 | 41 | myled1 = 1; //show successful picture was taken |
TakashiSasaki | 4:05e46365f442 | 42 | wait(2.0); |
TakashiSasaki | 4:05e46365f442 | 43 | myled1 = 0; |
TakashiSasaki | 4:05e46365f442 | 44 | } else { |
TakashiSasaki | 4:05e46365f442 | 45 | printf("take picture picture\n"); |
TakashiSasaki | 4:05e46365f442 | 46 | myled3 = 1; //show picture take failed |
TakashiSasaki | 4:05e46365f442 | 47 | wait(2.0); |
TakashiSasaki | 4:05e46365f442 | 48 | myled3 = 0; |
TakashiSasaki | 4:05e46365f442 | 49 | } |
TakashiSasaki | 4:05e46365f442 | 50 | } else { |
TakashiSasaki | 4:05e46365f442 | 51 | printf("show camera is not ready\n"); |
TakashiSasaki | 4:05e46365f442 | 52 | myled4 = 1; //show camera is not ready |
TakashiSasaki | 4:05e46365f442 | 53 | wait(2.0); |
TakashiSasaki | 4:05e46365f442 | 54 | myled4 = 0; |
TakashiSasaki | 4:05e46365f442 | 55 | } |
TakashiSasaki | 4:05e46365f442 | 56 | } |
TakashiSasaki | 4:05e46365f442 | 57 | myled2 = 1; //show end of sequence |
TakashiSasaki | 4:05e46365f442 | 58 | wait(2.0); |
TakashiSasaki | 4:05e46365f442 | 59 | myled2 = 0; |
TakashiSasaki | 4:05e46365f442 | 60 | printf("time = %f\n", timer.read()); |
TakashiSasaki | 4:05e46365f442 | 61 | |
TakashiSasaki | 4:05e46365f442 | 62 | fclose(fp); |
TakashiSasaki | 4:05e46365f442 | 63 | exit(1); |
TakashiSasaki | 4:05e46365f442 | 64 | } |