瀏覽代碼

Merge pull request #4836 from thinkyhead/rc_some_comments

Some comments, const args, debug output tweaks
Scott Lahteine 8 年之前
父節點
當前提交
2ebfbc4c8d
共有 2 個文件被更改,包括 57 次插入23 次删除
  1. 55
    21
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/stepper.cpp

+ 55
- 21
Marlin/Marlin_main.cpp 查看文件

596
 void prepare_move_to_destination();
596
 void prepare_move_to_destination();
597
 
597
 
598
 void get_cartesian_from_steppers();
598
 void get_cartesian_from_steppers();
599
-void set_current_from_steppers_for_axis(AxisEnum axis);
599
+void set_current_from_steppers_for_axis(const AxisEnum axis);
600
 
600
 
601
 #if ENABLED(ARC_SUPPORT)
601
 #if ENABLED(ARC_SUPPORT)
602
   void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
602
   void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
645
 
645
 
646
 /**
646
 /**
647
  * sync_plan_position
647
  * sync_plan_position
648
- * Set planner / stepper positions to the cartesian current_position.
648
+ *
649
- * The stepper code translates these coordinates into step units.
649
+ * Set the planner/stepper positions directly from current_position with
650
- * Allows translation between steps and millimeters for cartesian & core robots
650
+ * no kinematic translation. Used for homing axes and cartesian/core syncing.
651
  */
651
  */
652
 inline void sync_plan_position() {
652
 inline void sync_plan_position() {
653
   #if ENABLED(DEBUG_LEVELING_FEATURE)
653
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1323
   update_software_endstops(axis);
1323
   update_software_endstops(axis);
1324
 }
1324
 }
1325
 
1325
 
