Hi, I was trying for more than a week to use a camera from RadioShack with my new YUN, finally works but now I have a different problem now it is taking to long to save the picture (1 hour) that I took and I don't know what to do.
The camera works fine with Arduino UNO and save the picture in less than 30 seconds.
/*******************************************************************************
- Function Name : capture_photo
- Description : capture a photo and store the file named temp.jpg into SD
- Input : None
- Output : None
- Return : None
*******************************************************************************/
void capture_photo(){
String dir = "/mnt/sd/";
String filename = getTimeStamp();
//NOTE I need to fix this problem.
String extencion = "KC01.jpg "; //For some reason this name has to have a extra space at the end in order to be completed.
String nombreArchivoCompleto = (dir+filename+extencion);
int nombreArchivoCompletoLength = nombreArchivoCompleto.length();
char fileNameCharArray[nombreArchivoCompletoLength];
nombreArchivoCompleto.toCharArray(fileNameCharArray, nombreArchivoCompletoLength);
File dataFile = FileSystem.open(fileNameCharArray, FILE_WRITE);
delay(10);
VC0706_compression_ratio(63);
delay(100);
VC0706_frame_control(3);
delay(10);
VC0706_frame_control(0);
delay(10);
rx_ready=false;
rx_counter=0;
mySerial.end(); // clear all rx buffer
delay(50);
mySerial.begin(115200);
//get frame buffer length
VC0706_get_framebuffer_length(0);
delay(100);
buffer_read();
//while(1){};
// store frame buffer length for coming reading
frame_length=(VC0706_rx_buffer[5]<<8)+VC0706_rx_buffer[6];
frame_length=frame_length<<16;
frame_length=frame_length+(0x0ff00&(VC0706_rx_buffer[7]<<8))+VC0706_rx_buffer[8];
vc_frame_address =READ_DATA_BLOCK_NO;
// make a string that start with a timestamp for assembling the data to log:
while(vc_frame_address<frame_length){
VC0706_read_frame_buffer(vc_frame_address-READ_DATA_BLOCK_NO, READ_DATA_BLOCK_NO);
delay(6);
//get the data with length=READ_DATA_BLOCK_NObytes
rx_ready=false;
rx_counter=0;
buffer_read();
// write data to temp.jpg
dataFile.write(VC0706_rx_buffer+5,READ_DATA_BLOCK_NO);
//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;
last_data_length=frame_length-vc_frame_address;
VC0706_read_frame_buffer(vc_frame_address,last_data_length);
delay(6);
//get the data
rx_ready=false;
rx_counter=0;
buffer_read();
dataFile.write(VC0706_rx_buffer+5,last_data_length);
dataFile.close();
//Serial.print("Imagen lista para ser vista y esperando para la siguiente");
}
Is there a solution.
Thank you so much.