Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PTPCapture added to examples

  • Loading branch information...
commit d5da81a3601cba66f8d0fe8f98edb48810926634 1 parent 285d869
@felis authored
Showing with 76 additions and 1 deletion.
  1. +5 −1 README
  2. +71 −0 examples/PTPCapture/PTPCapture.pde
View
6 README
@@ -1 +1,5 @@
-PTP and camera-specific libraries for Arduino USB Host Project. The project is hosted at http://www.circuitsathome.com
+PTP and camera-specific libraries for Arduino USB Host Project.
+
+This library depends on <a href="<a href="https://github.com/felis/USB_Host_Shield">USB_Host_Shield library</a> written to support <a href="/arduino_usb_host_shield_projects">USB Host Shield</a>.
+
+The project is hosted at http://www.circuitsathome.com
View
71 examples/PTPCapture/PTPCapture.pde
@@ -0,0 +1,71 @@
+#include <inttypes.h>
+#include <avr/pgmspace.h>
+
+#include <Max3421e.h>
+#include <Max3421e_constants.h>
+#include <Max_LCD.h>
+#include <Usb.h>
+
+#include <ptp.h>
+
+#define DEV_ADDR 1
+
+// Nikon CoolPix P100
+#define DATA_IN_EP 2
+#define DATA_OUT_EP 1
+#define INTERRUPT_EP 3
+#define CONFIG_NUM 1
+
+// Canon
+//#define DATA_IN_EP 1
+//#define DATA_OUT_EP 2
+//#define INTERRUPT_EP 3
+//#define CONFIG_NUM 1
+
+#define MAX_USB_STRING_LEN 64
+
+class CamStateHandlers : public PTPStateHandlers
+{
+ bool stateConnected;
+
+public:
+ CamStateHandlers() : stateConnected(false) {};
+
+ virtual void OnDeviceDisconnectedState(PTP *ptp);
+ virtual void OnDeviceInitializedState(PTP *ptp);
+} CamStates;
+
+PTP Ptp(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);
+
+void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
+{
+ if (stateConnected)
+ {
+ stateConnected = false;
+ Notify(PSTR("Camera disconnected\r\n"));
+ }
+}
+
+void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
+{
+ if (!stateConnected)
+ {
+ stateConnected = true;
+
+ Ptp.CaptureImage();
+ delay(1000);
+ }
+}
+
+void setup() {
+ Serial.begin( 115200 );
+ Serial.println("Start");
+ Ptp.Setup();
+ delay( 200 );
+}
+
+void loop()
+{
+ Ptp.Task();
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.