![](/media/cache/profiles/6f7790bb54a7c5d3dea27385488a604a.jpg.50x50_q85.jpg)
putting strings to xbee
Dependencies: BMP085 SDFileSystem mbed JPEGCamera
Fork of SaibiCansat2014 by
camera.cpp@5:8a4b2ffa8d71, 2014-07-15 (annotated)
- Committer:
- TakashiSasaki
- Date:
- Tue Jul 15 10:43:04 2014 +0000
- Revision:
- 5:8a4b2ffa8d71
- Parent:
- 4:05e46365f442
- Child:
- 6:9824d4e2f29b
works for master module.
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 | 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 | 4:05e46365f442 | 24 | JPEGCamera camera(p9, p10); // TX, RX |
TakashiSasaki | 4:05e46365f442 | 25 | LocalFileSystem local("local"); //save images on mbed |
TakashiSasaki | 4:05e46365f442 | 26 | Timer timer; |
TakashiSasaki | 4:05e46365f442 | 27 | timer.start(); |
TakashiSasaki | 4:05e46365f442 | 28 | camera.setPictureSize(JPEGCamera::SIZE320x240); |
TakashiSasaki | 4:05e46365f442 | 29 | |
TakashiSasaki | 5:8a4b2ffa8d71 | 30 | //FILE *fp = fopen(FILENAME,"wb"); |
TakashiSasaki | 5:8a4b2ffa8d71 | 31 | //if (fp == NULL) return -1; |
TakashiSasaki | 4:05e46365f442 | 32 | |
TakashiSasaki | 4:05e46365f442 | 33 | |
TakashiSasaki | 5:8a4b2ffa8d71 | 34 | //for (int i = 0; i < 2; i++) { |
TakashiSasaki | 4:05e46365f442 | 35 | |
TakashiSasaki | 4:05e46365f442 | 36 | if (camera.isReady()) { |
TakashiSasaki | 4:05e46365f442 | 37 | char filename[32]; |
TakashiSasaki | 5:8a4b2ffa8d71 | 38 | sprintf(filename, FILENAME, i); |
TakashiSasaki | 4:05e46365f442 | 39 | printf("Picture: %s ", filename); |
TakashiSasaki | 5:8a4b2ffa8d71 | 40 | myled1 = 1; |
TakashiSasaki | 4:05e46365f442 | 41 | if (camera.takePicture(filename)) { |
TakashiSasaki | 4:05e46365f442 | 42 | while (camera.isProcessing()) { |
TakashiSasaki | 4:05e46365f442 | 43 | camera.processPicture(); |
TakashiSasaki | 4:05e46365f442 | 44 | } |
TakashiSasaki | 5:8a4b2ffa8d71 | 45 | //myled1 = 1; //show successful picture was taken |
TakashiSasaki | 5:8a4b2ffa8d71 | 46 | //wait(2.0); |
TakashiSasaki | 5:8a4b2ffa8d71 | 47 | //myled1 = 0; |
TakashiSasaki | 4:05e46365f442 | 48 | } else { |
TakashiSasaki | 4:05e46365f442 | 49 | printf("take picture picture\n"); |
TakashiSasaki | 5:8a4b2ffa8d71 | 50 | //myled3 = 1; //show picture take failed |
TakashiSasaki | 5:8a4b2ffa8d71 | 51 | //wait(2.0); |
TakashiSasaki | 5:8a4b2ffa8d71 | 52 | //myled3 = 0; |
TakashiSasaki | 4:05e46365f442 | 53 | } |
TakashiSasaki | 5:8a4b2ffa8d71 | 54 | myled1 = 0; |
TakashiSasaki | 4:05e46365f442 | 55 | } else { |
TakashiSasaki | 4:05e46365f442 | 56 | printf("show camera is not ready\n"); |
TakashiSasaki | 4:05e46365f442 | 57 | myled4 = 1; //show camera is not ready |
TakashiSasaki | 4:05e46365f442 | 58 | wait(2.0); |
TakashiSasaki | 4:05e46365f442 | 59 | myled4 = 0; |
TakashiSasaki | 4:05e46365f442 | 60 | } |
TakashiSasaki | 5:8a4b2ffa8d71 | 61 | //} |
TakashiSasaki | 5:8a4b2ffa8d71 | 62 | //myled2 = 1; //show end of sequence |
TakashiSasaki | 5:8a4b2ffa8d71 | 63 | //wait(2.0); |
TakashiSasaki | 5:8a4b2ffa8d71 | 64 | //myled2 = 0; |
TakashiSasaki | 4:05e46365f442 | 65 | printf("time = %f\n", timer.read()); |
TakashiSasaki | 4:05e46365f442 | 66 | |
TakashiSasaki | 5:8a4b2ffa8d71 | 67 | //fclose(fp); |
TakashiSasaki | 5:8a4b2ffa8d71 | 68 | //exit(1); |
TakashiSasaki | 5:8a4b2ffa8d71 | 69 | return 0; |
TakashiSasaki | 4:05e46365f442 | 70 | } |