Browse Source

Merge pull request #1864 from thinkyhead/is_running

IsStopped / IsRunning inline
Scott Lahteine 10 years ago
parent
commit
caa7734402
4 changed files with 35 additions and 31 deletions
  1. 3
    1
      Marlin/Marlin.h
  2. 25
    21
      Marlin/Marlin_main.cpp
  3. 6
    8
      Marlin/planner.cpp
  4. 1
    1
      Marlin/temperature.cpp

+ 3
- 1
Marlin/Marlin.h View File

@@ -219,7 +219,9 @@ void Stop();
219 219
   void filrunout();
220 220
 #endif
221 221
 
222
-bool IsStopped();
222
+extern bool Running;
223
+inline bool IsRunning() { return  Running; }
224
+inline bool IsStopped() { return !Running; }
223 225
 
224 226
 bool enquecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full
225 227
 void enquecommands_P(const char *cmd); //put one or many ASCII commands at the end of the current buffer, read from flash

+ 25
- 21
Marlin/Marlin_main.cpp View File

@@ -202,6 +202,16 @@
202 202
   CardReader card;
203 203
 #endif
204 204
 
205
+bool Running = true;
206
+
207
+static float feedrate = 1500.0, next_feedrate, saved_feedrate;
208
+float current_position[NUM_AXIS] = { 0.0 };
209
+static float destination[NUM_AXIS] = { 0.0 };
210
+bool axis_known_position[3] = { false };
211
+
212
+static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
213
+static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
214
+
205 215
 float homing_feedrate[] = HOMING_FEEDRATE;
206 216
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
207 217
 int feedmultiply = 100; //100->1 200->2
@@ -210,23 +220,20 @@ int extruder_multiply[EXTRUDERS] = ARRAY_BY_EXTRUDERS(100, 100, 100, 100);
210 220
 bool volumetric_enabled = false;
211 221
 float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA);
212 222
 float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0, 1.0, 1.0, 1.0);
213
-float current_position[NUM_AXIS] = { 0.0 };
214 223
 float home_offset[3] = { 0 };
215 224
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
216 225
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
217
-bool axis_known_position[3] = { false };
226
+
218 227
 uint8_t active_extruder = 0;
219 228
 int fanSpeed = 0;
220 229
 bool cancel_heatup = false;
230
+
221 231
 const char errormagic[] PROGMEM = "Error:";
222 232
 const char echomagic[] PROGMEM = "echo:";
223 233
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
224
-static float destination[NUM_AXIS] = { 0 };
234
+
225 235
 static float offset[3] = { 0 };
226
-static float feedrate = 1500.0, next_feedrate, saved_feedrate;
227
-static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
228 236
 static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
229
-static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
230 237
 static int bufindr = 0;
231 238
 static int bufindw = 0;
232 239
 static int buflen = 0;
@@ -243,7 +250,6 @@ static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l
243 250
 unsigned long starttime = 0; ///< Print job start time
244 251
 unsigned long stoptime = 0;  ///< Print job stop time
245 252
 static uint8_t target_extruder;
246
-bool Stopped = false;
247 253
 bool CooldownNoWait = true;
248 254
 bool target_direction;
249 255
 
@@ -743,7 +749,7 @@ void get_command()
743 749
         case 1:
744 750
         case 2:
745 751
         case 3:
