ソースを参照

Save CPU by multiplying by pre-compiled values

Scott Lahteine 8年前
コミット
bad286d52f
1個のファイルの変更4行の追加4行の削除
  1. 4
    4
      Marlin/mesh_bed_leveling.h

+ 4
- 4
Marlin/mesh_bed_leveling.h ファイルの表示

@@ -58,22 +58,22 @@
58 58
     }
59 59
 
60 60
     int8_t cell_index_x(float x) {
61
-      int8_t cx = (x - (MESH_MIN_X)) / (MESH_X_DIST);
61
+      int8_t cx = (x - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
62 62
       return constrain(cx, 0, (MESH_NUM_X_POINTS) - 2);
63 63
     }
64 64
 
65 65
     int8_t cell_index_y(float y) {
66
-      int8_t cy = (y - (MESH_MIN_Y)) / (MESH_Y_DIST);
66
+      int8_t cy = (y - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
67 67
       return constrain(cy, 0, (MESH_NUM_Y_POINTS) - 2);
68 68
     }
69 69
 
70 70
     int8_t probe_index_x(float x) {
71
-      int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) / (MESH_X_DIST);
71
+      int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST));
72 72
       return (px >= 0 && px < (MESH_NUM_X_POINTS)) ? px : -1;
73 73
     }
74 74
 
75 75
     int8_t probe_index_y(float y) {
76
-      int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) / (MESH_Y_DIST);
76
+      int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * (1.0 / (MESH_Y_DIST));
77 77
       return (py >= 0 && py < (MESH_NUM_Y_POINTS)) ? py : -1;
78 78
     }
79 79
 

読み込み中…
キャンセル
保存