Browse Source

Compare indices instead of floats for probe actions

Scott Lahteine 9 years ago
parent
commit
61f8394361
3 changed files with 27 additions and 30 deletions
  1. 2
    1
      Marlin/Marlin.h
  2. 23
    26
      Marlin/Marlin_main.cpp
  3. 2
    3
      Marlin/ultralcd.cpp

+ 2
- 1
Marlin/Marlin.h View File

227
 void prepare_arc_move(char isclockwise);
227
 void prepare_arc_move(char isclockwise);
228
 void clamp_to_software_endstops(float target[3]);
228
 void clamp_to_software_endstops(float target[3]);
229
 
229
 
230
-void refresh_cmd_timeout();
230
+extern unsigned long previous_millis_cmd;
231
+inline void refresh_cmd_timeout() { previous_millis_cmd = millis(); }
231
 
232
 
232
 #ifdef FAST_PWM_FAN
233
 #ifdef FAST_PWM_FAN
233
   void setPwmFrequency(uint8_t pin, int val);
234
   void setPwmFrequency(uint8_t pin, int val);

+ 23
- 26
Marlin/Marlin_main.cpp View File

238
 const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
238
 const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
239
 const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
239
 const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
240
 // Inactivity shutdown
240
 // Inactivity shutdown
241
-static unsigned long previous_millis_cmd = 0;
241
+unsigned long previous_millis_cmd = 0;
242
 static unsigned long max_inactive_time = 0;
242
 static unsigned long max_inactive_time = 0;
243
 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
243
 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
244
 unsigned long starttime = 0; ///< Print job start time
244
 unsigned long starttime = 0; ///< Print job start time
986
   #endif
986
   #endif
987
 }
987
 }
988
 
988
 
989
-inline void refresh_cmd_timeout() { previous_millis_cmd = millis(); }
990
-
991
 /**
989
 /**
992
  * Some planner shorthand inline functions
990
  * Some planner shorthand inline functions
993
  */
991
  */
1327
   }
1325
   }
1328
 
1326
 
1329
   enum ProbeAction {
1327
   enum ProbeAction {
1330
-    ProbeStay             = 0,
1331
-    ProbeEngage           = BIT(0),
1332
-    ProbeRetract          = BIT(1),
1333
-    ProbeEngageAndRetract = (ProbeEngage | ProbeRetract)
1328
+    ProbeStay          = 0,
1329
+    ProbeDeploy        = BIT(0),
1330
+    ProbeStow          = BIT(1),
1331
+    ProbeDeployAndStow = (ProbeDeploy | ProbeStow)
1334
   };
1332
   };
1335
 
1333
 
1336
   // Probe bed height at position (x,y), returns the measured z value
1334
   // Probe bed height at position (x,y), returns the measured z value
1337
-  static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeEngageAndRetract, int verbose_level=1) {
1335
+  static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeDeployAndStow, int verbose_level=1) {
1338
     // move to right place
1336
     // move to right place
1339
     do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
1337
     do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
1340
     do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1338
     do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1341
 
1339
 
1342
     #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
1340
     #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
1343
-      if (retract_action & ProbeEngage) deploy_z_probe();
1341
+      if (retract_action & ProbeDeploy) deploy_z_probe();
1344
     #endif
1342
     #endif
1345
 
1343
 
1346
     run_z_probe();
1344
     run_z_probe();
1354
     #endif
1352
     #endif
1355
 
1353
 
1356
     #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
1354
     #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
1357
-      if (retract_action & ProbeRetract) stow_z_probe();
1355
+      if (retract_action & ProbeStow) stow_z_probe();
1358
     #endif
1356
     #endif
1359
 
1357
 
1360
     if (verbose_level > 2) {
1358
     if (verbose_level > 2) {
2167
     }
2165
     }
2168
 
2166
 
2169
     bool dryrun = code_seen('D') || code_seen('d'),
2167
     bool dryrun = code_seen('D') || code_seen('d'),
2170
-         engage_probe_for_each_reading = code_seen('E') || code_seen('e');
2168
+         deploy_probe_for_each_reading = code_seen('E') || code_seen('e');
2171
 
2169
 
2172
     #ifdef AUTO_BED_LEVELING_GRID
2170
     #ifdef AUTO_BED_LEVELING_GRID
2173
 
2171
 
2319
             if (distance_from_center > DELTA_PROBABLE_RADIUS) continue;
2317
             if (distance_from_center > DELTA_PROBABLE_RADIUS) continue;
2320
           #endif //DELTA
2318
           #endif //DELTA
2321
 
2319
 
2322
-          // Enhanced G29 - Do not retract servo between probes
2323
           ProbeAction act;
2320
           ProbeAction act;
2324
-          if (engage_probe_for_each_reading)
2325
-            act = ProbeEngageAndRetract;
2326
-          else if (yProbe == front_probe_bed_position && xCount == 0)
2327
-            act = ProbeEngage;
2328
-          else if (yProbe == front_probe_bed_position + (yGridSpacing * (auto_bed_leveling_grid_points - 1)) && xCount == auto_bed_leveling_grid_points - 1)
2329
-            act = ProbeRetract;
2321
+          if (deploy_probe_for_each_reading) // G29 E - Stow between probes
2322
+            act = ProbeDeployAndStow;
2323
+          else if (yCount == 0 && xCount == 0)
2324
+            act = ProbeDeploy;
2325
+          else if (yCount == auto_bed_leveling_grid_points - 1 && xCount == auto_bed_leveling_grid_points - 1)
2326
+            act = ProbeStow;
2330
           else
2327
           else
2331
             act = ProbeStay;
2328
             act = ProbeStay;
2332
 
2329
 
2417
 
2414
 
2418
       // Actions for each probe
2415
       // Actions for each probe
2419
       ProbeAction p1, p2, p3;
2416
       ProbeAction p1, p2, p3;
2420
-      if (engage_probe_for_each_reading)
2421
-        p1 = p2 = p3 = ProbeEngageAndRetract;
2417
+      if (deploy_probe_for_each_reading)
2418
+        p1 = p2 = p3 = ProbeDeployAndStow;
2422
       else
2419
       else
2423
-        p1 = ProbeEngage, p2 = ProbeStay, p3 = ProbeRetract;
2420
+        p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
2424
 
2421
 
2425
       // Probe at 3 arbitrary points
2422
       // Probe at 3 arbitrary points
2426
       float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, p1, verbose_level),
