Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | /* Canon Powershot Device Property Parser */ |
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 <ptpdebug.h> |
||
13 | #include <canonps.h> |
||
14 | #include <ptpdpparser.h> |
||
15 | #include <psvaluetitles.h> |
||
16 | #include "devpropparser.h" |
||
17 | |||
18 | #define DEV_ADDR 1 |
||
19 | |||
20 | // Canon PowerShot S3 IS |
||
21 | #define DATA_IN_EP 1 |
||
22 | #define DATA_OUT_EP 2 |
||
23 | #define INTERRUPT_EP 3 |
||
24 | #define CONFIG_NUM 1 |
||
25 | |||
26 | class CamStateHandlers : public PSStateHandlers |
||
27 | { |
||
28 | enum CamStates { stInitial, stDisconnected, stConnected }; |
||
29 | CamStates stateConnected; |
||
30 | |||
31 | public: |
||
32 | CamStateHandlers() : stateConnected(stInitial) |
||
33 | { |
||
34 | }; |
||
35 | |||
36 | virtual void OnDeviceDisconnectedState(PTP *ptp); |
||
37 | virtual void OnDeviceInitializedState(PTP *ptp); |
||
38 | }; |
||
39 | |||
40 | CamStateHandlers CamStates; |
||
41 | CanonPS Ps(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates); |
||
42 | |||
43 | void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp) |
||
44 | { |
||
45 | if (stateConnected == stConnected || stateConnected == stInitial) |
||
46 | { |
||
47 | stateConnected = stDisconnected; |
||
48 | Notify(PSTR("Camera disconnected\r\n")); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | void CamStateHandlers::OnDeviceInitializedState(PTP *ptp) |
||
53 | { |
||
54 | if (stateConnected == stDisconnected || stateConnected == stInitial) |
||
55 | { |
||
56 | stateConnected = stConnected; |
||
57 | |||
58 | uint16_t prefix = 0xD000; |
||
59 | |||
60 | uint16_t shoot_mode[] = {0x01, 0x02, 0x03, 0x04}; |
||
61 | |||
62 | for (uint8_t i=0; i<4; i++) |
||
63 | { |
||
64 | Ps.SetDevicePropValue(PS_DPC_ShootingMode, (uint16_t)shoot_mode[i]); |
||
65 | delay(10); |
||
66 | |||
67 | Notify(PSTR("Mode:")); |
||
68 | PrintValueTitle<uint8_t, VT_MODE, VT_MODE_COUNT, VT_MODE_TEXT_LEN>((PTP*)ptp, PS_DPC_ShootingMode, ModeTitles); |
||
69 | Notify(PSTR("\r\n")); |
||
70 | |||
71 | for (uint8_t j=0; j<128; j++) |
||
72 | { |
||
73 | HexDump dmp; |
||
74 | |||
75 | if (Ps.GetDevicePropDesc((prefix | j), &dmp) == PTP_RC_OK) |
||
76 | { |
||
77 | Notify(PSTR("\r\n")); |
||
78 | |||
79 | DevPropParser prs; |
||
80 | |||
81 | if (Ps.GetDevicePropDesc((prefix | j), &prs) == PTP_RC_OK) |
||
82 | Notify(PSTR("\r\n")); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | Notify(PSTR("\r\n")); |
||
87 | |||
88 | } // for (uint8_t i=0; i<4; i++) |
||
89 | |||
90 | } // if (stateConnected == stDisconnected || stateConnected == stInitial) |
||
91 | } |
||
92 | |||
93 | void setup() |
||
94 | { |
||
95 | Serial.begin( 115200 ); |
||
96 | Serial.println("Start"); |
||
97 | Ps.Setup(); |
||
98 | delay( 200 ); |
||
99 | } |
||
100 | |||
101 | void loop() |
||
102 | { |
||
103 | Ps.Task(); |
||
104 | } |
||
105 |