Browse Source

Refactor SCARA calibration. Save some lines of code and possibly ROM.

Josef Larsson 9 years ago
parent
commit
9b3462f73f
1 changed files with 15 additions and 61 deletions
  1. 15
    61
      Marlin/Marlin_main.cpp

+ 15
- 61
Marlin/Marlin_main.cpp View File

@@ -3967,18 +3967,16 @@ inline void gcode_M303() {
3967 3967
 }
3968 3968
 
3969 3969
 #ifdef SCARA
3970
-
3971 3970
   /**
3972 3971
    * M360: SCARA calibration: Move to cal-position ThetaA (0 deg calibration)
3973 3972
    */
3974
-  inline bool gcode_M360() {
3975
-    SERIAL_ECHOLN(" Cal: Theta 0 ");
3973
+  bool SCARA_move_to_cal(uint8_t delta_x, uint8_t delta_y) {
3976 3974
     //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
3977 3975
     //SERIAL_ECHOLN(" Soft endstops disabled ");
3978 3976
     if (! Stopped) {
3979 3977
       //get_coordinates(); // For X Y Z E F
3980
-      delta[X_AXIS] = 0;
3981
-      delta[Y_AXIS] = 120;
3978
+      delta[X_AXIS] = delta_x;
3979
+      delta[Y_AXIS] = delta_y;
3982 3980
       calculate_SCARA_forward_Transform(delta);
3983 3981
       destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS];
3984 3982
       destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS];
@@ -3990,24 +3988,19 @@ inline void gcode_M303() {
3990 3988
   }
3991 3989
 
3992 3990
   /**
3991
+   * M360: SCARA calibration: Move to cal-position ThetaA (0 deg calibration)
3992
+   */
3993
+  inline bool gcode_M360() {
3994
+    SERIAL_ECHOLN(" Cal: Theta 0 ");
3995
+    return SCARA_move_to_cal(0, 120);
3996
+  }
3997
+
3998
+  /**
3993 3999
    * M361: SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree)
3994 4000
    */
3995 4001
   inline bool gcode_M361() {
3996 4002
     SERIAL_ECHOLN(" Cal: Theta 90 ");
3997
-    //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
3998
-    //SERIAL_ECHOLN(" Soft endstops disabled ");
3999
-    if (! Stopped) {
4000
-      //get_coordinates(); // For X Y Z E F
4001
-      delta[X_AXIS] = 90;
4002
-      delta[Y_AXIS] = 130;
4003
-      calculate_SCARA_forward_Transform(delta);
4004
-      destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS];
4005
-      destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS];
4006
-      prepare_move();
4007
-      //ClearToSend();
4008
-      return true;
4009
-    }
4010
-    return false;
4003
+    return SCARA_move_to_cal(90, 130);
4011 4004
   }
4012 4005
 
4013 4006
   /**
@@ -4015,20 +4008,7 @@ inline void gcode_M303() {
4015 4008
    */
4016 4009
   inline bool gcode_M362() {
4017 4010
     SERIAL_ECHOLN(" Cal: Psi 0 ");
4018
-    //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
4019
-    //SERIAL_ECHOLN(" Soft endstops disabled ");
4020
-    if (! Stopped) {
4021
-      //get_coordinates(); // For X Y Z E F
4022
-      delta[X_AXIS] = 60;
4023
-      delta[Y_AXIS] = 180;
4024
-      calculate_SCARA_forward_Transform(delta);
4025
-      destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS];
4026
-      destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS];
4027
-      prepare_move();
4028
-      //ClearToSend();
4029
-      return true;
4030
-    }
4031
-    return false;
4011
+    return SCARA_move_to_cal(60, 180);
4032 4012
   }
4033 4013
 
4034 4014
   /**
@@ -4036,20 +4016,7 @@ inline void gcode_M303() {
4036 4016
    */
4037 4017
   inline bool gcode_M363() {
4038 4018
     SERIAL_ECHOLN(" Cal: Psi 90 ");
4039
-    //SoftEndsEnabled = false;              // Ignore soft endstops during calibration
4040
-    //SERIAL_ECHOLN(" Soft endstops disabled ");
4041
-    if (! Stopped) {
4042
-      //get_coordinates(); // For X Y Z E F
4043
-      delta[X_AXIS] = 50;
4044
-      delta[Y_AXIS] = 90;
4045
-      calculate_SCARA_forward_Transform(delta);
4046
-      destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS];
4047
-      destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS];
4048
-      prepare_move();
4049
-      //ClearToSend();
4050
-      return true;
4051
-    }
4052
-    return false;
4019
+    return SCARA_move_to_cal(50, 90);
4053 4020
   }
4054 4021
 
4055 4022
   /**
@@ -4057,20 +4024,7 @@ inline void gcode_M303() {
4057 4024
    */
4058 4025
   inline bool gcode_M364() {
4059 4026
     SERIAL_ECHOLN(" Cal: Theta-Psi 90 ");
4060
-   // SoftEndsEnabled = false;              // Ignore soft endstops during calibration
4061
-    //SERIAL_ECHOLN(" Soft endstops disabled ");
4062
-    if (! Stopped) {
4063
-      //get_coordinates(); // For X Y Z E F
4064
-      delta[X_AXIS] = 45;
4065
-      delta[Y_AXIS] = 135;
4066
-      calculate_SCARA_forward_Transform(delta);
4067
-      destination[X_AXIS] = delta[X_AXIS] / axis_scaling[X_AXIS];
4068
-      destination[Y_AXIS] = delta[Y_AXIS] / axis_scaling[Y_AXIS];
4069
-      prepare_move();
4070
-      //ClearToSend();
4071
-      return true;
4072
-    }
4073
-    return false;
4027
+    return SCARA_move_to_cal(45, 135);
4074 4028
   }
4075 4029
 
4076 4030
   /**

Loading…
Cancel
Save