Browse Source

IsStopped / IsRunning inline

Scott Lahteine 10 years ago
parent
commit
27cb90da8b
3 changed files with 29 additions and 23 deletions
  1. 3
    1
      Marlin/Marlin.h
  2. 25
    21
      Marlin/Marlin_main.cpp
  3. 1
    1
      Marlin/temperature.cpp

+ 3
- 1
Marlin/Marlin.h View File

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

+ 1
- 1
Marlin/temperature.cpp View File

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

Loading…
Cancel
Save