Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | /* Exposure compensation change 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 | #include <ptp.h> |
||
11 | #include <canoneos.h> |
||
12 | #include <qep_port.h> |
||
13 | |||
14 | #include "hdrcapture.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 EOSStateHandlers |
||
25 | { |
||
26 | enum CamStates { stInitial, stDisconnected, stConnected }; |
||
27 | CamStates stateConnected; |
||
28 | |||
29 | public: |
||
30 | CamStateHandlers() : stateConnected(stInitial) |
||
31 | { |
||
32 | }; |
||
33 | |||
34 | virtual void OnDeviceDisconnectedState(PTP *ptp); |
||
35 | virtual void OnDeviceInitializedState(PTP *ptp); |
||
36 | }; |
||
37 | |||
38 | CamStateHandlers CamStates; |
||
39 | CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates); |
||
40 | HDRCapture hdrCapture(Eos); |
||
41 | QEvent msTick; |
||
42 | QEvent secTick; |
||
43 | |||
44 | void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp) |
||
45 | { |
||
46 | if (stateConnected == stConnected || stateConnected == stInitial) |
||
47 | { |
||
48 | stateConnected = stDisconnected; |
||
49 | Notify(PSTR("Camera disconnected\r\n")); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | void CamStateHandlers::OnDeviceInitializedState(PTP *ptp) |
||
54 | { |
||
55 | if (stateConnected == stDisconnected) |
||
56 | { |
||
57 | stateConnected = stConnected; |
||
58 | |||
59 | Serial.println("Connected"); |
||
60 | |||
61 | SetEvt setEvt; |
||
62 | setEvt.sig = RUN_SIG; |
||
63 | |||
64 | hdrCapture.PostEvent(&setEvt); |
||
65 | } |
||
66 | hdrCapture.Run(); |
||
67 | hdrCapture.PostEvent(&msTick); // post TICK_MILLIS_SIG event |
||
68 | } |
||
69 | |||
70 | void setup() |
||
71 | { |
||
72 | Serial.begin( 115200 ); |
||
73 | Serial.println("Start"); |
||
74 | |||
75 | Eos.Setup(); |
||
76 | delay( 200 ); |
||
77 | |||
78 | hdrCapture.init(); |
||
79 | |||
80 | SetEvt setEvt; |
||
81 | |||
82 | setEvt.sig = SET_FRAMES_SIG; |
||
83 | setEvt.value = 3; |
||
84 | |||
85 | hdrCapture.dispatch(&setEvt); |
||
86 | |||
87 | setEvt.sig = SET_FRAME_TIMEOUT_SIG; |
||
88 | setEvt.value = 5; |
||
89 | |||
90 | hdrCapture.dispatch(&setEvt); |
||
91 | |||
92 | setEvt.sig = SET_SELF_TIMEOUT_SIG; |
||
93 | setEvt.value = 3; |
||
94 | |||
95 | hdrCapture.dispatch(&setEvt); |
||
96 | |||
97 | SetBktEvt setBktEvt; |
||
98 | setBktEvt.sig = SET_BRACKETING_SIG; |
||
99 | setBktEvt.step = 2; |
||
100 | setBktEvt.negative = 3; |
||
101 | setBktEvt.positive = 9; |
||
102 | |||
103 | hdrCapture.dispatch(&setBktEvt); |
||
104 | |||
105 | |||
106 | msTick.sig = TICK_MILLIS_SIG; |
||
107 | } |
||
108 | |||
109 | void loop() |
||
110 | { |
||
111 | Eos.Task(); |
||
112 | delay(1); |
||
113 | } |
||
114 |