From 765b2da3d431245e6f8b6e5c9bcfbf706b9e066e Mon Sep 17 00:00:00 2001 From: blddk Date: Mon, 10 Mar 2014 21:52:33 +0100 Subject: [PATCH 1/2] Added CHDK support Added so M240 can be used to trigger CHDK instead of sending an IR signal, see more about CHDK here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ --- Marlin/Configuration_adv.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index bca056f9b..316d7dae1 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -279,6 +279,9 @@ //=============================Additional Features=========================== //=========================================================================== +//#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/ +#define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again + #define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers? #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place. From 09af1b90b8b55eafcc3539aa1e8d08c48cee54f7 Mon Sep 17 00:00:00 2001 From: blddk Date: Mon, 10 Mar 2014 21:57:08 +0100 Subject: [PATCH 2/2] Added CHDK support Added CHDK support to take pictures instead of doing an IR command, see more about how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ --- Marlin/Marlin_main.cpp | 52 +++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index d62447071..bb8b30356 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -314,6 +314,12 @@ bool Stopped=false; bool CooldownNoWait = true; bool target_direction; +//Insert variables if CHDK is defined +#ifdef CHDK +unsigned long chdkHigh = 0; +boolean chdkActive = false; +#endif + //=========================================================================== //=============================Routines====================================== //=========================================================================== @@ -2588,23 +2594,33 @@ void process_commands() #endif //PIDTEMP case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { - #if defined(PHOTOGRAPH_PIN) && 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); + #ifdef CHDK + + SET_OUTPUT(CHDK); + WRITE(CHDK, HIGH); + chdkHigh = millis(); + chdkActive = true; + + #else + + #if defined(PHOTOGRAPH_PIN) && 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); + WRITE(PHOTOGRAPH_PIN, HIGH); + _delay_ms(PULSE_LENGTH); + WRITE(PHOTOGRAPH_PIN, LOW); + _delay_ms(PULSE_LENGTH); } - #endif + #endif + #endif //chdk end if } break; #ifdef DOGLCD @@ -3353,6 +3369,16 @@ void manage_inactivity() } } } + + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH + if (chdkActive) + { + chdkActive = false; + if (millis()-chdkHigh < CHDK_DELAY) return; + WRITE(CHDK, LOW); + } + #endif + #if defined(KILL_PIN) && KILL_PIN > -1 if( 0 == READ(KILL_PIN) ) kill();