-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathe_Shutter.ino
39 lines (32 loc) · 946 Bytes
/
e_Shutter.ino
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
// Interface to CANON Timer Remote Controller TC-80N3
// Also works with similar remote shutters.
//
// Note: For simple mechanical switches, please use USE_SWITCHES instead
// (Simple switches make chatters so software debouncing is necessary).
#ifdef USE_SHUTTER
// Workaround the bug in attachInterrupt():
// Calling attachInterrupt() first time causes the interrupt handler
// to be called once. Maybe pending/nonprocessed interrupts get alive again
// and fire the interrupt routine.
volatile boolean pendingInterrupts_Shutter = true;
void shutterHandler()
{
if (!pendingInterrupts_Shutter) {
if (digitalRead(SHUTTER_PIN) == LOW) {
startRecording();
} else {
stopRecording();
}
}
}
void setupShutter()
{
pinMode(SHUTTER_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(SHUTTER_PIN), shutterHandler, CHANGE);
pendingInterrupts_Shutter = false;
}
#else
void setupShutter()
{
}
#endif