Browse Source

Update M48 command in the status line (#14816)

Acenotass 6 years ago
parent
commit
4af9908764

+ 25
- 27
Marlin/src/gcode/calibrate/M48.cpp View File

@@ -123,45 +123,47 @@ void GcodeSuite::M48() {
123 123
     randomSeed(millis());
124 124
 
125 125
     for (uint8_t n = 0; n < n_samples; n++) {
126
+      #if HAS_SPI_LCD
127
+        // Display M48 progress in the status bar
128
+        ui.status_printf_P(0, PSTR(MSG_M48_POINT ": %d/%d"), int(n + 1), int(n_samples));
129
+      #endif
126 130
       if (n_legs) {
127 131
         const int dir = (random(0, 10) > 5.0) ? -1 : 1;  // clockwise or counter clockwise
128 132
         float angle = random(0, 360);
129 133
         const float radius = random(
130 134
           #if ENABLED(DELTA)
131
-            (int) (0.1250000000 * (DELTA_PRINTABLE_RADIUS)),
132
-            (int) (0.3333333333 * (DELTA_PRINTABLE_RADIUS))
135
+            int(0.1250000000 * (DELTA_PRINTABLE_RADIUS)),
136
+            int(0.3333333333 * (DELTA_PRINTABLE_RADIUS))
133 137
           #else
134
-            (int) 5.0, (int) (0.125 * _MIN(X_BED_SIZE, Y_BED_SIZE))
138
+            int(5), int(0.125 * _MIN(X_BED_SIZE, Y_BED_SIZE))
135 139
           #endif
136 140
         );
137 141
 
138 142
         if (verbose_level > 3) {
139
-          SERIAL_ECHOPAIR("Starting radius: ", radius);
140
-          SERIAL_ECHOPAIR("   angle: ", angle);
141
-          SERIAL_ECHOPGM(" Direction: ");
142
-          if (dir > 0) SERIAL_ECHOPGM("Counter-");
143
-          SERIAL_ECHOLNPGM("Clockwise");
143
+          SERIAL_ECHOPAIR("Start radius:", radius, " angle:", angle, " dir:");
144
+          if (dir > 0) SERIAL_CHAR('C');
145
+          SERIAL_ECHOLNPGM("CW");
144 146
         }
145 147
 
146 148
         for (uint8_t l = 0; l < n_legs - 1; l++) {
147 149
           float delta_angle;
148 150
 
149
-          if (schizoid_flag)
151
+          if (schizoid_flag) {
150 152
             // The points of a 5 point star are 72 degrees apart.  We need to
151 153
             // skip a point and go to the next one on the star.
152 154
             delta_angle = dir * 2.0 * 72.0;
153
-
154
-          else
155
+          }
156
+          else {
155 157
             // If we do this line, we are just trying to move further
156 158
             // around the circle.
157 159
             delta_angle = dir * (float) random(25, 45);
160
+          }
158 161
 
159 162
           angle += delta_angle;
160
-
161
-          while (angle > 360.0)   // We probably do not need to keep the angle between 0 and 2*PI, but the
162
-            angle -= 360.0;       // Arduino documentation says the trig functions should not be given values
163
-          while (angle < 0.0)     // outside of this range.   It looks like they behave correctly with
164
-            angle += 360.0;       // numbers outside of the range, but just to be safe we clamp them.
163
+          while (angle > 360.0) angle -= 360.0; // We probably do not need to keep the angle between 0 and 2*PI, but the
164
+                                                // Arduino documentation says the trig functions should not be given values
165
+          while (angle < 0.0) angle += 360.0;   // outside of this range.   It looks like they behave correctly with
166
+                                                // numbers outside of the range, but just to be safe we clamp them.
165 167
 
166 168
           X_current = X_probe_location - (X_PROBE_OFFSET_FROM_EXTRUDER) + cos(RADIANS(angle)) * radius;
167 169
           Y_current = Y_probe_location - (Y_PROBE_OFFSET_FROM_EXTRUDER) + sin(RADIANS(angle)) * radius;
@@ -175,18 +177,14 @@ void GcodeSuite::M48() {
175 177
             while (!position_is_reachable_by_probe(X_current, Y_current)) {
176 178
               X_current *= 0.8;
177 179
               Y_current *= 0.8;
178
-              if (verbose_level > 3) {
179
-                SERIAL_ECHOPAIR("Pulling point towards center:", X_current);
180
-                SERIAL_ECHOLNPAIR(", ", Y_current);
181
-              }
180
+              if (verbose_level > 3)
181
+                SERIAL_ECHOLNPAIR("Moving inward: X", X_current, " Y", Y_current);
182 182
             }
183 183
           #endif
184
-          if (verbose_level > 3) {
185
-            SERIAL_ECHOPGM("Going to:");
186
-            SERIAL_ECHOPAIR(" X", X_current);
187
-            SERIAL_ECHOPAIR(" Y", Y_current);
188
-            SERIAL_ECHOLNPAIR(" Z", current_position[Z_AXIS]);
189
-          }
184
+
185
+          if (verbose_level > 3)
186
+            SERIAL_ECHOLNPAIR("Going to: X", X_current, " Y", Y_current, " Z", current_position[Z_AXIS]);
187
+
190 188
           do_blocking_move_to_xy(X_current, Y_current);
191 189
         } // n_legs loop
192 190
       } // n_legs
@@ -220,7 +218,7 @@ void GcodeSuite::M48() {
220 218
       if (verbose_level > 0) {
221 219
         if (verbose_level > 1) {
222 220
           SERIAL_ECHO(n + 1);
223
-          SERIAL_ECHOPAIR(" of ", (int)n_samples);
221
+          SERIAL_ECHOPAIR(" of ", int(n_samples));
224 222
           SERIAL_ECHOPAIR_F(": z: ", sample_set[n], 3);
225 223
           if (verbose_level > 2) {
226 224
             SERIAL_ECHOPAIR_F(" mean: ", mean, 4);

+ 3
- 0
Marlin/src/lcd/language/language_en.h View File

@@ -256,6 +256,9 @@
256 256
 #ifndef MSG_M48_TEST
257 257
   #define MSG_M48_TEST                        _UxGT("M48 Probe Test")
258 258
 #endif
259
+#ifndef MSG_M48_POINT
260
+  #define MSG_M48_POINT                       _UxGT("M48 Point")
261
+#endif
259 262
 #ifndef MSG_M48_DEVIATION
260 263
   #define MSG_M48_DEVIATION                   _UxGT("Deviation")
261 264
 #endif

+ 1
- 0
Marlin/src/lcd/language/language_ru.h View File

@@ -86,6 +86,7 @@
86 86
 
87 87
 #define MSG_M48_TEST                        _UxGT("Проверка датчика Z")
88 88
 #define MSG_M48_DEVIATION                   _UxGT("Отклонение")
89
+#define MSG_M48_POINT                       _UxGT("Точка")
89 90
 
90 91
 // TODO: IDEX Menu
91 92
 #define MSG_OFFSETS_MENU                    _UxGT("Размещение сопел")

Loading…
Cancel
Save