Browse Source

Merge pull request #829 from blddk/Marlin_v1

Added CHDK support
ErikZalm 10 years ago
parent
commit
1f895844ac
2 changed files with 42 additions and 13 deletions
  1. 3
    0
      Marlin/Configuration_adv.h
  2. 39
    13
      Marlin/Marlin_main.cpp

+ 3
- 0
Marlin/Configuration_adv.h View File

@@ -279,6 +279,9 @@
279 279
 //=============================Additional Features===========================
280 280
 //===========================================================================
281 281
 
282
+//#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
283
+#define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
284
+
282 285
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
283 286
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
284 287
 

+ 39
- 13
Marlin/Marlin_main.cpp View File

@@ -314,6 +314,12 @@ bool Stopped=false;
314 314
 bool CooldownNoWait = true;
315 315
 bool target_direction;
316 316
 
317
+//Insert variables if CHDK is defined
318
+#ifdef CHDK
319
+unsigned long chdkHigh = 0;
320
+boolean chdkActive = false;
321
+#endif
322
+
317 323
 //===========================================================================
318 324
 //=============================Routines======================================
319 325
 //===========================================================================
@@ -2588,23 +2594,33 @@ void process_commands()
2588 2594
     #endif //PIDTEMP
2589 2595
     case 240: // M240  Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
2590 2596
      {
2591
-      #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
2592
-        const uint8_t NUM_PULSES=16;
2593
-        const float PULSE_LENGTH=0.01524;
2594
-        for(int i=0; i < NUM_PULSES; i++) {
2595
-          WRITE(PHOTOGRAPH_PIN, HIGH);
2596
-          _delay_ms(PULSE_LENGTH);
2597
-          WRITE(PHOTOGRAPH_PIN, LOW);
2598
-          _delay_ms(PULSE_LENGTH);
2597
+     	#ifdef CHDK
2598
+       
2599
+         SET_OUTPUT(CHDK);
2600
+         WRITE(CHDK, HIGH);
2601
+         chdkHigh = millis();
2602
+         chdkActive = true;
2603
+       
2604
+       #else
2605
+     	
2606
+      	#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
2607
+	const uint8_t NUM_PULSES=16;
2608
+	const float PULSE_LENGTH=0.01524;
2609
+	for(int i=0; i < NUM_PULSES; i++) {
2610
+        WRITE(PHOTOGRAPH_PIN, HIGH);
2611
+        _delay_ms(PULSE_LENGTH);
2612
+        WRITE(PHOTOGRAPH_PIN, LOW);
2613
+        _delay_ms(PULSE_LENGTH);
2599 2614
         }
2600 2615
         delay(7.33);
2601 2616
         for(int i=0; i < NUM_PULSES; i++) {
2602
-          WRITE(PHOTOGRAPH_PIN, HIGH);
2603
-          _delay_ms(PULSE_LENGTH);
2604
-          WRITE(PHOTOGRAPH_PIN, LOW);
2605
-          _delay_ms(PULSE_LENGTH);
2617
+        WRITE(PHOTOGRAPH_PIN, HIGH);
2618
+        _delay_ms(PULSE_LENGTH);
2619
+        WRITE(PHOTOGRAPH_PIN, LOW);
2620
+        _delay_ms(PULSE_LENGTH);
2606 2621
         }
2607
-      #endif
2622
+      	#endif
2623
+      #endif //chdk end if
2608 2624
      }
2609 2625
     break;
2610 2626
 #ifdef DOGLCD
@@ -3353,6 +3369,16 @@ void manage_inactivity()
3353 3369
       }
3354 3370
     }
3355 3371
   }
3372
+  
3373
+  #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
3374
+    if (chdkActive)
3375
+    {
3376
+      chdkActive = false;
3377
+      if (millis()-chdkHigh < CHDK_DELAY) return;
3378
+      WRITE(CHDK, LOW);
3379
+    }
3380
+  #endif
3381
+  
3356 3382
   #if defined(KILL_PIN) && KILL_PIN > -1
3357 3383
     if( 0 == READ(KILL_PIN) )
3358 3384
       kill();

Loading…
Cancel
Save