VC0706 driver for radio shack camera shield
Sample Code
#include "mbed.h" #include "SDFileSystem.h" #include "CameraShield.h" #include <stdio.h> unsigned char VC0706_rx_buffer[80]; SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd", PTE6, SDFileSystem::SWITCH_POS_NO, 25000000); // MOSI, MISO, SCLK, SSEL CameraShield camera(PTC17, PTC16); void CapturePhoto() { uint32_t frame_length = camera.VC0706_get_frame_buffer_length(); //get frame buffer length uint32_t vc_frame_address = READ_DATA_BLOCK_NO; FILE* camFile = fopen("/sd/temp.jpg", "w"); while(vc_frame_address<frame_length) { camera.VC0706_read_frame_buffer(vc_frame_address - READ_DATA_BLOCK_NO, READ_DATA_BLOCK_NO); wait_ms(9); //get the data with length=READ_DATA_BLOCK_NObytes camera.buffer_read(VC0706_rx_buffer, 80); // write data to temp.jpg fwrite(VC0706_rx_buffer + 5, sizeof(char), READ_DATA_BLOCK_NO, camFile); //read next READ_DATA_BLOCK_NO bytes from frame buffer vc_frame_address = vc_frame_address + READ_DATA_BLOCK_NO; } // get the last data vc_frame_address = vc_frame_address - READ_DATA_BLOCK_NO; uint32_t last_data_length = frame_length - vc_frame_address; camera.VC0706_read_frame_buffer(vc_frame_address, last_data_length); wait_ms(9); //get the data camera.buffer_read(VC0706_rx_buffer, 80); fwrite(VC0706_rx_buffer+5, sizeof(char), last_data_length, camFile); fclose(camFile); } int main (void) { // Check to see if the file exists: // if exists,delete the file: sd.remove("/sd/temp.jpg"); camera.Init(); camera.VC0706_image_size(VC0706_640x480); camera.ResumeVideo(); wait_ms(500); while(1) { camera.ResumeVideo(); wait_ms(1000); camera.TakeSnapShot(); CapturePhoto(); } }
Revision 1:5cff9e627e06, committed 2014-12-18
- Comitter:
- davidr99
- Date:
- Thu Dec 18 04:36:48 2014 +0000
- Parent:
- 0:e5fc19091502
- Commit message:
- Added modserial to its dependency
Changed in this revision
MODSERIAL.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r e5fc19091502 -r 5cff9e627e06 MODSERIAL.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MODSERIAL.lib Thu Dec 18 04:36:48 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/MODSERIAL/#a04506a9a55b