Skip to content

Commit

Permalink
add M240 code for time-lapse photography
Browse files Browse the repository at this point in the history
  • Loading branch information
eclecticc committed Aug 22, 2011
1 parent e80b5bc commit 8423b62
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Sprinter/Sprinter.pde
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Configuration.h"
#include "pins.h"
#include "Sprinter.h"
#include <util/delay.h>

#ifdef SDSUPPORT
#include "SdFat.h"
Expand Down Expand Up @@ -55,6 +56,7 @@
// M190 - Wait for bed current temp to reach target temp.
// M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
// M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000)
// M240 - Trigger a camera to take a photograph


//Stepper Movement Variables
Expand Down Expand Up @@ -339,6 +341,12 @@ void setup()

#endif

#ifdef PHOTOGRAPH_PIN
#if (PHOTOGRAPH_PIN > -1)
SET_OUTPUT(PHOTOGRAPH_PIN);
WRITE(PHOTOGRAPH_PIN, LOW);
#endif
#endif
}


Expand Down Expand Up @@ -903,6 +911,29 @@ inline void process_commands()
}
break;
#endif
case 240: // M240
// Triggers a camera by emulating a Canon RC-1 Remote
// Data from: http://www.doc-diy.net/photo/rc-1_hacked/
#ifdef PHOTOGRAPH_PIN
#if (PHOTOGRAPH_PIN > -1)
#define NUM_PULSES 16
#define PULSE_LENGTH 0.01524
for(int i=0; i < NUM_PULSES; i++) {
WRITE(PHOTOGRAPH_PIN, HIGH);
_delay_ms(PULSE_LENGTH);
WRITE(PHOTOGRAPH_PIN, LOW);
_delay_ms(PULSE_LENGTH);
}
_delay_ms(7.33);
for(int i=0; i < NUM_PULSES; i++) {
WRITE(PHOTOGRAPH_PIN, HIGH);
_delay_ms(PULSE_LENGTH);
WRITE(PHOTOGRAPH_PIN, LOW);
_delay_ms(PULSE_LENGTH);
}
#endif
#endif
break;
}

}
Expand Down
1 change: 1 addition & 0 deletions Sprinter/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@
#define MAX6675_SS 49
#endif

#define PHOTOGRAPH_PIN 23

#endif
/****************************************************************************************
Expand Down

0 comments on commit 8423b62

Please sign in to comment.