746
-          if (Stopped == true) {
752
+          if (IsStopped()) {
747 753
             SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
748 754
             LCD_MESSAGEPGM(MSG_STOPPED);
749 755
           }
@@ -1240,7 +1246,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
1240 1246
       if (z_min_endstop)
1241 1247
     #endif
1242 1248
       {
1243
-        if (!Stopped) {
1249
+        if (IsRunning()) {
1244 1250
           SERIAL_ERROR_START;
1245 1251
           SERIAL_ERRORLNPGM("Z-Probe failed to engage!");
1246 1252
           LCD_ALERTMESSAGEPGM("Err: ZPROBE");
@@ -1315,7 +1321,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
1315 1321
       if (!z_min_endstop)
1316 1322
     #endif
1317 1323
       {
1318
-        if (!Stopped) {
1324
+        if (IsRunning()) {
1319 1325
           SERIAL_ERROR_START;
1320 1326
           SERIAL_ERRORLNPGM("Z-Probe failed to retract!");
1321 1327
           LCD_ALERTMESSAGEPGM("Err: ZPROBE");
@@ -1650,7 +1656,7 @@ static void homeaxis(AxisEnum axis) {
1650 1656
  * G0, G1: Coordinated movement of X Y Z E axes
1651 1657
  */
1652 1658
 inline void gcode_G0_G1() {
1653
-  if (!Stopped) {
1659
+  if (IsRunning()) {
1654 1660
     get_coordinates(); // For X Y Z E F
1655 1661
     #ifdef FWRETRACT
1656 1662
       if (autoretract_enabled)
@@ -1675,7 +1681,7 @@ inline void gcode_G0_G1() {
1675 1681
  * G3: Counterclockwise Arc
1676 1682
  */
1677 1683
 inline void gcode_G2_G3(bool clockwise) {
1678
-  if (!Stopped) {
1684
+  if (IsRunning()) {
1679 1685
     get_arc_coordinates();
1680 1686
     prepare_arc_move(clockwise);
1681 1687
   }
@@ -4119,7 +4125,7 @@ inline void gcode_M303() {
4119 4125
   bool SCARA_move_to_cal(uint8_t delta_x, uint8_t delta_y) {
4120 4126
     //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
4121 4127
     //SERIAL_ECHOLN(" Soft endstops disabled ");
4122
-    if (! Stopped) {
4128
+    if (IsRunning()) {
4123 4129
       //get_coordinates(); // For X Y Z E F
4124 4130
       delta[X_AXIS] = delta_x;
4125 4131
       delta[Y_AXIS] = delta_y;
@@ -4617,7 +4623,7 @@ inline void gcode_M907() {
4617 4623
  * M999: Restart after being stopped
4618 4624
  */
4619 4625
 inline void gcode_M999() {
4620
-  Stopped = false;
4626
+  Running = true;
4621 4627
   lcd_reset_alert_level();
4622 4628
   gcode_LastN = Stopped_gcode_LastN;
4623 4629
   FlushSerialRequestResend();
@@ -4652,7 +4658,7 @@ inline void gcode_T() {
4652 4658
         // Save current position to return to after applying extruder offset
4653 4659
         set_destination_to_current();
4654 4660
         #ifdef DUAL_X_CARRIAGE
4655
-          if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && Stopped == false &&
4661
+          if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && IsRunning() &&
4656 4662
                 (delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder))) {
4657 4663
             // Park old head: 1) raise 2) move to park position 3) lower
4658 4664
             plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
@@ -4710,7 +4716,7 @@ inline void gcode_T() {
4710 4716
           sync_plan_position();
4711 4717
         #endif
4712 4718
         // Move to the old position if 'F' was in the parameters
4713
-        if (make_move && !Stopped) prepare_move();
4719
+        if (make_move && IsRunning()) prepare_move();
4714 4720
       }
4715 4721
 
4716 4722
       #ifdef EXT_SOLENOID
@@ -5877,7 +5883,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
5877 5883
 
5878 5884
   #ifdef DUAL_X_CARRIAGE
5879 5885
     // handle delayed move timeout
5880
-    if (delayed_move_time && ms > delayed_move_time + 1000 && !Stopped) {
5886
+    if (delayed_move_time && ms > delayed_move_time + 1000 && IsRunning()) {
5881 5887
       // travel moves have been received so enact them
5882 5888
       delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
5883 5889
       set_destination_to_current();
@@ -5928,8 +5934,8 @@ void kill()
5928 5934
 void Stop()
5929 5935
 {
5930 5936
   disable_heater();
5931
-  if(Stopped == false) {
5932
-    Stopped = true;
5937
+  if (IsRunning()) {
5938
+    Running = false;
5933 5939
     Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart
5934 5940
     SERIAL_ERROR_START;
5935 5941
     SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
@@ -5937,8 +5943,6 @@ void Stop()
5937 5943
   }
5938 5944
 }
5939 5945
 
5940
-bool IsStopped() { return Stopped; };
5941
-
5942 5946
 #ifdef FAST_PWM_FAN
5943 5947
 void setPwmFrequency(uint8_t pin, int val)
5944 5948
 {

+ 6
- 8
Marlin/planner.cpp View File

@@ -87,7 +87,7 @@ unsigned long axis_steps_per_sqr_second[NUM_AXIS];
87 87
     0.0, 1.0, 0.0,
88 88
     0.0, 0.0, 1.0
89 89
   };
90
-#endif // #ifdef ENABLE_AUTO_BED_LEVELING
90
+#endif // ENABLE_AUTO_BED_LEVELING
91 91
 
92 92
 // The current position of the tool in absolute steps
93 93
 long position[NUM_AXIS];   //rescaled from extern when axis_steps_per_unit are changed by gcode
@@ -472,7 +472,7 @@ float junction_deviation = 0.1;
472 472
   void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder)
473 473
 #else
474 474
   void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder)
475
-#endif  //ENABLE_AUTO_BED_LEVELING
475
+#endif  // ENABLE_AUTO_BED_LEVELING
476 476
 {
477 477
   // Calculate the buffer head after we push this byte
478 478
   int next_buffer_head = next_block_index(block_buffer_head);
@@ -487,9 +487,7 @@ float junction_deviation = 0.1;
487 487
 
488 488
   #ifdef MESH_BED_LEVELING
489 489
     if (mbl.active) z += mbl.get_z(x, y);
490
-  #endif
491
-
492
-  #ifdef ENABLE_AUTO_BED_LEVELING
490
+  #elif defined(ENABLE_AUTO_BED_LEVELING)
493 491
     apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
494 492
   #endif
495 493
 
@@ -979,10 +977,10 @@ float junction_deviation = 0.1;
979 977
   void plan_set_position(const float &x, const float &y, const float &z, const float &e)
980 978
 #endif // ENABLE_AUTO_BED_LEVELING || MESH_BED_LEVELING
981 979
   {
982
-    #ifdef ENABLE_AUTO_BED_LEVELING
983
-      apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
984
-    #elif defined(MESH_BED_LEVELING)
980
+    #ifdef MESH_BED_LEVELING
985 981
       if (mbl.active) z += mbl.get_z(x, y);
982
+    #elif defined(ENABLE_AUTO_BED_LEVELING)
983
+      apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
986 984
     #endif
987 985
 
988 986
     float nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]);

+ 1
- 1
Marlin/temperature.cpp View File

@@ -443,7 +443,7 @@ void checkExtruderAutoFans()
443 443
 // Temperature Error Handlers
444 444
 //
445 445
 inline void _temp_error(int e, const char *msg1, const char *msg2) {
446
-  if (!IsStopped()) {
446
+  if (IsRunning()) {
447 447
     SERIAL_ERROR_START;
448 448
     if (e >= 0) SERIAL_ERRORLN((int)e);
449 449
     serialprintPGM(msg1);

Loading…
Cancel
Save