Parcourir la source

Propose simpler cel index methods

Scott Lahteine il y a 9 ans
Parent
révision
a1a5cb5393
1 fichiers modifiés avec 4 ajouts et 6 suppressions
  1. 4
    6
      Marlin/mesh_bed_leveling.h

+ 4
- 6
Marlin/mesh_bed_leveling.h Voir le fichier

@@ -54,15 +54,13 @@
54 54
     }
55 55
 
56 56
     int8_t cel_index_x(float x) {
57
-      int8_t cx = 1;
58
-      while (x > get_probe_x(cx) && cx < MESH_NUM_X_POINTS - 1) cx++; // For 3x3 range is 1 to 2
59
-      return cx - 1; // so this will return 0 - 1
57
+      int8_t cx = int(x - (MESH_MIN_X)) / (MESH_X_DIST);
58
+      return constrain(cx, 0, (MESH_NUM_X_POINTS) - 2);
60 59
     }
61 60
 
62 61
     int8_t cel_index_y(float y) {
63
-      int8_t cy = 1;
64
-      while (y > get_probe_y(cy) && cy < MESH_NUM_Y_POINTS - 1) cy++;
65
-      return cy - 1;
62
+      int8_t cy = int(y - (MESH_MIN_Y)) / (MESH_Y_DIST);
63
+      return constrain(cy, 0, (MESH_NUM_Y_POINTS) - 2);
66 64
     }
67 65
 
68 66
     int8_t probe_index_x(float x) {

Chargement…
Annuler
Enregistrer