2423
       float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, p1, verbose_level),
2839
            Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING,
2836
            Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING,
2840
            ext_position = st_get_position_mm(E_AXIS);
2837
            ext_position = st_get_position_mm(E_AXIS);
2841
 
2838
 
2842
-    bool engage_probe_for_each_reading = code_seen('E') || code_seen('e');
2839
+    bool deploy_probe_for_each_reading = code_seen('E') || code_seen('e');
2843
 
2840
 
2844
     if (code_seen('X') || code_seen('x')) {
2841
     if (code_seen('X') || code_seen('x')) {
2845
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
2842
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
2917
     st_synchronize();
2914
     st_synchronize();
2918
     current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
2915
     current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
2919
 
2916
 
2920
-    if (engage_probe_for_each_reading) stow_z_probe();
2917
+    if (deploy_probe_for_each_reading) stow_z_probe();
2921
 
2918
 
2922
     for (uint16_t n=0; n < n_samples; n++) {
2919
     for (uint16_t n=0; n < n_samples; n++) {
2923
 
2920
 
2959
 
2956
 
2960
       } // n_legs
2957
       } // n_legs
2961
 
2958
 
2962
-      if (engage_probe_for_each_reading)  {
2959
+      if (deploy_probe_for_each_reading)  {
2963
         deploy_z_probe(); 
2960
         deploy_z_probe(); 
2964
         delay(1000);
2961
         delay(1000);
2965
       }
2962
       }
3006
       plan_buffer_line(X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder);
3003
       plan_buffer_line(X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder);
3007
       st_synchronize();
3004
       st_synchronize();
3008
 
3005
 
3009
-      if (engage_probe_for_each_reading) {
3006
+      if (deploy_probe_for_each_reading) {
3010
         stow_z_probe();
3007
         stow_z_probe();
3011
         delay(1000);
3008
         delay(1000);
3012
       }
3009
       }
3013
     }
3010
     }
3014
 
3011
 
3015
-    if (!engage_probe_for_each_reading) {
3012
+    if (!deploy_probe_for_each_reading) {
3016
       stow_z_probe();
3013
       stow_z_probe();
3017
       delay(1000);
3014
       delay(1000);
3018
     }
3015
     }

+ 2
- 3
Marlin/ultralcd.cpp View File

1789
   return conv;
1789
   return conv;
1790
 }
1790
 }
1791
 
1791
 
1792
-#if defined(MANUAL_BED_LEVELING)
1792
+#ifdef MANUAL_BED_LEVELING
1793
 static int _lcd_level_bed_position;
1793
 static int _lcd_level_bed_position;
1794
 static void _lcd_level_bed()
1794
 static void _lcd_level_bed()
1795
 {
1795
 {
1849
     lcd_goto_menu(_lcd_level_bed);
1849
     lcd_goto_menu(_lcd_level_bed);
1850
   }
1850
   }
1851
 }
1851
 }
1852
-static void lcd_level_bed()
1853
-{
1852
+static void lcd_level_bed() {
1854
   axis_known_position[X_AXIS] = false;
1853
   axis_known_position[X_AXIS] = false;
1855
   axis_known_position[Y_AXIS] = false;
1854
   axis_known_position[Y_AXIS] = false;
1856
   axis_known_position[Z_AXIS] = false;
1855
   axis_known_position[Z_AXIS] = false;

Loading…
Cancel
Save