Browse Source

Group all universal variables

Scott Lahteine 10 years ago
parent
commit
6b919e14c1
1 changed files with 74 additions and 102 deletions
  1. 74
    102
      Marlin/Marlin_main.cpp

+ 74
- 102
Marlin/Marlin_main.cpp View File

@@ -202,10 +202,6 @@
202 202
 #endif
203 203
 
204 204
 float homing_feedrate[] = HOMING_FEEDRATE;
205
-#ifdef ENABLE_AUTO_BED_LEVELING
206
-  int xy_travel_speed = XY_TRAVEL_SPEED;
207
-  float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
208
-#endif
209 205
 int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
210 206
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
211 207
 int feedmultiply = 100; //100->1 200->2
@@ -216,15 +212,49 @@ float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA
216 212
 float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0, 1.0, 1.0, 1.0);
217 213
 float current_position[NUM_AXIS] = { 0.0 };
218 214
 float home_offset[3] = { 0 };
219
-#ifdef DELTA
220
-  float endstop_adj[3] = { 0 };
221
-#elif defined(Z_DUAL_ENDSTOPS)
222
-  float z_endstop_adj = 0;
223
-#endif
224
-
225 215
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
226 216
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
227 217
 bool axis_known_position[3] = { false };
218
+uint8_t active_extruder = 0;
219
+int fanSpeed = 0;
220
+bool cancel_heatup = false;
221
+const char errormagic[] PROGMEM = "Error:";
222
+const char echomagic[] PROGMEM = "echo:";
223
+const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
224
+static float destination[NUM_AXIS] = { 0 };
225
+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
229
+static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
230
+static int bufindr = 0;
231
+static int bufindw = 0;
232
+static int buflen = 0;
233
+static char serial_char;
234
+static int serial_count = 0;
235
+static boolean comment_mode = false;
236
+static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
237
+const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
238
+const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
239
+// Inactivity shutdown
240
+static unsigned long previous_millis_cmd = 0;
241
+static unsigned long max_inactive_time = 0;
242
+static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
243
+unsigned long starttime = 0; ///< Print job start time
244
+unsigned long stoptime = 0;  ///< Print job stop time
245
+static uint8_t tmp_extruder;
246
+bool Stopped = false;
247
+bool CooldownNoWait = true;
248
+bool target_direction;
249
+
250
+#ifdef ENABLE_AUTO_BED_LEVELING
251
+  int xy_travel_speed = XY_TRAVEL_SPEED;
252
+  float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
253
+#endif
254
+
255
+#if defined(Z_DUAL_ENDSTOPS) && !defined(DELTA)
256
+  float z_endstop_adj = 0;
257
+#endif
228 258
 
229 259
 // Extruder offsets
230 260
 #if EXTRUDERS > 1
@@ -243,9 +273,6 @@ bool axis_known_position[3] = { false };
243 273
   };
244 274
 #endif
245 275
 
246
-uint8_t active_extruder = 0;
247
-int fanSpeed = 0;
248
-
249 276
 #ifdef SERVO_ENDSTOPS
250 277
   int servo_endstops[] = SERVO_ENDSTOPS;
251 278
   int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
@@ -282,33 +309,36 @@ int fanSpeed = 0;
282 309
   ;
283 310
 #endif
284 311
 
285
-#ifdef DELTA
286
-  float delta[3] = { 0, 0, 0 };
287
-  #define SIN_60 0.8660254037844386
288
-  #define COS_60 0.5
289
-  // these are the default values, can be overriden with M665
290
-  float delta_radius = DELTA_RADIUS;
291
-  float delta_tower1_x = -SIN_60 * delta_radius; // front left tower
292
-  float delta_tower1_y = -COS_60 * delta_radius;     
293
-  float delta_tower2_x =  SIN_60 * delta_radius; // front right tower
294
-  float delta_tower2_y = -COS_60 * delta_radius;     
295
-  float delta_tower3_x = 0;                      // back middle tower
296
-  float delta_tower3_y = delta_radius;
297
-  float delta_diagonal_rod = DELTA_DIAGONAL_ROD;
298
-  float delta_diagonal_rod_2 = sq(delta_diagonal_rod);
299
-  float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
300
-  #ifdef ENABLE_AUTO_BED_LEVELING
301
-    int delta_grid_spacing[2] = { 0, 0 };
302
-    float bed_level[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS];
312
+#if defined(DELTA) || defined(SCARA)
313
+  static float delta[3] = { 0, 0, 0 };    
314
+  #ifdef DELTA
315
+    #define SIN_60 0.8660254037844386
316
+    #define COS_60 0.5
317
+    float endstop_adj[3] = { 0 };
318
+    // these are the default values, can be overriden with M665
319
+    float delta_radius = DELTA_RADIUS;
320
+    float delta_tower1_x = -SIN_60 * delta_radius; // front left tower
321
+    float delta_tower1_y = -COS_60 * delta_radius;     
322
+    float delta_tower2_x =  SIN_60 * delta_radius; // front right tower
323
+    float delta_tower2_y = -COS_60 * delta_radius;     
324
+    float delta_tower3_x = 0;                      // back middle tower
325
+    float delta_tower3_y = delta_radius;
326
+    float delta_diagonal_rod = DELTA_DIAGONAL_ROD;
327
+    float delta_diagonal_rod_2 = sq(delta_diagonal_rod);
328
+    float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
329
+    #ifdef ENABLE_AUTO_BED_LEVELING
330
+      int delta_grid_spacing[2] = { 0, 0 };
331
+      float bed_level[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS];
332
+    #endif
303 333
   #endif
304
-#endif
305 334
 
