chiark / gitweb /
added m240 photography support. default off
authorBernhard <bkubicek@x201.(none)>
Thu, 22 Dec 2011 11:11:39 +0000 (12:11 +0100)
committerBernhard <bkubicek@x201.(none)>
Thu, 22 Dec 2011 11:11:39 +0000 (12:11 +0100)
Marlin/Configuration.h
Marlin/Marlin.pde

index 3215a09c9713d91ff7a9bccc8c21b7fed69ae0e5..85fd389688f6694c1cf1c095c11402873855b538 100644 (file)
@@ -363,6 +363,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 
 const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
 
+
+// M240  Triggers a camera by emulating a Canon RC-1 Remote
+// Data from: http://www.doc-diy.net/photo/rc-1_hacked/
+// #define PHOTOGRAPH_PIN     23
+
 //===========================================================================
 //=============================Buffers           ============================
 //===========================================================================
index 1dbfb8694c1cbb215c8b74fd4e15678035b43ab5..c20ac49b626afb654727d3a230f460f4e3b3f380 100644 (file)
@@ -41,6 +41,7 @@
 #include "motion_control.h"
 #include "cardreader.h"
 #include "watchdog.h"
+#include <util/delay.h>
 
 
 
 // M205 -  advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
 // M206 - set additional homeing offset
 // M220 - set speed factor override percentage S:factor in percent
+// M240 - Trigger a camera to take a photograph
 // M301 - Set PID parameters P I and D
 // M302 - Allow cold extrudes
 // M400 - Finish all moves
@@ -227,7 +229,15 @@ void enquecommand(const char *cmd)
     buflen += 1;
   }
 }
-
+void setup_photpin()
+{
+  #ifdef PHOTOGRAPH_PIN
+    #if (PHOTOGRAPH_PIN > -1)
+    SET_OUTPUT(PHOTOGRAPH_PIN);
+    WRITE(PHOTOGRAPH_PIN, LOW);
+    #endif
+  #endif 
+}
 void setup()
 { 
   MSerial.begin(BAUDRATE);
@@ -255,6 +265,7 @@ void setup()
   plan_init();  // Initialize planner;
   st_init();    // Initialize stepper;
   wd_init();
+  setup_photpin();
 }
 
 
@@ -1064,6 +1075,8 @@ FORCE_INLINE void process_commands()
       }
     }
     break;
+    
+    
 
     #ifdef PIDTEMP
     case 301: // M301
@@ -1089,6 +1102,29 @@ FORCE_INLINE void process_commands()
       }
       break;
     #endif //PIDTEMP
+    case 240: // M240  Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
+     {
+      #ifdef PHOTOGRAPH_PIN
+        #if (PHOTOGRAPH_PIN > -1)
+        const uint8_t NUM_PULSES=16;
+        const float 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(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;
       
     case 302: // finish all moves
     {