소스 검색

Merge pull request #4555 from thinkyhead/rc_mbl_index_rounding

Remove premature int-cast from MBL cell index methods
Scott Lahteine 8 년 전
부모
커밋
ed0b50ebee
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4
    4
      Marlin/mesh_bed_leveling.h

+ 4
- 4
Marlin/mesh_bed_leveling.h 파일 보기

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

Loading…
취소
저장