Ahmed Saber
/
JPEGCameraTest
test program for Bluetooth JPEG Camera library for LinkSprite LS-Y201 camera
main.cpp@0:0c9cdf074ba1, 2014-10-13 (annotated)
- Committer:
- thesane
- Date:
- Mon Oct 13 20:54:45 2014 +0000
- Revision:
- 0:0c9cdf074ba1
test program for Bluetooth JPEGCamera Library
Who changed what in which revision?
User | Revision | Line number | New 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 | |
thesane | 0:0c9cdf074ba1 | 5 | Serial control(p28, p27); // tx, rx read from bluetooth module VERIFIED |
thesane | 0:0c9cdf074ba1 | 6 | JPEGCamera camera(p13, p14); // 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(); |
thesane | 0:0c9cdf074ba1 | 19 | camera.setPictureSize(JPEGCamera::SIZE160x120); |
thesane | 0:0c9cdf074ba1 | 20 | wait(3); |
thesane | 0:0c9cdf074ba1 | 21 | //Continuously wait for commands |
thesane | 0:0c9cdf074ba1 | 22 | while(1) |
thesane | 0:0c9cdf074ba1 | 23 | { |
thesane | 0:0c9cdf074ba1 | 24 | //Check for bytes over serial from bluetooth/xbee |
thesane | 0:0c9cdf074ba1 | 25 | if(control.readable()) |
thesane | 0:0c9cdf074ba1 | 26 | { |
thesane | 0:0c9cdf074ba1 | 27 | message=control.getc(); |
thesane | 0:0c9cdf074ba1 | 28 | //Take a picture (note that this takes a while to complete and will only only work for 999 pictures |
thesane | 0:0c9cdf074ba1 | 29 | if (message==210) |
thesane | 0:0c9cdf074ba1 | 30 | { |
thesane | 0:0c9cdf074ba1 | 31 | if (camera.isReady()) |
thesane | 0:0c9cdf074ba1 | 32 | { |
thesane | 0:0c9cdf074ba1 | 33 | if (camera.takePicture()) |
thesane | 0:0c9cdf074ba1 | 34 | { |
thesane | 0:0c9cdf074ba1 | 35 | int image_size = camera.getImageSize(); |
thesane | 0:0c9cdf074ba1 | 36 | while (camera.isProcessing()) |
thesane | 0:0c9cdf074ba1 | 37 | { |
thesane | 0:0c9cdf074ba1 | 38 | camera.processPicture(control); |
thesane | 0:0c9cdf074ba1 | 39 | } |
thesane | 0:0c9cdf074ba1 | 40 | } |
thesane | 0:0c9cdf074ba1 | 41 | else |
thesane | 0:0c9cdf074ba1 | 42 | { |
thesane | 0:0c9cdf074ba1 | 43 | control.printf("D 1 \n"); |
thesane | 0:0c9cdf074ba1 | 44 | } |
thesane | 0:0c9cdf074ba1 | 45 | } |
thesane | 0:0c9cdf074ba1 | 46 | else |
thesane | 0:0c9cdf074ba1 | 47 | { |
thesane | 0:0c9cdf074ba1 | 48 | control.printf("D 0 \n"); |
thesane | 0:0c9cdf074ba1 | 49 | } |
thesane | 0:0c9cdf074ba1 | 50 | } |
thesane | 0:0c9cdf074ba1 | 51 | } |
thesane | 0:0c9cdf074ba1 | 52 | } |
thesane | 0:0c9cdf074ba1 | 53 | } |