Library creation
Revision 0:bd5d25911e06, committed 2016-03-17
- Comitter:
- GlessConsult
- Date:
- Thu Mar 17 17:53:43 2016 +0000
- Commit message:
- A little library to control a Mobius ActionCam by connecting the USB interface via relays.
Changed in this revision
MobiusCam.cpp | Show annotated file Show diff for this revision Revisions of this file |
MobiusCam.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r bd5d25911e06 MobiusCam.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MobiusCam.cpp Thu Mar 17 17:53:43 2016 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "USBHostMSD.h" +#include "MobiusCam.h" + +void MobiusCam::clip(int t) { // take a clip for t seconds + printf("Start a clip\r\n"); + _camUSB = 0; + Thread::wait(200); + _camV5V = 1; + Thread::wait(t * 1000); + printf("Stop the clip\r\n"); + _camUSB = 0; + _camV5V = 0; + Thread::wait(1000); +} + +void MobiusCam::directory(char *buf, int bufLen) { + printf("Start the camera\r\n"); + _camUSB = 1; + Thread::wait(200); + _camV5V = 1; + Thread::wait(7000); + printf("Try to connect the MSD device\r\n"); + int cnt = 0; + while(!_msd.connect() && (cnt++ < 5)) { + Thread::wait(500); + } + if (cnt < 5) { + printf("MSD device connected\r\n"); + DIR *d = opendir("/usb/DCIM/101HDDVR"); + //DIR *d = opendir("/usb/DCIM"); + if (d != NULL) { + struct dirent *p; + uint32_t counter = 0; + printf("Lecture du repertoire ...\r\n"); + while ((p = readdir(d)) != NULL) { + counter++; + printf("%s\r\n", p->d_name); + } + closedir(d); + printf("\r\nFin de lecture du repertoire\r\n"); + } + else + printf("No directory\r\n"); + } + else + printf("MSD device NOT connected\r\n"); + Thread::wait(500); + printf("Stop the camera\r\n"); + _camUSB = 0; + _camV5V = 0; + Thread::wait(1000); +} \ No newline at end of file
diff -r 000000000000 -r bd5d25911e06 MobiusCam.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MobiusCam.h Thu Mar 17 17:53:43 2016 +0000 @@ -0,0 +1,23 @@ +#ifndef MBED_MOBIUS_H +#define MBED_MOBIUS_H + +#include "mbed.h" +#include "USBHostMSD.h" + +class MobiusCam { +public: + MobiusCam(PinName camV5V, PinName camUSB) : _camV5V(camV5V), _camUSB(camUSB), _msd("usb") { + _camV5V = 0; + _camUSB = 0; + } + + void clip(int t); + void directory(char *buf, int bufLen); + +private: + DigitalOut _camV5V; + DigitalOut _camUSB; + USBHostMSD _msd; +}; + +#endif \ No newline at end of file