Browse Source

UBL devel debugging flag

Scott Lahteine 7 years ago
parent
commit
a20eacaa48
7 changed files with 67 additions and 62 deletions
  1. 0
    1
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 1
    1
      Marlin/Marlin.h
  3. 54
    1
      Marlin/ubl.cpp
  4. 8
    1
      Marlin/ubl.h
  5. 4
    6
      Marlin/ubl_G29.cpp
  6. 0
    51
      Marlin/ubl_motion.cpp
  7. 0
    1
      Marlin/ultralcd.cpp

+ 0
- 1
Marlin/G26_Mesh_Validation_Tool.cpp View File

@@ -137,7 +137,6 @@
137 137
   #if ENABLED(ULTRA_LCD)
138 138
     extern char lcd_status_message[];
139 139
   #endif
140
-  extern float destination[XYZE];
141 140
   void set_destination_from_current();
142 141
   void prepare_move_to_destination();
143 142
   inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); }

+ 1
- 1
Marlin/Marlin.h View File

@@ -223,7 +223,7 @@ extern volatile bool wait_for_heatup;
223 223
   extern volatile bool wait_for_user;
224 224
 #endif
225 225
 
226
-extern float current_position[NUM_AXIS];
226
+extern float current_position[XYZE], destination[XYZE];
227 227
 
228 228
 // Workspace offsets
229 229
 #if HAS_WORKSPACE_OFFSET

+ 54
- 1
Marlin/ubl.cpp View File

@@ -51,6 +51,59 @@
51 51
     safe_delay(10);
52 52
   }
53 53
 
54
+  #if ENABLED(UBL_DEVEL_DEBUGGING)
55
+
56
+    static void debug_echo_axis(const AxisEnum axis) {
57
+      if (current_position[axis] == destination[axis])
58
+        SERIAL_ECHOPGM("-------------");
59
+      else
60
+        SERIAL_ECHO_F(destination[X_AXIS], 6);
61
+    }
62
+
63
+    void debug_current_and_destination(const char *title) {
64
+
65
+      // if the title message starts with a '!' it is so important, we are going to
66
+      // ignore the status of the g26_debug_flag
67
+      if (*title != '!' && !g26_debug_flag) return;
68
+
69
+      const float de = destination[E_AXIS] - current_position[E_AXIS];
70
+
71
+      if (de == 0.0) return; // Printing moves only
72
+
73
+      const float dx = destination[X_AXIS] - current_position[X_AXIS],
74
+                  dy = destination[Y_AXIS] - current_position[Y_AXIS],
75
+                  xy_dist = HYPOT(dx, dy);
76
+
77
+      if (xy_dist == 0.0) return;
78
+
79
+      SERIAL_ECHOPGM("   fpmm=");
80
+      const float fpmm = de / xy_dist;
81
+      SERIAL_ECHO_F(fpmm, 6);
82
+
83
+      SERIAL_ECHOPGM("    current=( ");
84
+      SERIAL_ECHO_F(current_position[X_AXIS], 6);
85
+      SERIAL_ECHOPGM(", ");
86
+      SERIAL_ECHO_F(current_position[Y_AXIS], 6);
87
+      SERIAL_ECHOPGM(", ");
88
+      SERIAL_ECHO_F(current_position[Z_AXIS], 6);
89
+      SERIAL_ECHOPGM(", ");
90
+      SERIAL_ECHO_F(current_position[E_AXIS], 6);
91
+      SERIAL_ECHOPGM(" )   destination=( ");
92
+      debug_echo_axis(X_AXIS);
93
+      SERIAL_ECHOPGM(", ");
94
+      debug_echo_axis(Y_AXIS);
95
+      SERIAL_ECHOPGM(", ");
96
+      debug_echo_axis(Z_AXIS);
97
+      SERIAL_ECHOPGM(", ");
98
+      debug_echo_axis(E_AXIS);
99
+      SERIAL_ECHOPGM(" )   ");
100
+      SERIAL_ECHO(title);
101
+      SERIAL_EOL();
102
+
103
+    }
104
+
105
+  #endif // UBL_DEVEL_DEBUGGING
106
+
54 107
   int8_t unified_bed_leveling::storage_slot;
55 108
 
56 109
   float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
@@ -174,7 +227,7 @@
174 227
     uint8_t error_flag = 0;
175 228
 
176 229
     if (settings.calc_num_meshes() < 1) {
177
-      SERIAL_PROTOCOLLNPGM("?Insufficient EEPROM storage for a mesh of this size.");
230
+      SERIAL_PROTOCOLLNPGM("?Mesh too big for EEPROM.");
178 231
       error_flag++;
179 232
     }
180 233
 

+ 8
- 1
Marlin/ubl.h View File

@@ -26,6 +26,9 @@
26 26
 #include "MarlinConfig.h"
27 27
 
28 28
 #if ENABLED(AUTO_BED_LEVELING_UBL)
29
+
30
+  //#define UBL_DEVEL_DEBUGGING
31
+
29 32
   #include "Marlin.h"
30 33
   #include "planner.h"
31 34
   #include "math.h"
@@ -41,7 +44,11 @@
41 44
 
42 45
   // ubl_motion.cpp
43 46
 
44
-  void debug_current_and_destination(const char * const title);
47
+  #if ENABLED(UBL_DEVEL_DEBUGGING)
48
+    void debug_current_and_destination(const char * const title);
49
+  #else
50
+    FORCE_INLINE void debug_current_and_destination(const char * const title) { UNUSED(title); }
51
+  #endif
45 52
 
46 53
   // ubl_G29.cpp
47 54
 