1326
+/**
1327
+ * Set an axis' current position to its home position (after homing).
1328
+ *
1329
+ * For Core and Cartesian robots this applies one-to-one when an
1330
+ * individual axis has been homed.
1331
+ *
1332
+ * DELTA should wait until all homing is done before setting the XYZ
1333
+ * current_position to home, because homing is a single operation.
1334
+ * In the case where the axis positions are already known and previously
1335
+ * homed, DELTA could home to X or Y individually by moving either one
1336
+ * to the center. However, homing Z always homes XY and Z.
1337
+ *
1338
+ * SCARA should wait until all XY homing is done before setting the XY
1339
+ * current_position to home, because neither X nor Y is at home until
1340
+ * both are at home. Z can however be homed individually.
1341
+ * 
1342
+ */
1326
 static void set_axis_is_at_home(AxisEnum axis) {
1343
 static void set_axis_is_at_home(AxisEnum axis) {
1327
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1344
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1328
     if (DEBUGGING(LEVELING)) {
1345
     if (DEBUGGING(LEVELING)) {
1355
       // SERIAL_ECHOLNPAIR(" Y:", homeposition[Y_AXIS]);
1372
       // SERIAL_ECHOLNPAIR(" Y:", homeposition[Y_AXIS]);
1356
 
1373
 
1357
       /**
1374
       /**
1358
-       * Works out real Homeposition angles using inverse kinematics,
1375
+       * Get Home position SCARA arm angles using inverse kinematics,
1359
-       * and calculates homing offset using forward kinematics
1376
+       * and calculate homing offset using forward kinematics
1360
        */
1377
        */
1361
       inverse_kinematics(homeposition);
1378
       inverse_kinematics(homeposition);
1362
       forward_kinematics_SCARA(delta[A_AXIS], delta[B_AXIS]);
1379
       forward_kinematics_SCARA(delta[A_AXIS], delta[B_AXIS]);
1989
   //   - Raise to the BETWEEN height
2006
   //   - Raise to the BETWEEN height
1990
   // - Return the probed Z position
2007
   // - Return the probed Z position
1991
   //
2008
   //
1992
-  static float probe_pt(float x, float y, bool stow = true, int verbose_level = 1) {
2009
+  static float probe_pt(const float &x, const float &y, bool stow = true, int verbose_level = 1) {
1993
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2010
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1994
       if (DEBUGGING(LEVELING)) {
2011
       if (DEBUGGING(LEVELING)) {
1995
         SERIAL_ECHOPAIR(">>> probe_pt(", x);
2012
         SERIAL_ECHOPAIR(">>> probe_pt(", x);
2013
         SERIAL_ECHOLNPGM(")");
2030
         SERIAL_ECHOLNPGM(")");
2014
       }
2031
       }
2015
     #endif
2032
     #endif
2033
+
2016
     feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
2034
     feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
2035
+
2036
+    // Move the probe to the given XY
2017
     do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
2037
     do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
2018
 
2038
 
2019
     if (DEPLOY_PROBE()) return NAN;
2039
     if (DEPLOY_PROBE()) return NAN;
2105
 #elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
2125
 #elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
2106
 
2126
 
2107
   /**
2127
   /**
2108
-   * All DELTA leveling in the Marlin uses NONLINEAR_BED_LEVELING
2128
+   * Extrapolate a single point from its neighbors
2109
    */
2129
    */
2110
-  static void extrapolate_one_point(uint8_t x, uint8_t y, int xdir, int ydir) {
2130
+  static void extrapolate_one_point(uint8_t x, uint8_t y, int8_t xdir, int8_t ydir) {
2111
     if (bed_level_grid[x][y]) return;  // Don't overwrite good values.
2131
     if (bed_level_grid[x][y]) return;  // Don't overwrite good values.
2112
     float a = 2 * bed_level_grid[x + xdir][y] - bed_level_grid[x + xdir * 2][y], // Left to right.
2132
     float a = 2 * bed_level_grid[x + xdir][y] - bed_level_grid[x + xdir * 2][y], // Left to right.
2113
           b = 2 * bed_level_grid[x][y + ydir] - bed_level_grid[x][y + ydir * 2], // Front to back.
2133
           b = 2 * bed_level_grid[x][y + ydir] - bed_level_grid[x][y + ydir * 2], // Front to back.
2151
 #endif // AUTO_BED_LEVELING_NONLINEAR
2171
 #endif // AUTO_BED_LEVELING_NONLINEAR
2152
 
2172
 
2153
 /**
2173
 /**
2154
- * Home an individual axis
2174
+ * Home an individual linear axis
2155
  */
2175
  */
2156
 
2176
 
2157
 static void do_homing_move(AxisEnum axis, float where, float fr_mm_s = 0.0) {
2177
 static void do_homing_move(AxisEnum axis, float where, float fr_mm_s = 0.0) {
2163
   endstops.hit_on_purpose();
2183
   endstops.hit_on_purpose();
2164
 }
2184
 }
2165
 
2185
 
2186
+/**
2187
+ * Home an individual "raw axis" to its endstop.
2188
+ * This applies to XYZ on Cartesian and Core robots, and
2189
+ * to the individual ABC steppers on DELTA and SCARA.
2190
+ *
2191
+ * At the end of the procedure the axis is marked as
2192
+ * homed and the current position of that axis is updated.
2193
+ * Kinematic robots should wait till all axes are homed
2194
+ * before updating the current position.
2195
+ */
2196
+
2166
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
2197
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
2167
 
2198
 
2168
 static void homeaxis(AxisEnum axis) {
2199
 static void homeaxis(AxisEnum axis) {
2678
         SERIAL_ECHOPGM(" (Right");
2709
         SERIAL_ECHOPGM(" (Right");
2679
       #elif (X_PROBE_OFFSET_FROM_EXTRUDER < 0)
2710
       #elif (X_PROBE_OFFSET_FROM_EXTRUDER < 0)
2680
         SERIAL_ECHOPGM(" (Left");
2711
         SERIAL_ECHOPGM(" (Left");
2712
+      #elif (Y_PROBE_OFFSET_FROM_EXTRUDER != 0)
2713
+        SERIAL_ECHOPGM(" (Middle");
2714
+      #else
2715
+        SERIAL_ECHOPGM(" (Aligned With");
2681
       #endif
2716
       #endif
2682
       #if (Y_PROBE_OFFSET_FROM_EXTRUDER > 0)
2717
       #if (Y_PROBE_OFFSET_FROM_EXTRUDER > 0)
2683
         SERIAL_ECHOPGM("-Back");
2718
         SERIAL_ECHOPGM("-Back");
2684
       #elif (Y_PROBE_OFFSET_FROM_EXTRUDER < 0)
2719
       #elif (Y_PROBE_OFFSET_FROM_EXTRUDER < 0)
2685
         SERIAL_ECHOPGM("-Front");
2720
         SERIAL_ECHOPGM("-Front");
2721
+      #elif (X_PROBE_OFFSET_FROM_EXTRUDER != 0)
2722
+        SERIAL_ECHOPGM("-Center");
2686
       #endif
2723
       #endif
2687
       if (zprobe_zoffset < 0)
2724
       if (zprobe_zoffset < 0)
2688
         SERIAL_ECHOPGM(" & Below");
2725
         SERIAL_ECHOPGM(" & Below");
3295
       return;
3332
       return;
3296
     }
3333
     }
3297
 
3334
 
3298
-    bool dryrun = code_seen('D');
3335
+    bool dryrun = code_seen('D'),
3299
-    bool stow_probe_after_each = code_seen('E');
3336
+         stow_probe_after_each = code_seen('E');
3300
 
3337
 
3301
     #if ENABLED(AUTO_BED_LEVELING_GRID)
3338
     #if ENABLED(AUTO_BED_LEVELING_GRID)
3302
 
3339
 
3386
       #endif // !DELTA
3423
       #endif // !DELTA
3387
 
3424
 
3388
       // Inform the planner about the new coordinates
3425
       // Inform the planner about the new coordinates
3389
-      // (This is probably not needed here)
3390
       SYNC_PLAN_POSITION_KINEMATIC();
3426
       SYNC_PLAN_POSITION_KINEMATIC();
3391
     }
3427
     }
3392
 
3428
 
3759
  * G92: Set current position to given X Y Z E
3795
  * G92: Set current position to given X Y Z E
3760
  */
3796
  */
3761
 inline void gcode_G92() {
3797
 inline void gcode_G92() {
3762
-  bool didE = code_seen('E');
3798
+  bool didXYZ = false,
3799
+       didE = code_seen('E');
3763
 
3800
 
3764
   if (!didE) stepper.synchronize();
3801
   if (!didE) stepper.synchronize();
3765
 
3802
 
3766
-  bool didXYZ = false;
3767
   LOOP_XYZE(i) {
3803
   LOOP_XYZE(i) {
3768
     if (code_seen(axis_codes[i])) {
3804
     if (code_seen(axis_codes[i])) {
3769
       float p = current_position[i],
3805
       float p = current_position[i],
4148
     if (verbose_level > 2)
4184
     if (verbose_level > 2)
4149
       SERIAL_PROTOCOLLNPGM("Positioning the probe...");
4185
       SERIAL_PROTOCOLLNPGM("Positioning the probe...");
4150
 
4186
 
4151
-    // we don't do bed level correction in M48 because we want the raw data when we probe
4187
+    // Disable bed level correction in M48 because we want the raw data when we probe
4152
     #if ENABLED(AUTO_BED_LEVELING_FEATURE)
4188
     #if ENABLED(AUTO_BED_LEVELING_FEATURE)
4153
       reset_bed_level();
4189
       reset_bed_level();
4154
     #endif
4190
     #endif
5745
 }
5781
 }
5746
 
5782
 
5747
 #if ENABLED(MORGAN_SCARA)
5783
 #if ENABLED(MORGAN_SCARA)
5784
+
5748
   bool SCARA_move_to_cal(uint8_t delta_a, uint8_t delta_b) {
5785
   bool SCARA_move_to_cal(uint8_t delta_a, uint8_t delta_b) {
5749
-    //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
5750
-    //SERIAL_ECHOLNPGM(" Soft endstops disabled");
5751
     if (IsRunning()) {
5786
     if (IsRunning()) {
5752
       //gcode_get_destination(); // For X Y Z E F
5787
       //gcode_get_destination(); // For X Y Z E F
5753
       forward_kinematics_SCARA(delta_a, delta_b);
5788
       forward_kinematics_SCARA(delta_a, delta_b);
5755
       destination[Y_AXIS] = cartes[Y_AXIS];
5790
       destination[Y_AXIS] = cartes[Y_AXIS];
5756
       destination[Z_AXIS] = current_position[Z_AXIS];
5791
       destination[Z_AXIS] = current_position[Z_AXIS];
5757
       prepare_move_to_destination();
5792
       prepare_move_to_destination();
5758
-      //ok_to_send();
5759
       return true;
5793
       return true;
5760
     }
5794
     }
5761
     return false;
5795
     return false;
7875
  *
7909
  *
7876
  * << INCOMPLETE! Still needs to unapply leveling! >>
7910
  * << INCOMPLETE! Still needs to unapply leveling! >>
7877
  */
7911
  */
7878
-void set_current_from_steppers_for_axis(AxisEnum axis) {
7912
+void set_current_from_steppers_for_axis(const AxisEnum axis) {
7879
   #if ENABLED(AUTO_BED_LEVELING_LINEAR)
7913
   #if ENABLED(AUTO_BED_LEVELING_LINEAR)
7880
     vector_3 pos = untilted_stepper_position();
7914
     vector_3 pos = untilted_stepper_position();
7881
     current_position[axis] = axis == X_AXIS ? pos.x : axis == Y_AXIS ? pos.y : pos.z;
7915
     current_position[axis] = axis == X_AXIS ? pos.x : axis == Y_AXIS ? pos.y : pos.z;
7948
     mesh_line_to_destination(fr_mm_s, x_splits, y_splits);
7982
     mesh_line_to_destination(fr_mm_s, x_splits, y_splits);
7949
   }
7983
   }
7950
 
7984
 
7951
-#endif  // MESH_BED_LEVELING
7985
+#endif // MESH_BED_LEVELING
7952
 
7986
 
7953
 #if IS_KINEMATIC
7987
 #if IS_KINEMATIC
7954
 
7988
 

+ 2
- 2
Marlin/stepper.cpp 查看文件

1062
        zpos = count_position[Z_AXIS];
1062
        zpos = count_position[Z_AXIS];
1063
   CRITICAL_SECTION_END;
1063
   CRITICAL_SECTION_END;
1064
 
1064
 
1065
-  #if ENABLED(COREXY) || ENABLED(COREXZ)
1065
+  #if ENABLED(COREXY) || ENABLED(COREXZ) || IS_SCARA
1066
     SERIAL_PROTOCOLPGM(MSG_COUNT_A);
1066
     SERIAL_PROTOCOLPGM(MSG_COUNT_A);
1067
   #else
1067
   #else
1068
     SERIAL_PROTOCOLPGM(MSG_COUNT_X);
1068
     SERIAL_PROTOCOLPGM(MSG_COUNT_X);
1069
   #endif
1069
   #endif
1070
   SERIAL_PROTOCOL(xpos);
1070
   SERIAL_PROTOCOL(xpos);
1071
 
1071
 
1072
-  #if ENABLED(COREXY) || ENABLED(COREYZ)
1072
+  #if ENABLED(COREXY) || ENABLED(COREYZ) || IS_SCARA
1073
     SERIAL_PROTOCOLPGM(" B:");
1073
     SERIAL_PROTOCOLPGM(" B:");
1074
   #else
1074
   #else
1075
     SERIAL_PROTOCOLPGM(" Y:");
1075
     SERIAL_PROTOCOLPGM(" Y:");

Loading…
取消
儲存