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