-
Notifications
You must be signed in to change notification settings - Fork 1
/
multiCameraIrControl.cpp
341 lines (315 loc) · 7.43 KB
/
multiCameraIrControl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/*******************************************
*
* Name.......: cameraIrControl Library
* Description: A powerful Library to control easy various cameras via IR. Please check the project page and leave a comment.
* Author.....: Sebastian Setz
* Version....: 1.9
* Date.......: 2013-02-12
* Project....: http://sebastian.setz.name/arduino/my-libraries/multiCameraIrControl
* Contact....: http://Sebastian.Setz.name
* License....: This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to
* Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
* Keywords...: arduino, library, camera, ir, control, canon, nikon, olympus, minolta, sony, pentax, interval, timelapse
* History....: 2010-12-08 V1.0 - release
* 2010-12-09 V1.1
* 2010-12-16 V1.2
* 2011-01-01 V1.3
* 2011-01-04 V1.4 - making Sony function work, thank you Walter.
* 2011-01-25 V1.5 - making Olympus work, thank you Steve Stav.
* 2011-12-05 V1.6 - adding Olympus zoom, thank you again Steve! Refresh keywords.txt; Arduino 1.0 compatible
* 2011-12-07 V1.7 - repairing Canon function - thanks to Viktor
* 2013-02-11 V1.8 - adding toggleFocus for Pentax - thanks to Marcel Normann
* adding toggleVideo for Sony - thanks to InfinitR
* V1.9 - adding CanonWLDC100 support - thanks to ImaRH
*
********************************************/
#include "multiCameraIrControl.h"
void Camera::wait(unsigned int time) {
unsigned long start = micros();
while (micros() - start <= time) {
}
}
void Camera::high(unsigned int time) {
int pause = (1000 / _freq / 2) - 4;
unsigned long start = micros();
while (micros() - start <= time) {
digitalWrite(_pin, HIGH);
delayMicroseconds(pause);
digitalWrite(_pin, LOW);
delayMicroseconds(pause);
}
}
void Camera::begin()
{
pinMode(_pin, OUTPUT);
}
void Camera::shotDelayed()
{
// generic stub
}
void Camera::toggleFocus()
{
// generic stub
}
void Camera::toggleVideo()
{
// generic stub
}
// void Camera::zoomin()
// {
// // generic stub
// }
// void Camera::zoomout()
// {
// // generic stub
// }
void Nikon::shotNow()
{
high(2000);
wait(27830);
high(390);
wait(1580);
high(410);
wait(3580);
high(400);
}
void Pentax::shotNow()
{
high(13000);
wait(3000);
for (int i = 0; i < 7; i++) {
high(1000);
wait(1000);
};
}
void Pentax::toggleFocus()
{
high(13000);
wait(3000);
for (int i=0;i<5;i++){
high(1000);
wait(1000);
};
high(1000);
wait(3000);
high(1000);
}
void Olympus::shotNow()
{
const byte seq[] = { 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 };
const byte count = sizeof(seq) / sizeof(seq[0]);
high(8972);
wait(4384);
high(624);
for (int i = 0; i < count; i++) {
if (seq[i]) {
wait(1600);
high(600);
}
else {
wait(488);
high(500);
}
}
}
// void Olympus::zoomin(unsigned int pct)
// {
// const byte seq[] = {0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 };
// const byte count = sizeof(seq) / sizeof(seq[0]);
// high(9000);
// wait(4500);
// high(500);
// for (int i = 0; i < count; i++) {
// if (seq[i]) {
// wait(1500);
// high(500);
// }
// else{
// wait(500);
// high(500);
// }
// };
// wait(40000);
// if (pct>100) pct = 100;
// pct = (pct*52)/100 + 1;
// for (int i = 1; i < pct; i++)
// {
// high(9000);
// wait(2000);
// high(500);
// wait(96000);
// }
// }
// void Olympus::zoomout(unsigned int pct)
// {
// const byte seq[] = {0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1 };
// const byte count = sizeof(seq) / sizeof(seq[0]);
// high(9000); //
// wait(4500);
// high(500);
// for (int i = 0; i < count; i++) {
// if (seq[i]) {
// wait(1500);
// high(500);
// }
// else{
// wait(500);
// high(500);
// }
// };
// wait(40000);
// if (pct>100) pct = 100;
// pct = (pct*70)/100 + 1;
// for (int i = 1; i < pct; i++)
// {
// high(9000);
// wait(2000);
// high(500);
// wait(96000);
// }
// }
void Minolta::shotNow()
{
const byte seq[] = { 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 };
const byte count = sizeof(seq) / sizeof(seq[0]);
high(3750);
wait(1890);
for (int i = 0; i < count; i++) {
if (seq[i]) {
high(456);
wait(1430);
}
else {
high(456);
wait(487);
}
}
}
void Minolta::shotDelayed()
{
const byte seq[] = { 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
const byte count = sizeof(seq) / sizeof(seq[0]);
high(3750);
wait(1890);
for (int i = 0; i < count; i++) {
if (seq[i]) {
high(456);
wait(1430);
}
else {
high(456);
wait(487);
}
}
}
void Sony::shotNow()
{
const byte seq[] = { 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 };
const byte count = sizeof(seq) / sizeof(seq[0]);
for (int j=0;j<3;j++) {
high(2320);
wait(650);
for (int i = 0; i < count; i++) {
if (seq[i]) {
high(1175);
wait(650);
}
else {
high(575);
wait(650);
}
}
wait(10000);
}
}
void Sony::shotDelayed()
{
const byte seq[] = { 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 };
const byte count = sizeof(seq) / sizeof(seq[0]);
for (int j = 0; j < 3; j++) {
high(2320);
wait(650);
for (int i = 0; i < count; i++) {
if (seq[i]) {
high(1175);
wait(650);
}
else {
high(575);
wait(650);
}
}
wait(10000);
}
}
void Sony::toggleVideo()
{
const byte seq[] = { 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 };
const byte count = sizeof(seq) / sizeof(seq[0]);
for (int j = 0; j < 3; j++) {
high(2320);
wait(650);
for (int i = 0; i < count; i++) {
if (seq[i]) {
high(1175);
wait(650);
}
else {
high(575);
wait(650);
}
}
wait(10000);
}
}
void Canon::shotNow()
{
for(int i=0; i<16; i++) {
digitalWrite(_pin, HIGH);
delayMicroseconds(11);
digitalWrite(_pin,LOW);
delayMicroseconds(11);
}
delayMicroseconds(7330);
for(int i=0; i<16; i++) {
digitalWrite(_pin,HIGH);
delayMicroseconds(11);
digitalWrite(_pin,LOW);
delayMicroseconds(11);
}
}
void Canon::shotDelayed()
{
for(int i=0; i<16; i++) {
digitalWrite(_pin, HIGH);
delayMicroseconds(11);
digitalWrite(_pin, LOW);
delayMicroseconds(11);
}
delayMicroseconds(5360);
for(int i=0; i<16; i++) {
digitalWrite(_pin, HIGH);
delayMicroseconds(11);
digitalWrite(_pin, LOW);
delayMicroseconds(11);
}
}
void CanonWLDC100::shotNow()
{
const byte seq[] = {0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1};
const byte count = sizeof(seq) / sizeof(seq[0]);
high(9042);
wait(4379);
for (int i = 0; i < count; i++) {
if (seq[i]) {
high(612);
wait(1621);
}
else{
high(612);
wait(512);
}
};
high(599);
}