Jean Philippe Glesser / MobiusCam
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MobiusCam.cpp Source File

MobiusCam.cpp

00001 #include "mbed.h"
00002 #include "USBHostMSD.h"
00003 #include "MobiusCam.h"
00004 
00005 void MobiusCam::clip(int t) {      // take a clip for t seconds
00006     printf("Start a clip\r\n");
00007     _camUSB = 0;
00008     Thread::wait(200);
00009     _camV5V = 1;
00010     Thread::wait(t * 1000);
00011     printf("Stop the clip\r\n");
00012     _camUSB = 0;
00013     _camV5V = 0;
00014     Thread::wait(1000);
00015 }
00016 
00017 void MobiusCam::directory(char *buf, int bufLen) {     
00018     printf("Start the camera\r\n");
00019     _camUSB = 1;
00020     Thread::wait(200);
00021     _camV5V = 1;
00022     Thread::wait(7000);
00023     printf("Try to connect the MSD device\r\n");
00024     int cnt = 0;
00025     while(!_msd.connect() && (cnt++ < 5)) {
00026         Thread::wait(500);
00027     }
00028     if (cnt < 5) {
00029         printf("MSD device connected\r\n");
00030         DIR *d = opendir("/usb/DCIM/101HDDVR");
00031         //DIR *d = opendir("/usb/DCIM");
00032         if (d != NULL) {
00033             struct dirent *p;
00034             uint32_t counter = 0;              
00035             printf("Lecture du repertoire ...\r\n");
00036             while ((p = readdir(d)) != NULL) {
00037                 counter++;
00038                 printf("%s\r\n", p->d_name);   
00039             }
00040             closedir(d);
00041             printf("\r\nFin de lecture du repertoire\r\n");
00042         }
00043         else
00044             printf("No directory\r\n");
00045     }
00046     else
00047         printf("MSD device NOT connected\r\n");
00048     Thread::wait(500);        
00049     printf("Stop the camera\r\n");
00050     _camUSB = 0;
00051     _camV5V = 0;
00052     Thread::wait(1000);
00053 }