Browse Source

Move dwell to gcode

Scott Lahteine 7 years ago
parent
commit
51f195e698

+ 3
- 14
Marlin/src/Marlin.cpp View File

163
 #endif
163
 #endif
164
 
164
 
165
 // Inactivity shutdown
165
 // Inactivity shutdown
166
-millis_t previous_cmd_ms = 0;
167
 static millis_t max_inactive_time = 0;
166
 static millis_t max_inactive_time = 0;
168
 static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
167
 static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
169
 
168
 
366
  ***************** GCode Handlers *****************
365
  ***************** GCode Handlers *****************
367
  **************************************************/
366
  **************************************************/
368
 
367
 
369
-#if ENABLED(ARC_SUPPORT)
370
-  #include "gcode/motion/G2_G3.h"
371
-#endif
372
-
373
-void dwell(millis_t time) {
374
-  gcode.refresh_cmd_timeout();
375
-  time += previous_cmd_ms;
376
-  while (PENDING(millis(), time)) idle();
377
-}
378
-
379
 #include "gcode/motion/G4.h"
368
 #include "gcode/motion/G4.h"
380
 
369
 
381
 #if ENABLED(BEZIER_CURVE_SUPPORT)
370
 #if ENABLED(BEZIER_CURVE_SUPPORT)
882
 
871
 
883
   const millis_t ms = millis();
872
   const millis_t ms = millis();
884
 
873
 