306
-#ifdef SCARA
307
-  float axis_scaling[3] = { 1, 1, 1 };    // Build size scaling, default to 1
308
-  static float delta[3] = { 0, 0, 0 };		
309
-#endif
335
+  #ifdef SCARA
336
+    float axis_scaling[3] = { 1, 1, 1 };    // Build size scaling, default to 1
337
+  #endif
310 338
 
311
-bool cancel_heatup = false;
339
+#elif !defined(DELTA)
340
+  static bool home_all_axis = true;
341
+#endif
312 342
 
313 343
 #ifdef FILAMENT_SENSOR
314 344
   //Variables for Filament Sensor input
@@ -326,67 +356,21 @@ bool cancel_heatup = false;
326 356
    static bool filrunoutEnqued = false;
327 357
 #endif
328 358
 
329
-const char errormagic[] PROGMEM = "Error:";
330
-const char echomagic[] PROGMEM = "echo:";
331
-
332
-const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
333
-static float destination[NUM_AXIS] = { 0 };
334
-
335
-static float offset[3] = { 0 };
336
-
337
-#ifndef DELTA
338
-  static bool home_all_axis = true;
339
-#endif
340
-
341
-static float feedrate = 1500.0, next_feedrate, saved_feedrate;
342
-static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
343
-
344
-static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
345
-
346
-static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
347 359
 #ifdef SDSUPPORT
348 360
   static bool fromsd[BUFSIZE];
349 361
 #endif
350
-static int bufindr = 0;
351
-static int bufindw = 0;
352
-static int buflen = 0;
353
-
354
-static char serial_char;
355
-static int serial_count = 0;
356
-static boolean comment_mode = false;
357
-static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
358
-
359
-const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
360
-
361
-const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
362
-
363
-// Inactivity shutdown
364
-static unsigned long previous_millis_cmd = 0;
365
-static unsigned long max_inactive_time = 0;
366
-static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
367
-
368
-unsigned long starttime = 0; ///< Print job start time
369
-unsigned long stoptime = 0;  ///< Print job stop time
370
-
371
-static uint8_t tmp_extruder;
372
-
373
-
374
-bool Stopped = false;
375 362
 
376 363
 #if NUM_SERVOS > 0
377 364
   Servo servos[NUM_SERVOS];
378 365
 #endif
379 366
 
380
-bool CooldownNoWait = true;
381
-bool target_direction;
382
-
383 367
 #ifdef CHDK
384 368
   unsigned long chdkHigh = 0;
385 369
   boolean chdkActive = false;
386 370
 #endif
387 371
 
388 372
 //===========================================================================
389
-//=============================Routines======================================
373
+//================================ Functions ================================
390 374
 //===========================================================================
391 375
 
392 376
 void get_arc_coordinates();
@@ -5707,21 +5691,11 @@ void disable_all_axes() {
5707 5691
  */
5708 5692
 void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
5709 5693
   
5710
-  #if HAS_KILL
5711
-    static int killCount = 0;   // make the inactivity button a bit less responsive
5712
-    const int KILL_DELAY = 750;
5713
-  #endif
5714
-
5715 5694
   #if HAS_FILRUNOUT
5716 5695
     if (card.sdprinting && !(READ(FILRUNOUT_PIN) ^ FIL_RUNOUT_INVERTING))
5717 5696
       filrunout();
5718 5697
   #endif
5719 5698
 
5720
-  #if HAS_HOME
5721
-    static int homeDebounceCount = 0;   // poor man's debouncing count
5722
-    const int HOME_DEBOUNCE_DELAY = 750;
5723
-  #endif
5724
-
5725 5699
   if (buflen < BUFSIZE - 1) get_command();
5726 5700
 
5727 5701
   unsigned long ms = millis();
@@ -5744,6 +5718,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
5744 5718
     // Check if the kill button was pressed and wait just in case it was an accidental
5745 5719
     // key kill key press
5746 5720
     // -------------------------------------------------------------------------------
5721
+    static int killCount = 0;   // make the inactivity button a bit less responsive
5722
+    const int KILL_DELAY = 750;
5747 5723
     if (!READ(KILL_PIN))
5748 5724
        killCount++;
5749 5725
     else if (killCount > 0)
@@ -5758,6 +5734,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
5758 5734
   #if HAS_HOME
5759 5735
     // Check to see if we have to home, use poor man's debouncer
5760 5736
     // ---------------------------------------------------------
5737
+    static int homeDebounceCount = 0;   // poor man's debouncing count
5738
+    const int HOME_DEBOUNCE_DELAY = 750;
5761 5739
     if (!READ(HOME_PIN)) {
5762 5740
       if (!homeDebounceCount) {
5763 5741
         enquecommands_P(PSTR("G28"));
@@ -5797,7 +5775,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
5797 5775
     if (delayed_move_time && ms > delayed_move_time + 1000 && !Stopped) {
5798 5776
       // travel moves have been received so enact them
5799 5777
       delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
5800
-      memcpy(destination,current_position, sizeof(destination));
5778
+      memcpy(destination, current_position, sizeof(destination));
5801 5779
       prepare_move();
5802 5780
     }
5803 5781
   #endif
@@ -5814,13 +5792,7 @@ void kill()
5814 5792
   cli(); // Stop interrupts
5815 5793
   disable_heater();
5816 5794
 
5817
-  disable_x();
5818
-  disable_y();
5819
-  disable_z();
5820
-  disable_e0();
5821
-  disable_e1();
5822
-  disable_e2();
5823
-  disable_e3();
5795
+  disable_all_axes();
5824 5796
 
5825 5797
   #if HAS_POWER_SWITCH
5826 5798
     pinMode(PS_ON_PIN, INPUT);

Loading…
Cancel
Save