Selaa lähdekoodia

Latest upstream commits, merged

Scott Lahteine 10 vuotta sitten
vanhempi
commit
588ed70d4a
2 muutettua tiedostoa jossa 41 lisäystä ja 52 poistoa
  1. 20
    25
      Marlin/Marlin_main.cpp
  2. 21
    27
      Marlin/ultralcd.cpp

+ 20
- 25
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -990,10 +990,10 @@ static void axis_is_at_home(int axis) {
990 990
   #endif
991 991
 
992 992
   #ifdef SCARA
993
-    float homeposition[3];
994 993
    
995
-    if (axis < 2) {
994
+    if (axis == X_AXIS || axis == Y_AXIS) {
996 995
 
996
+      float homeposition[3];
997 997
       for (int i = 0; i < 3; i++) homeposition[i] = base_home_pos(i);
998 998
 
999 999
       // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]);
@@ -1023,21 +1023,18 @@ static void axis_is_at_home(int axis) {
1023 1023
       // inverse kinematic transform.
1024 1024
       min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis));
1025 1025
       max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis));
1026
-    } 
1027
-    else {
1028
-      current_position[axis] = base_home_pos(axis) + home_offset[axis];
1029
-      min_pos[axis] = base_min_pos(axis) + home_offset[axis];
1030
-      max_pos[axis] = base_max_pos(axis) + home_offset[axis];
1031 1026
     }
1032
-  #else
1027
+    else
1028
+  #endif
1029
+  {
1033 1030
     current_position[axis] = base_home_pos(axis) + home_offset[axis];
1034 1031
     min_pos[axis] = base_min_pos(axis) + home_offset[axis];
1035 1032
     max_pos[axis] = base_max_pos(axis) + home_offset[axis];
1036
-  #endif
1037 1033
 
1038
-  #if defined(ENABLE_AUTO_BED_LEVELING) && Z_HOME_DIR < 0
1039
-    if (axis == Z_AXIS) current_position[Z_AXIS] += zprobe_zoffset;
1040
-  #endif
1034
+    #if defined(ENABLE_AUTO_BED_LEVELING) && Z_HOME_DIR < 0
1035
+      if (axis == Z_AXIS) current_position[Z_AXIS] += zprobe_zoffset;
1036
+    #endif
1037
+  }
1041 1038
 }
1042 1039
 
1043 1040
 /**
@@ -1505,13 +1502,11 @@ static void homeaxis(AxisEnum axis) {
1505 1502
 
1506 1503
   if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) {
1507 1504
 
1508
-    int axis_home_dir;
1509
-
1510
-    #ifdef DUAL_X_CARRIAGE
1511
-      if (axis == X_AXIS) axis_home_dir = x_home_dir(active_extruder);
1512
-    #else
1513
-      axis_home_dir = home_dir(axis);
1514
-    #endif
1505
+    int axis_home_dir =
1506
+      #ifdef DUAL_X_CARRIAGE
1507
+        (axis == X_AXIS) ? x_home_dir(active_extruder) :
1508
+      #endif
1509
+      home_dir(axis);
1515 1510
 
1516 1511
     // Set the axis position as setup for the move
1517 1512
     current_position[axis] = 0;
@@ -3806,23 +3801,23 @@ inline void gcode_M206() {
3806 3801
    * M666: Set delta endstop adjustment
3807 3802
    */
3808 3803
   inline void gcode_M666() {
3809
-    for (int8_t i = 0; i < 3; i++) {
3804
+    for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
3810 3805
       if (code_seen(axis_codes[i])) {
3811 3806
         endstop_adj[i] = code_value();
3812 3807
       }
3813 3808
     }
3814 3809
   }
3815
-#elif defined(Z_DUAL_ENDSTOPS)
3810
+#elif defined(Z_DUAL_ENDSTOPS) // !DELTA && defined(Z_DUAL_ENDSTOPS)
3816 3811
   /**
3817 3812
    * M666: For Z Dual Endstop setup, set z axis offset to the z2 axis.
3818 3813
    */
3819 3814
   inline void gcode_M666() {
3820
-   if (code_seen('Z')) z_endstop_adj = code_value();
3821
-   SERIAL_ECHOPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj );
3822
-   SERIAL_EOL;
3815
+    if (code_seen('Z')) z_endstop_adj = code_value();
3816
+    SERIAL_ECHOPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj);
3817
+    SERIAL_EOL;
3823 3818
   }
3824 3819
   
3825
-#endif // DELTA
3820
+#endif // !DELTA && defined(Z_DUAL_ENDSTOPS)
3826 3821
 
3827 3822
 #ifdef FWRETRACT
3828 3823
 

+ 21
- 27
Marlin/ultralcd.cpp Näytä tiedosto

@@ -648,26 +648,26 @@ static void lcd_prepare_menu() {
648 648
 
649 649
 #endif // DELTA_CALIBRATION_MENU
650 650
 
651
-inline void line_to_current() {
651
+inline void line_to_current(AxisEnum axis) {
652 652
   #ifdef DELTA
653 653
     calculate_delta(current_position);
654
-    plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder);
654
+    plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder);
655 655
   #else
656
-    plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder);
656
+    plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder);
657 657
   #endif
