code for taking image and saving to SD card
Dependencies: SDFileSystem mbed
Diff: main.cpp
- Revision:
- 4:c22ccc2df5dc
- Parent:
- 3:2f9cbbda52e8
diff -r 2f9cbbda52e8 -r c22ccc2df5dc main.cpp --- a/main.cpp Mon Apr 06 22:17:20 2015 +0000 +++ b/main.cpp Sun Apr 12 02:14:26 2015 +0000 @@ -1,4 +1,4 @@ -0/******************************************************************************************************* +/******************************************************************************************************* This code uses the LS-Y202 camera module to take an image, and save it an SD card. The SD card is interfaced via an SD card shield. @@ -12,8 +12,10 @@ #include "stdlib.h" Serial pc(USBTX, USBRX); // tx, rx, communicate with PC -Serial cam(D8, D2); // tx, rx, (Camera to) Nucleo -SDFileSystem sd(D11, D12, D13, D10, "sd"); // mosi, miso, sclk, cs, name +//Serial cam(D8, D2); // tx, rx, (Camera to) Nucleo +Serial cam(PA_11, PA_12); +//SDFileSystem sd(D11, D12, D13, D10, "sd"); // mosi, miso, sclk, cs, name +SDFileSystem sd(PB_15, PB_14, PB_13, D4, "sd"); uint8_t ZERO = 0x00; uint8_t incomingbyte; @@ -164,7 +166,7 @@ int main(void) { - pc.baud(128000); // for PC terminal display/communications + pc.baud(115200); // for PC terminal display/communications pc.printf("\n\rStarting...\n\r"); // cam.attach(&cam_Rx_interrupt, Serial::RxIrq); // attach ISR to cam UART recieve @@ -187,14 +189,16 @@ wait(0.100); // 0x22 = 160*120, 0x11 = 320*240, 0x00 = 640*480, 0x1D = 800*600 // 0x1C = 1024*768, 0x1B = 1280*960, 0x21 = 1600*1200 - SetImageSizeCmd(0x1D); + SetImageSizeCmd(0x00); wait(0.100); SendTakePhotoCmd(); wait(3); // Open SD card dir and file mkdir("/sd/mydir", 0777); - FILE *fp = fopen("/sd/mydir/sdtest.jpg", "w"); + char tmp[50]; + //sprintf( + FILE *fp = fopen("/sd/mydir/sdtest640x480.jpg", "w"); if(fp == NULL) { error("\n\rCould not open file for write\n\r"); }