Browse Source

Apply const to MBL class methods

pull/1/head
Scott Lahteine 8 years ago
parent
commit
85c2b96685
  1. 32
      Marlin/mesh_bed_leveling.h

32
Marlin/mesh_bed_leveling.h

@ -36,50 +36,50 @@
void reset(); void reset();
static FORCE_INLINE float get_probe_x(int8_t i) { return MESH_MIN_X + (MESH_X_DIST) * i; } static FORCE_INLINE float get_probe_x(const int8_t i) { return MESH_MIN_X + (MESH_X_DIST) * i; }
static FORCE_INLINE float get_probe_y(int8_t i) { return MESH_MIN_Y + (MESH_Y_DIST) * i; } static FORCE_INLINE float get_probe_y(const int8_t i) { return MESH_MIN_Y + (MESH_Y_DIST) * i; }
void set_z(const int8_t px, const int8_t py, const float z) { z_values[py][px] = z; } void set_z(const int8_t px, const int8_t py, const float &z) { z_values[py][px] = z; }
bool active() { return TEST(status, MBL_STATUS_ACTIVE_BIT); } bool active() const { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
void set_active(bool onOff) { if (onOff) SBI(status, MBL_STATUS_ACTIVE_BIT); else CBI(status, MBL_STATUS_ACTIVE_BIT); } void set_active(const bool onOff) { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
bool has_mesh() { return TEST(status, MBL_STATUS_HAS_MESH_BIT); } bool has_mesh() const { return TEST(status, MBL_STATUS_HAS_MESH_BIT); }
void set_has_mesh(bool onOff) { if (onOff) SBI(status, MBL_STATUS_HAS_MESH_BIT); else CBI(status, MBL_STATUS_HAS_MESH_BIT); } void set_has_mesh(const bool onOff) { onOff ? SBI(status, MBL_STATUS_HAS_MESH_BIT) : CBI(status, MBL_STATUS_HAS_MESH_BIT); }
inline void zigzag(int8_t index, int8_t &px, int8_t &py) { inline void zigzag(const int8_t index, int8_t &px, int8_t &py) const {
px = index % (MESH_NUM_X_POINTS); px = index % (MESH_NUM_X_POINTS);
py = index / (MESH_NUM_X_POINTS); py = index / (MESH_NUM_X_POINTS);
if (py & 1) px = (MESH_NUM_X_POINTS - 1) - px; // Zig zag if (py & 1) px = (MESH_NUM_X_POINTS - 1) - px; // Zig zag
} }
void set_zigzag_z(int8_t index, float z) { void set_zigzag_z(const int8_t index, const float &z) {
int8_t px, py; int8_t px, py;
zigzag(index, px, py); zigzag(index, px, py);
set_z(px, py, z); set_z(px, py, z);
} }
int8_t cell_index_x(float x) { int8_t cell_index_x(const float &x) const {
int8_t cx = (x - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST)); int8_t cx = (x - (MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
return constrain(cx, 0, (MESH_NUM_X_POINTS) - 2); return constrain(cx, 0, (MESH_NUM_X_POINTS) - 2);
} }
int8_t cell_index_y(float y) { int8_t cell_index_y(const float &y) const {
int8_t cy = (y - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST)); int8_t cy = (y - (MESH_MIN_Y)) * (1.0 / (MESH_Y_DIST));
return constrain(cy, 0, (MESH_NUM_Y_POINTS) - 2); return constrain(cy, 0, (MESH_NUM_Y_POINTS) - 2);
} }
int8_t probe_index_x(float x) { int8_t probe_index_x(const float &x) const {
int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST)); int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * (1.0 / (MESH_X_DIST));
return (px >= 0 && px < (MESH_NUM_X_POINTS)) ? px : -1; return (px >= 0 && px < (MESH_NUM_X_POINTS)) ? px : -1;
} }
int8_t probe_index_y(float y) { int8_t probe_index_y(const float &y) const {
int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * (1.0 / (MESH_Y_DIST)); int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * (1.0 / (MESH_Y_DIST));
return (py >= 0 && py < (MESH_NUM_Y_POINTS)) ? py : -1; return (py >= 0 && py < (MESH_NUM_Y_POINTS)) ? py : -1;
} }
float calc_z0(float a0, float a1, float z1, float a2, float z2) { float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) const {
float delta_z = (z2 - z1) / (a2 - a1); const float delta_z = (z2 - z1) / (a2 - a1);
float delta_a = a0 - a1; const float delta_a = a0 - a1;
return z1 + delta_a * delta_z; return z1 + delta_a * delta_z;
} }

Loading…
Cancel
Save