+ 4
- 6
Marlin/ubl_G29.cpp View File

@@ -24,8 +24,6 @@
24 24
 
25 25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26 26
 
27
-  //#define UBL_DEVEL_DEBUGGING
28
-
29 27
   #include "ubl.h"
30 28
   #include "Marlin.h"
31 29
   #include "hex_print_routines.h"
@@ -1165,12 +1163,12 @@
1165 1163
 
1166 1164
   static uint8_t ubl_state_at_invocation = 0;
1167 1165
 
1168
-  #ifdef UBL_DEVEL_DEBUGGING
1166
+  #if ENABLED(UBL_DEVEL_DEBUGGING)
1169 1167
     static uint8_t ubl_state_recursion_chk = 0;
1170 1168
   #endif
1171 1169
 
1172 1170
   void unified_bed_leveling::save_ubl_active_state_and_disable() {
1173
-    #ifdef UBL_DEVEL_DEBUGGING
1171
+    #if ENABLED(UBL_DEVEL_DEBUGGING)
1174 1172
       ubl_state_recursion_chk++;
1175 1173
       if (ubl_state_recursion_chk != 1) {
1176 1174
         SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
@@ -1186,7 +1184,7 @@
1186 1184
   }
1187 1185
 
1188 1186
   void unified_bed_leveling::restore_ubl_active_state_and_leave() {
1189
-    #ifdef UBL_DEVEL_DEBUGGING
1187
+    #if ENABLED(UBL_DEVEL_DEBUGGING)
1190 1188
       if (--ubl_state_recursion_chk) {
1191 1189
         SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
1192 1190
         #if ENABLED(NEWPANEL)
@@ -1267,7 +1265,7 @@
1267 1265
     SERIAL_EOL();
1268 1266
     safe_delay(50);
1269 1267
 
1270
-    #ifdef UBL_DEVEL_DEBUGGING
1268
+    #if ENABLED(UBL_DEVEL_DEBUGGING)
1271 1269
       SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1272 1270
       SERIAL_EOL();
1273 1271
       SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);

+ 0
- 51
Marlin/ubl_motion.cpp View File

@@ -30,63 +30,12 @@
30 30
   #include <avr/io.h>
31 31
   #include <math.h>
32 32
 
33
-  extern float destination[XYZE];
34
-
35 33
   #if AVR_AT90USB1286_FAMILY  // Teensyduino & Printrboard IDE extensions have compile errors without this
36 34
     inline void set_current_from_destination() { COPY(current_position, destination); }
37 35
   #else
38 36
     extern void set_current_from_destination();
39 37
   #endif
40 38
 
41
-  static void debug_echo_axis(const AxisEnum axis) {
42
-    if (current_position[axis] == destination[axis])
43
-      SERIAL_ECHOPGM("-------------");
44
-    else
45
-      SERIAL_ECHO_F(destination[X_AXIS], 6);
46
-  }
47
-
48
-  void debug_current_and_destination(const char *title) {
49
-
50
-    // if the title message starts with a '!' it is so important, we are going to
51
-    // ignore the status of the g26_debug_flag
52
-    if (*title != '!' && !g26_debug_flag) return;
53
-
54
-    const float de = destination[E_AXIS] - current_position[E_AXIS];
55
-
56
-    if (de == 0.0) return; // Printing moves only
57
-
58
-    const float dx = destination[X_AXIS] - current_position[X_AXIS],
59
-                dy = destination[Y_AXIS] - current_position[Y_AXIS],
60
-                xy_dist = HYPOT(dx, dy);
61
-
62
-    if (xy_dist == 0.0) return;
63
-
64
-    SERIAL_ECHOPGM("   fpmm=");
65
-    const float fpmm = de / xy_dist;
66
-    SERIAL_ECHO_F(fpmm, 6);
67
-
68
-    SERIAL_ECHOPGM("    current=( ");
69
-    SERIAL_ECHO_F(current_position[X_AXIS], 6);
70
-    SERIAL_ECHOPGM(", ");
71
-    SERIAL_ECHO_F(current_position[Y_AXIS], 6);
72
-    SERIAL_ECHOPGM(", ");
73
-    SERIAL_ECHO_F(current_position[Z_AXIS], 6);
74
-    SERIAL_ECHOPGM(", ");
75
-    SERIAL_ECHO_F(current_position[E_AXIS], 6);
76
-    SERIAL_ECHOPGM(" )   destination=( ");
77
-    debug_echo_axis(X_AXIS);
78
-    SERIAL_ECHOPGM(", ");
79
-    debug_echo_axis(Y_AXIS);
80
-    SERIAL_ECHOPGM(", ");
81
-    debug_echo_axis(Z_AXIS);
82
-    SERIAL_ECHOPGM(", ");
83
-    debug_echo_axis(E_AXIS);
84
-    SERIAL_ECHOPGM(" )   ");
85
-    SERIAL_ECHO(title);
86
-    SERIAL_EOL();
87
-
88
-  }
89
-
90 39
   void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, uint8_t extruder) {
91 40
     /**
92 41
      * Much of the nozzle movement will be within the same cell. So we will do as little computation

+ 0
- 1
Marlin/ultralcd.cpp View File

@@ -2755,7 +2755,6 @@ void kill_screen(const char* lcd_msg) {
2755 2755
 
2756 2756
   #if IS_KINEMATIC
2757 2757
     extern float feedrate_mm_s;
2758
-    extern float destination[XYZE];
2759 2758
     void set_destination_from_current();
2760 2759
     void prepare_move_to_destination();
2761 2760
   #endif

Loading…
Cancel
Save