supported GR-PEACH original: http://developer.mbed.org/users/va009039/code/USBHostC270_example/ The function of Isochronous has moved to USBHost_AddIso library.
Dependencies: USBHost_custom_Addiso
Fork of USBHostC270_example_GR-PEACH by
main.cpp@13:fa85d3614acf, 2015-04-01 (annotated)
- Committer:
- dkato
- Date:
- Wed Apr 01 05:46:06 2015 +0000
- Revision:
- 13:fa85d3614acf
- Parent:
- 11:6a8eef89eb22
- Child:
- 15:ac8b6c6dfb3f
The function of Isochronous has moved to USBHost_AddIso library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 10:387c49b2fc7e | 1 | #include "USBHostMSD.h" |
va009039 | 10:387c49b2fc7e | 2 | #include "USBHostC270.h" |
va009039 | 10:387c49b2fc7e | 3 | |
va009039 | 10:387c49b2fc7e | 4 | Serial pc(USBTX, USBRX); |
va009039 | 10:387c49b2fc7e | 5 | BusOut leds(LED1, LED2, LED3); |
va009039 | 10:387c49b2fc7e | 6 | |
dkato | 13:fa85d3614acf | 7 | static uint8_t buf[1024*10]; |
dkato | 13:fa85d3614acf | 8 | |
va009039 | 10:387c49b2fc7e | 9 | int main() { |
va009039 | 10:387c49b2fc7e | 10 | pc.baud(921600); |
va009039 | 10:387c49b2fc7e | 11 | |
va009039 | 10:387c49b2fc7e | 12 | USBHostMSD* msd = new USBHostMSD("usb"); // USB flash drive |
va009039 | 10:387c49b2fc7e | 13 | USBHostC270* cam = new USBHostC270(C270_MJPEG, C270_160x120, _5FPS); // Logitech C270 |
va009039 | 10:387c49b2fc7e | 14 | |
va009039 | 10:387c49b2fc7e | 15 | Timer interval_t; |
va009039 | 10:387c49b2fc7e | 16 | interval_t.reset(); |
va009039 | 10:387c49b2fc7e | 17 | interval_t.start(); |
va009039 | 10:387c49b2fc7e | 18 | int shot = 0; |
va009039 | 10:387c49b2fc7e | 19 | while(1) { |
va009039 | 11:6a8eef89eb22 | 20 | if (interval_t.read() > 10 && cam->connected()) { |
va009039 | 10:387c49b2fc7e | 21 | int r = cam->readJPEG(buf, sizeof(buf)); |
va009039 | 10:387c49b2fc7e | 22 | char path[32]; |
va009039 | 10:387c49b2fc7e | 23 | snprintf(path, sizeof(path), "/usb/image%02d.jpg", shot % 20); |
va009039 | 10:387c49b2fc7e | 24 | printf("%d %s %d bytes\n", shot, path, r); |
va009039 | 10:387c49b2fc7e | 25 | if (msd->connected()) { |
va009039 | 10:387c49b2fc7e | 26 | FILE* fp = fopen(path, "wb"); |
va009039 | 10:387c49b2fc7e | 27 | if (fp) { |
va009039 | 10:387c49b2fc7e | 28 | fwrite(buf, r, 1, fp); |
va009039 | 10:387c49b2fc7e | 29 | fclose(fp); |
va009039 | 10:387c49b2fc7e | 30 | } |
va009039 | 10:387c49b2fc7e | 31 | shot++; |
va009039 | 10:387c49b2fc7e | 32 | leds = shot % 8; |
va009039 | 10:387c49b2fc7e | 33 | } |
va009039 | 10:387c49b2fc7e | 34 | interval_t.reset(); |
va009039 | 10:387c49b2fc7e | 35 | } |
va009039 | 10:387c49b2fc7e | 36 | if (!msd->connected()) { |
va009039 | 10:387c49b2fc7e | 37 | msd->connect(); |
va009039 | 11:6a8eef89eb22 | 38 | Thread::wait(500); |
va009039 | 10:387c49b2fc7e | 39 | } |
va009039 | 11:6a8eef89eb22 | 40 | if (!cam->connected()) { |
va009039 | 11:6a8eef89eb22 | 41 | cam->connect(); |
va009039 | 11:6a8eef89eb22 | 42 | Thread::wait(500); |
va009039 | 11:6a8eef89eb22 | 43 | } else { |
va009039 | 11:6a8eef89eb22 | 44 | cam->poll(); |
va009039 | 11:6a8eef89eb22 | 45 | } |
va009039 | 10:387c49b2fc7e | 46 | } |
va009039 | 10:387c49b2fc7e | 47 | } |