Browse Source

added m240 photography support. default off

Bernhard 12 years ago
parent
commit
212515148e
2 changed files with 42 additions and 1 deletions
  1. 5
    0
      Marlin/Configuration.h
  2. 37
    1
      Marlin/Marlin.pde

+ 5
- 0
Marlin/Configuration.h View File

@@ -363,6 +363,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
363 363
 
364 364
 const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
365 365
 
366
+
367
+// M240  Triggers a camera by emulating a Canon RC-1 Remote
368
+// Data from: http://www.doc-diy.net/photo/rc-1_hacked/
369
+// #define PHOTOGRAPH_PIN     23
370
+
366 371
 //===========================================================================
367 372
 //=============================Buffers           ============================
368 373
 //===========================================================================

+ 37
- 1
Marlin/Marlin.pde View File

@@ -41,6 +41,7 @@
41 41
 #include "motion_control.h"
42 42
 #include "cardreader.h"
43 43
 #include "watchdog.h"
44
+#include <util/delay.h>
44 45
 
45 46
 
46 47
 
@@ -109,6 +110,7 @@
109 110
 // M205 -  advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
110 111
 // M206 - set additional homeing offset
111 112
 // M220 - set speed factor override percentage S:factor in percent
113
+// M240 - Trigger a camera to take a photograph
112 114
 // M301 - Set PID parameters P I and D
113 115
 // M302 - Allow cold extrudes
114 116
 // M400 - Finish all moves
@@ -227,7 +229,15 @@ void enquecommand(const char *cmd)
227 229
     buflen += 1;
228 230
   }
229 231
 }
230
-
232
+void setup_photpin()
233
+{
234
+  #ifdef PHOTOGRAPH_PIN
235
+    #if (PHOTOGRAPH_PIN > -1)
236
+    SET_OUTPUT(PHOTOGRAPH_PIN);
237
+    WRITE(PHOTOGRAPH_PIN, LOW);
238
+    #endif
239
+  #endif 
240
+}
231 241
 void setup()
232 242
 { 
233 243
   MSerial.begin(BAUDRATE);
@@ -255,6 +265,7 @@ void setup()
255 265
   plan_init();  // Initialize planner;
256 266
   st_init();    // Initialize stepper;
257 267
   wd_init();
268
+  setup_photpin();
258 269
 }
259 270
 
260 271
 
@@ -1064,6 +1075,8 @@ FORCE_INLINE void process_commands()
1064 1075
       }
1065 1076
     }
1066 1077
     break;
1078
+    
1079
+    
1067 1080
 
1068 1081
     #ifdef PIDTEMP
1069 1082
     case 301: // M301
@@ -1089,6 +1102,29 @@ FORCE_INLINE void process_commands()
1089 1102
       }
1090 1103
       break;
1091 1104
     #endif //PIDTEMP
1105
+    case 240: // M240  Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
1106
+     {
1107
+      #ifdef PHOTOGRAPH_PIN
1108
+        #if (PHOTOGRAPH_PIN > -1)
1109
+        const uint8_t NUM_PULSES=16;
1110
+        const float PULSE_LENGTH=0.01524;
1111
+        for(int i=0; i < NUM_PULSES; i++) {
1112
+          WRITE(PHOTOGRAPH_PIN, HIGH);
1113
+          _delay_ms(PULSE_LENGTH);
1114
+          WRITE(PHOTOGRAPH_PIN, LOW);
1115
+          _delay_ms(PULSE_LENGTH);
1116
+        }
1117
+        delay(7.33);
1118
+        for(int i=0; i < NUM_PULSES; i++) {
1119
+          WRITE(PHOTOGRAPH_PIN, HIGH);
1120
+          _delay_ms(PULSE_LENGTH);
1121
+          WRITE(PHOTOGRAPH_PIN, LOW);
1122
+          _delay_ms(PULSE_LENGTH);
1123
+        }
1124
+        #endif
1125
+      #endif
1126
+     }
1127
+    break;
1092 1128
       
1093 1129
     case 302: // finish all moves
1094 1130
     {

Loading…
Cancel
Save