Преглед изворни кода

Minor G12 tweaks and point_t struct extension

João Brázio пре 8 година
родитељ
комит
4937f9ada4
4 измењених фајлова са 58 додато и 27 уклоњено
  1. 5
    8
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/SanityCheck.h
  3. 38
    17
      Marlin/nozzle.h
  4. 13
    0
      Marlin/point_t.h

+ 5
- 8
Marlin/Marlin_main.cpp Прегледај датотеку

@@ -2717,18 +2717,15 @@ inline void gcode_G4() {
2717 2717
 
2718 2718
 #endif //FWRETRACT
2719 2719
 
2720
-#if ENABLED(CLEAN_NOZZLE_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
2720
+#if ENABLED(NOZZLE_CLEAN_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
2721 2721
   #include "nozzle.h"
2722 2722
 
2723 2723
   inline void gcode_G12() {
2724 2724
     // Don't allow nozzle cleaning without homing first
2725
-    if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
2726
-      axis_unhomed_error(true);
2727
-      return;
2728
-    }
2725
+    if (axis_unhomed_error(true, true, true)) { return; }
2729 2726
 
2730 2727
     uint8_t const pattern = code_seen('P') ? code_value_ushort() : 0;
2731
-    uint8_t const strokes = code_seen('S') ? code_value_ushort() : CLEAN_NOZZLE_STROKES;
2728
+    uint8_t const strokes = code_seen('S') ? code_value_ushort() : NOZZLE_CLEAN_STROKES;
2732 2729
     uint8_t const objects = code_seen('T') ? code_value_ushort() : 3;
2733 2730
 
2734 2731
     Nozzle::clean(pattern, strokes, objects);
@@ -6796,11 +6793,11 @@ void process_next_command() {
6796 6793
           break;
6797 6794
       #endif // FWRETRACT
6798 6795
 
6799
-      #if ENABLED(CLEAN_NOZZLE_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
6796
+      #if ENABLED(NOZZLE_CLEAN_FEATURE) && HAS_BED_PROBE
6800 6797
         case 12:
6801 6798
           gcode_G12(); // G12: Clean Nozzle
6802 6799
           break;
6803
-      #endif // CLEAN_NOZZLE_FEATURE
6800
+      #endif // NOZZLE_CLEAN_FEATURE
6804 6801
 
6805 6802
       #if ENABLED(INCH_MODE_SUPPORT)
6806 6803
         case 20: //G20: Inch Mode

+ 2
- 2
Marlin/SanityCheck.h Прегледај датотеку

@@ -649,8 +649,8 @@
649 649
 /**
650 650
  * Nozzle cleaning
651 651
  */
652
-#if ENABLED(CLEAN_NOZZLE_FEATURE) && DISABLED(AUTO_BED_LEVELING_FEATURE)
653
-  #error You must enable AUTO_BED_LEVELING_FEATURE for CLEAN_NOZZLE_FEATURE to work
652
+#if ENABLED(NOZZLE_CLEAN_FEATURE) && !HAS_BED_PROBE
653
+  #error Due to internal dependencies you must have a bed probe for NOZZLE_CLEAN_FEATURE to work
654 654
 #endif
655 655
 
656 656
 #endif //SANITYCHECK_H

+ 38
- 17
Marlin/nozzle.h Прегледај датотеку

@@ -20,8 +20,8 @@
20 20
  *
21 21
  */
22 22
 
23
-#ifndef __CLEAN_NOZZLE_H__
24
-#define __CLEAN_NOZZLE_H__
23
+#ifndef __NOZZLE_H__
24
+#define __NOZZLE_H__
25 25
 
26 26
 #include "Marlin.h"
27 27
 #include "point_t.h"
@@ -30,7 +30,7 @@
30 30
  * @brief Nozzle class
31 31
  *
32 32
  * @todo: Do not ignore the end.z value and allow XYZ movements
33
- * @todo: Currently this feature needs AUTO_BED_LEVELING_FEATURE to be active
33
+ * @todo: Currently this feature needs HAS_BED_PROBE to be active
34 34
  *  due to the do_blocking_move_to*() functions.
35 35
  */
36 36
 class Nozzle {
@@ -45,6 +45,17 @@ class Nozzle {
45 45
      */
46 46
     static void stroke(point_t const &start, point_t const &end, uint8_t const &strokes)
47 47
     __attribute__ ((optimize ("Os"))) {
48
+
49
+      #if ENABLED(NOZZLE_CLEAN_PARK)
50
+        // Store the current coords
51
+        point_t const initial = {
52
+          current_position[X_AXIS],
53
+          current_position[Y_AXIS],
54
+          current_position[Z_AXIS],
55
+          current_position[E_AXIS]
56
+        };
57
+      #endif
58
+
48 59
       // Move to the starting point
49 60
       do_blocking_move_to_xy(start.x, start.y);
50 61
       do_blocking_move_to_z(start.z);
@@ -54,6 +65,12 @@ class Nozzle {
54 65
         do_blocking_move_to_xy(end.x, end.y);
55 66
         do_blocking_move_to_xy(start.x, start.y);
56 67
       }
68
+
69
+      #if ENABLED(NOZZLE_CLEAN_PARK)
70
+        // Move the nozzle to the initial point
71
+        do_blocking_move_to_z(initial.z);
72
+        do_blocking_move_to_xy(initial.x, initial.y);
73
+      #endif
57 74
     }
58 75
 
59 76
     /**
@@ -74,13 +91,15 @@ class Nozzle {
74 91
       // Don't allow impossible triangles
75 92
       if (A <= 0.0f || P <= 0.0f ) return;
76 93
 
77
-      // Store the current coords
78
-      point_t const home = {
79
-        current_position[X_AXIS],
80
-        current_position[Y_AXIS],
81
-        current_position[Z_AXIS],
82
-        current_position[E_AXIS]
83
-      };
94
+      #if ENABLED(NOZZLE_CLEAN_PARK)
95
+        // Store the current coords
96
+        point_t const initial = {
97
+          current_position[X_AXIS],
98
+          current_position[Y_AXIS],
99
+          current_position[Z_AXIS],
100
+          current_position[E_AXIS]
101
+        };
102
+      #endif
84 103
 
85 104
       for (uint8_t j = 0; j < strokes; j++) {
86 105
         for (uint8_t i = 0; i < (objects << 1); i++) {
@@ -99,9 +118,11 @@ class Nozzle {
99 118
         }
100 119
       }
101 120
 
102
-      // Move to home/start position
103
-      do_blocking_move_to_z(home.z);
104
-      do_blocking_move_to_xy(home.x, home.y);
121
+      #if ENABLED(NOZZLE_CLEAN_PARK)
122
+        // Move the nozzle to the initial point
123
+        do_blocking_move_to_z(initial.z);
124
+        do_blocking_move_to_xy(initial.x, initial.y);
125
+      #endif
105 126
     }
106 127
 
107 128
   public:
@@ -118,14 +139,14 @@ class Nozzle {
118 139
       switch (pattern) {
119 140
         case 1:
120 141
           Nozzle::zigzag(
121
-            CLEAN_NOZZLE_START_PT,
122
-            CLEAN_NOZZLE_END_PT, strokes, objects);
142
+            NOZZLE_CLEAN_START_PT,
143
+            NOZZLE_CLEAN_END_PT, strokes, objects);
123 144
           break;
124 145
 
125 146
         default:
126 147
           Nozzle::stroke(
127
-            CLEAN_NOZZLE_START_PT,
128
-            CLEAN_NOZZLE_END_PT, strokes);
148
+            NOZZLE_CLEAN_START_PT,
149
+            NOZZLE_CLEAN_END_PT, strokes);
129 150
       }
130 151
     }
131 152
 };

+ 13
- 0
Marlin/point_t.h Прегледај датотеку

@@ -28,6 +28,19 @@ struct point_t {
28 28
   float y;
29 29
   float z;
30 30
   float e;
31
+
32
+  point_t(float const x, float const y)
33
+    : point_t(x, y, NAN, NAN) {}
34
+
35
+  point_t(float const x, float const y, float const z)
36
+    : point_t(x, y, z, NAN) {}
37
+
38
+  point_t(float const x, float const y, float const z, float const e) {
39
+    this->x = x;
40
+    this->y = y;
41
+    this->z = z;
42
+    this->e = e;
43
+  }
31 44
 };
32 45
 
33 46
 #endif

Loading…
Откажи
Сачувај