658 658
 }
659 659
 
660 660
 float move_menu_scale;
661 661
 static void lcd_move_menu_axis();
662 662
 
663
-static void _lcd_move(const char *name, int axis, int min, int max) {
663
+static void _lcd_move(const char *name, AxisEnum axis, int min, int max) {
664 664
   if (encoderPosition != 0) {
665 665
     refresh_cmd_timeout();
666 666
     current_position[axis] += float((int)encoderPosition) * move_menu_scale;
667 667
     if (min_software_endstops && current_position[axis] < min) current_position[axis] = min;
668 668
     if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
669 669
     encoderPosition = 0;
670
-    line_to_current();
670
+    line_to_current(axis);
671 671
     lcdDrawUpdate = 1;
672 672
   }
673 673
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
@@ -680,7 +680,7 @@ static void lcd_move_e() {
680 680
   if (encoderPosition != 0) {
681 681
     current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale;
682 682
     encoderPosition = 0;
683
-    line_to_current();
683
+    line_to_current(E_AXIS);
684 684
     lcdDrawUpdate = 1;
685 685
   }
686 686
   if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS]));
@@ -1803,7 +1803,7 @@ char *ftostr52(const float &x) {
1803 1803
       if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS;
1804 1804
       if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
1805 1805
       encoderPosition = 0;
1806
-      line_to_current();
1806
+      line_to_current(Z_AXIS);
1807 1807
       lcdDrawUpdate = 2;
1808 1808
     }
1809 1809
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS]));
@@ -1811,48 +1811,44 @@ char *ftostr52(const float &x) {
1811 1811
     if (LCD_CLICKED) {
1812 1812
       if (!debounce_click) {
1813 1813
         debounce_click = true;
1814
-        int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS;
1815
-        int iy = _lcd_level_bed_position / MESH_NUM_X_POINTS;
1816
-        if (iy&1) { // Zig zag
1817
-          ix = (MESH_NUM_X_POINTS - 1) - ix;
1818
-        }
1814
+        int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS,
1815
+            iy = _lcd_level_bed_position / MESH_NUM_X_POINTS;
1816
+        if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag
1819 1817
         mbl.set_z(ix, iy, current_position[Z_AXIS]);
1820 1818
         _lcd_level_bed_position++;
1821 1819
         if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) {
1822 1820
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1823
-          line_to_current();
1821
+          line_to_current(Z_AXIS);
1824 1822
           mbl.active = 1;
1825 1823
           enqueuecommands_P(PSTR("G28"));
1826 1824
           lcd_return_to_status();
1827
-        } else {
1825
+        }
1826
+        else {
1828 1827
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1829
-          line_to_current();
1828
+          line_to_current(Z_AXIS);
1830 1829
           ix = _lcd_level_bed_position % MESH_NUM_X_POINTS;
1831 1830
           iy = _lcd_level_bed_position / MESH_NUM_X_POINTS;
1832
-          if (iy&1) { // Zig zag
1833
-            ix = (MESH_NUM_X_POINTS - 1) - ix;
1834
-          }
1831
+          if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag
1835 1832
           current_position[X_AXIS] = mbl.get_x(ix);
1836 1833
           current_position[Y_AXIS] = mbl.get_y(iy);
1837
-          line_to_current();
1834
+          line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
1838 1835
           lcdDrawUpdate = 2;
1839 1836
         }
1840 1837
       }
1841
-    } else {
1838
+    }
1839
+    else {
1842 1840
       debounce_click = false;
1843 1841
     }
1844 1842
   }
1845 1843
 
1846 1844
   static void _lcd_level_bed_homing() {
1847 1845
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), "Homing");
1848
-    if (axis_known_position[X_AXIS] &&
1849
-        axis_known_position[Y_AXIS] &&
1850
-        axis_known_position[Z_AXIS]) {
1846
+    if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) {
1851 1847
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1852 1848
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1853 1849
       current_position[X_AXIS] = MESH_MIN_X;
1854 1850
       current_position[Y_AXIS] = MESH_MIN_Y;
1855
-      line_to_current();
1851
+      line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
1856 1852
       _lcd_level_bed_position = 0;
1857 1853
       lcd_goto_menu(_lcd_level_bed);
1858 1854
     }
@@ -1860,9 +1856,7 @@ char *ftostr52(const float &x) {
1860 1856
   }
1861 1857
 
1862 1858
   static void lcd_level_bed() {
1863
-    axis_known_position[X_AXIS] = false;
1864
-    axis_known_position[Y_AXIS] = false;
1865
-    axis_known_position[Z_AXIS] = false;
1859
+    axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false;
1866 1860
     mbl.reset();
1867 1861
     enqueuecommands_P(PSTR("G28"));
1868 1862
     lcdDrawUpdate = 2;

Loading…
Peruuta
Tallenna