Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | #include <inttypes.h> |
2 | #include <avr/pgmspace.h> |
||
3 | |||
4 | //#include <Spi.h> |
||
5 | #include <Max3421e.h> |
||
6 | #include <Max3421e_constants.h> |
||
7 | #include <Max_LCD.h> |
||
8 | #include <Usb.h> |
||
9 | |||
10 | #include <ptp.h> |
||
11 | #include <ptpdebug.h> |
||
12 | #include <canoneos.h> |
||
13 | #include <simpletimer.h> |
||
14 | |||
15 | #define DEV_ADDR 1 |
||
16 | |||
17 | // Canon EOS 400D |
||
18 | #define DATA_IN_EP 1 |
||
19 | #define DATA_OUT_EP 2 |
||
20 | #define INTERRUPT_EP 3 |
||
21 | #define CONFIG_NUM 1 |
||
22 | |||
23 | class CamStateHandlers : public EOSStateHandlers |
||
24 | { |
||
25 | enum CamStates { stInitial, stDisconnected, stConnected }; |
||
26 | CamStates stateConnected; |
||
27 | |||
28 | public: |
||
29 | CamStateHandlers() : stateConnected(stInitial) |
||
30 | { |
||
31 | }; |
||
32 | |||
33 | virtual void OnDeviceDisconnectedState(PTP *ptp); |
||
34 | virtual void OnDeviceInitializedState(PTP *ptp); |
||
35 | }; |
||
36 | |||
37 | CamStateHandlers CamStates; |
||
38 | SimpleTimer PTPPollTimer; |
||
39 | CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates); |
||
40 | |||
41 | |||
42 | void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp) |
||
43 | { |
||
44 | if (stateConnected == stConnected || stateConnected == stInitial) |
||
45 | { |
||
46 | stateConnected = stDisconnected; |
||
47 | PTPPollTimer.Disable(); |
||
48 | Notify(PSTR("\r\nDevice disconnected.\r\n")); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | void CamStateHandlers::OnDeviceInitializedState(PTP *ptp) |
||
53 | { |
||
54 | if (stateConnected == stDisconnected) |
||
55 | { |
||
56 | stateConnected = stConnected; |
||
57 | PTPPollTimer.Enable(); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | void OnPTPPollTimer() |
||
62 | { |
||
63 | Serial.println("\r\n"); |
||
64 | |||
65 | HexDump hex; |
||
66 | Eos.EventCheck(&hex); |
||
67 | } |
||
68 | |||
69 | void setup() |
||
70 | { |
||
71 | Serial.begin( 115200 ); |
||
72 | Serial.println("Start"); |
||
73 | Eos.Setup(); |
||
74 | delay( 200 ); |
||
75 | PTPPollTimer.Set(OnPTPPollTimer, 1000); |
||
76 | } |
||
77 | |||
78 | void loop() |
||
79 | { |
||
80 | Eos.Task(); |
||
81 | PTPPollTimer.Run(); |
||
82 | } |
||
83 |