885
-  if (max_inactive_time && ELAPSED(ms, previous_cmd_ms + max_inactive_time)) {
874
+  if (max_inactive_time && ELAPSED(ms, gcode.previous_cmd_ms + max_inactive_time)) {
886
     SERIAL_ERROR_START();
875
     SERIAL_ERROR_START();
887
     SERIAL_ECHOLNPAIR(MSG_KILL_INACTIVE_TIME, parser.command_ptr);
876
     SERIAL_ECHOLNPAIR(MSG_KILL_INACTIVE_TIME, parser.command_ptr);
888
     kill(PSTR(MSG_KILLED));
877
     kill(PSTR(MSG_KILLED));
895
     #define MOVE_AWAY_TEST true
884
     #define MOVE_AWAY_TEST true
896
   #endif
885
   #endif
897
 
886
 
898
-  if (MOVE_AWAY_TEST && stepper_inactive_time && ELAPSED(ms, previous_cmd_ms + stepper_inactive_time)
887
+  if (MOVE_AWAY_TEST && stepper_inactive_time && ELAPSED(ms, gcode.previous_cmd_ms + stepper_inactive_time)
899
       && !ignore_stepper_queue && !planner.blocks_queued()) {
888
       && !ignore_stepper_queue && !planner.blocks_queued()) {
900
     #if ENABLED(DISABLE_INACTIVE_X)
889
     #if ENABLED(DISABLE_INACTIVE_X)
901
       disable_X();
890
       disable_X();
965
   #endif
954
   #endif
966
 
955
 
967
   #if ENABLED(EXTRUDER_RUNOUT_PREVENT)
956
   #if ENABLED(EXTRUDER_RUNOUT_PREVENT)
968
-    if (ELAPSED(ms, previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)
957
+    if (ELAPSED(ms, gcode.previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)
969
       && thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) {
958
       && thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) {
970
       #if ENABLED(SWITCHING_EXTRUDER)
959
       #if ENABLED(SWITCHING_EXTRUDER)
971
         const bool oldstatus = E0_ENABLE_READ;
960
         const bool oldstatus = E0_ENABLE_READ;

+ 2
- 2
Marlin/src/gcode/control/M3-M5.h View File

52
  */
52
  */
53
 
53
 
54
 // Wait for spindle to come up to speed
54
 // Wait for spindle to come up to speed
55
-inline void delay_for_power_up() { dwell(SPINDLE_LASER_POWERUP_DELAY); }
55
+inline void delay_for_power_up() { gcode.dwell(SPINDLE_LASER_POWERUP_DELAY); }
56
 
56
 
57
 // Wait for spindle to stop turning
57
 // Wait for spindle to stop turning
58
-inline void delay_for_power_down() { dwell(SPINDLE_LASER_POWERDOWN_DELAY); }
58
+inline void delay_for_power_down() { gcode.dwell(SPINDLE_LASER_POWERDOWN_DELAY); }
59
 
59
 
60
 /**
60
 /**
61
  * ocr_val_mode() is used for debugging and to get the points needed to compute the RPM vs ocr_val line
61
  * ocr_val_mode() is used for debugging and to get the points needed to compute the RPM vs ocr_val line

+ 11
- 1
Marlin/src/gcode/gcode.cpp View File

31
 #include "parser.h"
31
 #include "parser.h"
32
 #include "queue.h"
32
 #include "queue.h"
33
 #include "../module/motion.h"
33
 #include "../module/motion.h"
34
-#include "../module/printcounter.h"
35
 
34
 
36
 #if ENABLED(PRINTCOUNTER)
35
 #if ENABLED(PRINTCOUNTER)
37
   #include "../module/printcounter.h"
36
   #include "../module/printcounter.h"
38
 #endif
37
 #endif
39
 
38
 
39
+#include "../Marlin.h" // for idle()
40
+
40
 uint8_t GcodeSuite::target_extruder;
41
 uint8_t GcodeSuite::target_extruder;
41
 millis_t GcodeSuite::previous_cmd_ms;
42
 millis_t GcodeSuite::previous_cmd_ms;
42
 
43
 
99
   #endif
100
   #endif
100
 }
101
 }
101
 
102
 
103
+/**
104
+ * Dwell waits immediately. It does not synchronize. Use M400 instead of G4
105
+ */
106
+void GcodeSuite::dwell(millis_t time) {
107
+  refresh_cmd_timeout();
108
+  time += previous_cmd_ms;
109
+  while (PENDING(millis(), time)) idle();
110
+}
111
+
102
 //
112
 //
103
 // Placeholders for non-migrated codes
113
 // Placeholders for non-migrated codes
104
 //
114
 //

+ 2
- 0
Marlin/src/gcode/gcode.h View File

299
     #define KEEPALIVE_STATE(n) NOOP
299
     #define KEEPALIVE_STATE(n) NOOP
300
   #endif
300
   #endif
301
 
301
 
302
+  void dwell(millis_t time);
303
+
302
 private:
304
 private:
303
 
305
 
304
   static void G0_G1(
306
   static void G0_G1(

+ 1
- 1
Marlin/src/gcode/lcd/M0_M1.h View File

67
   gcode.refresh_cmd_timeout();
67
   gcode.refresh_cmd_timeout();
68
 
68
 
69
   if (ms > 0) {
69
   if (ms > 0) {
70
-    ms += previous_cmd_ms;  // wait until this time for a click
70
+    ms += gcode.previous_cmd_ms;  // wait until this time for a click
71
     while (PENDING(millis(), ms) && wait_for_user) idle();
71
     while (PENDING(millis(), ms) && wait_for_user) idle();
72
   }
72
   }
73
   else {
73
   else {

+ 1
- 1
Marlin/src/gcode/motion/G4.h View File

33
 
33
 
34
   if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
34
   if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
35
 
35
 
36
-  dwell(dwell_ms);
36
+  gcode.dwell(dwell_ms);
37
 }
37
 }

+ 5
- 1
Marlin/src/module/tool_change.cpp View File

30
 
30
 
31
 #include "../inc/MarlinConfig.h"
31
 #include "../inc/MarlinConfig.h"
32
 
32
 
33
+#if ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
34
+  #include "../gcode/gcode.h" // for dwell()
35
+#endif
36
+
33
 #if ENABLED(SWITCHING_EXTRUDER)
37
 #if ENABLED(SWITCHING_EXTRUDER)
34
 
38
 
35
   #if EXTRUDERS > 3
39
   #if EXTRUDERS > 3
74
       default: OUT_WRITE(SOL0_PIN, state); break;
78
       default: OUT_WRITE(SOL0_PIN, state); break;
75
     }
79
     }
76
     #if PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
80
     #if PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
77
-      dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY);
81
+      gcode.dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY);
78
     #endif
82
     #endif
79
   }
83
   }
80
 
84
 

Loading…
Cancel
Save