Browse Source

Minor G12 tweaks and point_t struct extension

João Brázio 8 years ago
parent
commit
4937f9ada4
4 changed files with 58 additions and 27 deletions
  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 View File

2717
 
2717
 
2718
 #endif //FWRETRACT
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
   #include "nozzle.h"
2721
   #include "nozzle.h"
2722
 
2722
 
2723
   inline void gcode_G12() {
2723
   inline void gcode_G12() {
2724
     // Don't allow nozzle cleaning without homing first
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
     uint8_t const pattern = code_seen('P') ? code_value_ushort() : 0;
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
     uint8_t const objects = code_seen('T') ? code_value_ushort() : 3;
2729
     uint8_t const objects = code_seen('T') ? code_value_ushort() : 3;
2733
 
2730
 
2734
     Nozzle::clean(pattern, strokes, objects);
2731
     Nozzle::clean(pattern, strokes, objects);
6796
           break;
6793
           break;
6797
       #endif // FWRETRACT
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
         case 12:
6797
         case 12:
6801
           gcode_G12(); // G12: Clean Nozzle
6798
           gcode_G12(); // G12: Clean Nozzle
6802
           break;
6799
           break;
6803
-      #endif // CLEAN_NOZZLE_FEATURE
6800
+      #endif // NOZZLE_CLEAN_FEATURE
6804
 
6801
 
6805
       #if ENABLED(INCH_MODE_SUPPORT)
6802
       #if ENABLED(INCH_MODE_SUPPORT)
6806
         case 20: //G20: Inch Mode
6803
         case 20: //G20: Inch Mode

+ 2
- 2
Marlin/SanityCheck.h View File

649
 /**
649
 /**
650
  * Nozzle cleaning
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
 #endif
654
 #endif
655
 
655
 
656
 #endif //SANITYCHECK_H
656
 #endif //SANITYCHECK_H

+ 38
- 17
Marlin/nozzle.h View File

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
 #include "Marlin.h"
26
 #include "Marlin.h"
27
 #include "point_t.h"
27
 #include "point_t.h"
30
  * @brief Nozzle class
30
  * @brief Nozzle class
31
  *
31
  *
32
  * @todo: Do not ignore the end.z value and allow XYZ movements
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
  *  due to the do_blocking_move_to*() functions.
34
  *  due to the do_blocking_move_to*() functions.
35
  */
35
  */
36
 class Nozzle {
36
 class Nozzle {
45
      */
45
      */
46
     static void stroke(point_t const &start, point_t const &end, uint8_t const &strokes)
46
     static void stroke(point_t const &start, point_t const &end, uint8_t const &strokes)
47
     __attribute__ ((optimize ("Os"))) {
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
       // Move to the starting point
59
       // Move to the starting point
49
       do_blocking_move_to_xy(start.x, start.y);
60
       do_blocking_move_to_xy(start.x, start.y);
50
       do_blocking_move_to_z(start.z);
61
       do_blocking_move_to_z(start.z);
54
         do_blocking_move_to_xy(end.x, end.y);
65
         do_blocking_move_to_xy(end.x, end.y);
55
         do_blocking_move_to_xy(start.x, start.y);
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
       // Don't allow impossible triangles
91
       // Don't allow impossible triangles
75
       if (A <= 0.0f || P <= 0.0f ) return;
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
       for (uint8_t j = 0; j < strokes; j++) {
104
       for (uint8_t j = 0; j < strokes; j++) {
86
         for (uint8_t i = 0; i < (objects << 1); i++) {
105
         for (uint8_t i = 0; i < (objects << 1); i++) {
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
   public:
128
   public:
118
       switch (pattern) {
139
       switch (pattern) {
119
         case 1:
140
         case 1:
120
           Nozzle::zigzag(
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
           break;
144
           break;
124
 
145
 
125
         default:
146
         default:
126
           Nozzle::stroke(
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 View File

28
   float y;
28
   float y;
29
   float z;
29
   float z;
30
   float e;
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
 #endif
46
 #endif

Loading…
Cancel
Save