Kaynağa Gözat

[2.0] Fix up G33, LPC1768 + SDCARD_SORT_ALPHA (#8250)

* Update Conditionals_post.h

* Add a cast to round() to convert to a unsigned int

Add's a cast to round() so that it will compile properly. round() returns a float which must be cast to a integer for the following % operation. Use a unsigned int as a negative index to an array is wrong. Should never be more than 255 points allowing us to use a 8 bit cast.

* Update G33.cpp
Colten Edwards 7 yıl önce
ebeveyn
işleme
e0a6ee8da5

+ 19
- 26
Marlin/src/gcode/calibrate/G33.cpp Dosyayı Görüntüle

@@ -155,7 +155,7 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
155 155
                 dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
156 156
   #endif
157 157
 
158
-      LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
158
+  LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
159 159
 
160 160
   if (!_0p_calibration) {
161 161
 
@@ -199,30 +199,23 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
199 199
         for (int8_t circle = -offset; circle <= offset; circle++) {
200 200
           const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
201 201
                       r = delta_calibration_radius * (1 + 0.1 * (zig_zag ? circle : - circle)),
202
-                      interpol = fmod(axis, 1);
203
-          #if ENABLED(PROBE_MANUALLY)
204
-             float z_temp = lcd_probe_pt(cos(a) * r, sin(a) * r);
205
-          #else
206
-            float z_temp = probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
207
-          #endif
202
+                      interpol = FMOD(axis, 1);
203
+          const float z_temp =
204
+            #if ENABLED(PROBE_MANUALLY)
205
+              lcd_probe_pt(cos(a) * r, sin(a) * r)
206
+            #else
207
+              probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1)
208
+            #endif
209
+          ;
208 210
           // split probe point to neighbouring calibration points
209
-          z_at_pt[round(axis - interpol + NPP - 1) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
210
-          z_at_pt[round(axis - interpol) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
211
+          z_at_pt[uint8_t(round(axis - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
212
+          z_at_pt[uint8_t(round(axis - interpol))           % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
211 213
         }
212 214
         zig_zag = !zig_zag;
213 215
       }
214 216
       if (_7p_intermed_points)
215
-        LOOP_CAL_RAD(axis) {
216
-/*
217
-        // average intermediate points to towers and opposites - only required with _7P_STEP >= 2
218
-          for (int8_t i = 1; i < _7P_STEP; i++) {
219
-            const float interpol = i * (1.0 / _7P_STEP);
220
-            z_at_pt[axis] += (z_at_pt[(axis + NPP - i - 1) % NPP + 1]
221
-                             + z_at_pt[axis + i]) * sq(cos(RADIANS(interpol * 90)));
222
-          }
223
-*/
224
-          z_at_pt[axis] /= _7P_STEP  / steps;
225
-        }
217
+        LOOP_CAL_RAD(axis)
218
+          z_at_pt[axis] /= _7P_STEP / steps;
226 219
     }
227 220
 
228 221
 
@@ -342,14 +335,14 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
342 335
       recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
343 336
       switch (axis) {
344 337
         case A_AXIS :
345
-        a_fac += 4.0 / (          Z06(__B) -Z06(__C)           +Z06(_CA) -Z06(_AB)); // Offset by alpha tower angle
346
-        break;
338
+          a_fac += 4.0 / (          Z06(__B) -Z06(__C)           +Z06(_CA) -Z06(_AB)); // Offset by alpha tower angle
339
+          break;
347 340
         case B_AXIS :
348
-        a_fac += 4.0 / (-Z06(__A)          +Z06(__C) -Z06(_BC)           +Z06(_AB)); // Offset by beta tower angle
349
-        break;
341
+          a_fac += 4.0 / (-Z06(__A)          +Z06(__C) -Z06(_BC)           +Z06(_AB)); // Offset by beta tower angle
342
+          break;
350 343
         case C_AXIS :
351
-        a_fac += 4.0 / (Z06(__A) -Z06(__B)           +Z06(_BC) -Z06(_CA)          ); // Offset by gamma tower angle
352
-        break;
344
+          a_fac += 4.0 / (Z06(__A) -Z06(__B)           +Z06(_BC) -Z06(_CA)          ); // Offset by gamma tower angle
345
+          break;
353 346
       }
354 347
     }
355 348
     a_fac /= 3.0;

+ 5
- 4
Marlin/src/inc/Conditionals_post.h Dosyayı Görüntüle

@@ -1079,10 +1079,6 @@
1079 1079
   #undef MOTOR_CURRENT
1080 1080
 #endif
1081 1081
 
1082
-#if ENABLED(SDCARD_SORT_ALPHA)
1083
-  #define HAS_FOLDER_SORTING (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
1084
-#endif
1085
-
1086 1082
 // Updated G92 behavior shifts the workspace
1087 1083
 #define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
1088 1084
 // The home offset also shifts the coordinate space
@@ -1197,4 +1193,9 @@
1197 1193
   #endif
1198 1194
 #endif
1199 1195
 
1196
+// needs to be here so that we catch the above changes to our defines
1197
+#if ENABLED(SDCARD_SORT_ALPHA)
1198
+  #define HAS_FOLDER_SORTING (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
1199
+#endif
1200
+
1200 1201
 #endif // CONDITIONALS_POST_H

Loading…
İptal
Kaydet