Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | /* Capture command demo */ |
2 | #include <inttypes.h> |
||
3 | #include <avr/pgmspace.h> |
||
4 | |||
5 | //#include <Spi.h> |
||
6 | #include <Max3421e.h> |
||
7 | #include <Max3421e_constants.h> |
||
8 | #include <Max_LCD.h> |
||
9 | #include <Usb.h> |
||
10 | |||
11 | #include <ptp.h> |
||
12 | #include <canoneos.h> |
||
13 | |||
14 | #include <MemoryFree.h> |
||
15 | |||
16 | #define DEV_ADDR 1 |
||
17 | |||
18 | // Canon EOS 400D |
||
19 | #define DATA_IN_EP 1 |
||
20 | #define DATA_OUT_EP 2 |
||
21 | #define INTERRUPT_EP 3 |
||
22 | #define CONFIG_NUM 1 |
||
23 | |||
24 | class CamStateHandlers : public PTPStateHandlers |
||
25 | { |
||
26 | bool stateConnected; |
||
27 | |||
28 | public: |
||
29 | CamStateHandlers() : stateConnected(false) {}; |
||
30 | |||
31 | virtual void OnDeviceDisconnectedState(PTP *ptp); |
||
32 | virtual void OnDeviceInitializedState(PTP *ptp); |
||
33 | } CamStates; |
||
34 | |||
35 | CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates); |
||
36 | |||
37 | void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp) |
||
38 | { |
||
39 | if (stateConnected) |
||
40 | { |
||
41 | stateConnected = false; |
||
42 | Notify(PSTR("Camera disconnected\r\n")); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | void CamStateHandlers::OnDeviceInitializedState(PTP *ptp) |
||
47 | { |
||
48 | if (!stateConnected) |
||
49 | stateConnected = true; |
||
50 | |||
51 | uint16_t rc = Eos.Capture(); |
||
52 | |||
53 | if (rc != PTP_RC_OK) |
||
54 | Message(PSTR("Error: "), rc); |
||
55 | |||
56 | delay(5000); |
||
57 | } |
||
58 | |||
59 | void setup() |
||
60 | { |
||
61 | Serial.begin( 115200 ); |
||
62 | Serial.println("Start"); |
||
63 | Eos.Setup(); |
||
64 | delay( 200 ); |
||
65 | } |
||
66 | |||
67 | void loop() |
||
68 | { |
||
69 | Eos.Task(); |
||
70 | } |
||
71 |