forked from andaluri/multiCameraIrControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiCameraIrControl.cpp
364 lines (337 loc) · 7.92 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
/*******************************************
*
* 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
*
********************************************/
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "multiCameraIrControl.h"
void wait(unsigned long time){
unsigned long start = micros();
while(micros()-start<=time){
}
}
void high(unsigned int time, int freq, int pinLED){
int pause = (1000/freq/2)-4;
unsigned long start = micros();
while(micros()-start<=time){
digitalWrite(pinLED,HIGH);
delayMicroseconds(pause);
digitalWrite(pinLED,LOW);
delayMicroseconds(pause);
}
}
Nikon::Nikon(int pin)
{
pinMode(pin, OUTPUT);
_pin = pin;
_freq = 40;
}
void Nikon::shutterNow()
{
high(2000,_freq,_pin);
wait(27830);
high(390,_freq,_pin);
wait(1580);
high(410,_freq,_pin);
wait(3580);
high(400,_freq,_pin);
}
Pentax::Pentax(int pin)
{
pinMode(pin, OUTPUT);
_pin = pin;
_freq = 38;
}
void Pentax::shutterNow()
{
high(13000,_freq,_pin);
wait(3000);
for (int i=0;i<7;i++){
high(1000,_freq,_pin);
wait(1000);
};
}
void Pentax::toggleFocus()
{
high(13000,_freq,_pin);
wait(3000);
for (int i=0;i<5;i++){
high(1000,_freq,_pin);
wait(1000);
};
high(1000,_freq,_pin);
wait(3000);
high(1000,_freq,_pin);
}
Olympus::Olympus(int pin)
{
pinMode(pin, OUTPUT);
_pin = pin;
_freq = 40;
}
void Olympus::shutterNow()
{
bool _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 };
high(8972,_freq,_pin);
wait(4384);
high(624,_freq,_pin);
for (int i=0;i<sizeof(_seq);i++){
if (_seq[i]==0){
wait(488);
high(600,_freq,_pin);
}
else{
wait(1600);
high(600,_freq,_pin);
}
};
}
void Olympus::zoomin(unsigned int pct)
{
bool _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 };
high(9000,_freq,_pin);
wait(4500);
high(500,_freq,_pin);
for (int i=0;i<sizeof(_seq);i++){
if (_seq[i]==0){
wait(500);
high(500,_freq,_pin);
}
else{
wait(1500);
high(500,_freq,_pin);
}
};
wait(40000);
if (pct>100) pct = 100;
pct = (pct*52)/100 + 1;
for (int i=1; i<pct; i++)
{
high(9000,_freq,_pin);
wait(2000);
high(500,_freq,_pin);
wait(96000);
}
}
void Olympus::zoomout(unsigned int pct)
{
bool _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 };
high(9000,_freq,_pin); //
wait(4500);
high(500,_freq,_pin);
for (int i=0;i<sizeof(_seq);i++){
if (_seq[i]==0){
wait(500);
high(500,_freq,_pin);
}
else{
wait(1500);
high(500,_freq,_pin);
}
};
wait(40000);
if (pct>100) pct = 100;
pct = (pct*70)/100 + 1;
for (int i=1; i<pct; i++)
{
high(9000,_freq,_pin);
wait(2000);
high(500,_freq,_pin);
wait(96000);
}
}
Minolta::Minolta(int pin)
{
pinMode(pin, OUTPUT);
_pin = pin;
_freq = 38;
}
void Minolta::shutterNow()
{
bool _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 };
high(3750,_freq,_pin);
wait(1890);
for (int i=0;i<sizeof(_seq);i++){
if (_seq[i]==0){
high(456,_freq,_pin);
wait(487);
}
else{
high(456,_freq,_pin);
wait(1430);
}
};
}
void Minolta::shutterDelayed()
{
bool _seqDelayed[] = {
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 };
high(3750,_freq,_pin);
wait(1890);
for (int i=0;i<sizeof(_seqDelayed);i++){
if (_seqDelayed[i]==0){
high(456,_freq,_pin);
wait(487);
}
else{
high(456,_freq,_pin);
wait(1430);
}
};
}
Sony::Sony(int pin)
{
pinMode(pin, OUTPUT);
_pin = pin;
_freq = 40;
}
void Sony::shutterNow()
{
bool _seq[] = {
1,0,1,1,0,1,0,0,1,0,1,1,1,0,0,0,1,1,1,1 };
for (int j=0;j<3;j++) {
high(2320,_freq,_pin);
wait(650);
for (int i=0;i<sizeof(_seq);i++){
if (_seq[i]==0){
high(575,_freq,_pin);
wait(650);
}
else{
high(1175,_freq,_pin);
wait(650);
}
}
wait(10000);
}
}
void Sony::shutterDelayed()
{
bool _seqDelayed[] = {
1,1,1,0,1,1,0,0,1,0,1,1,1,0,0,0,1,1,1,1 };
for (int j=0;j<3;j++) {
high(2320,_freq,_pin);
wait(650);
for (int i=0;i<sizeof(_seqDelayed);i++){
if (_seqDelayed[i]==0){
high(575,_freq,_pin);
wait(650);
}
else{
high(1175,_freq,_pin);
wait(650);
}
}
wait(10000);
}
}
void Sony::toggleVideo()
{
bool _seqToggle[] = {
0,0,0,1,0,0,1,0,1,0,1,1,1,0,0,0,1,1,1,1 };
for (int j=0;j<3;j++) {
high(2320,_freq,_pin);
wait(650);
for (int i=0;i<sizeof(_seqToggle);i++){
if (_seqToggle[i]==0){
high(575,_freq,_pin);
wait(650);
}
else{
high(1175,_freq,_pin);
wait(650);
}
}
wait(10000);
}
}
Canon::Canon(int pin)
{
pinMode(pin, OUTPUT);
_pin = pin;
_freq = 33;
}
void Canon::shutterNow()
{
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::shutterDelayed()
{
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);
}
}
CanonWLDC100::CanonWLDC100(int pin)
{
pinMode(pin, OUTPUT);
_pin = pin;
_freq = 38;
}
void CanonWLDC100::shutterNow()
{
bool _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};
high(9042,_freq,_pin);
wait(4379);
for (int i=0;i<sizeof(_seq);i++){
if (_seq[i]==0){
high(612,_freq,_pin);
wait(512);
}
else{
high(612,_freq,_pin);
wait(1621);
}
};
high(599,_freq,_pin);
}