|
@@ -36,54 +36,58 @@
|
36
|
36
|
|
37
|
37
|
void reset();
|
38
|
38
|
|
39
|
|
- static FORCE_INLINE float get_probe_x(int8_t i) { return MESH_MIN_X + (MESH_X_DIST) * i; }
|
40
|
|
- static FORCE_INLINE float get_probe_y(int8_t i) { return MESH_MIN_Y + (MESH_Y_DIST) * i; }
|
41
|
|
- void set_z(const int8_t px, const int8_t py, const float z) { z_values[py][px] = z; }
|
|
39
|
+ static FORCE_INLINE float get_probe_x(const int8_t i) { return MESH_MIN_X + (MESH_X_DIST) * i; }
|
|
40
|
+ static FORCE_INLINE float get_probe_y(const int8_t i) { return MESH_MIN_Y + (MESH_Y_DIST) * i; }
|
|
41
|
+ void set_z(const int8_t px, const int8_t py, const float &z) { z_values[py][px] = z; }
|
42
|
42
|
|
43
|
|
- bool active() { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
|
44
|
|
- void set_active(bool onOff) { if (onOff) SBI(status, MBL_STATUS_ACTIVE_BIT); else CBI(status, MBL_STATUS_ACTIVE_BIT); }
|
45
|
|
- bool has_mesh() { return TEST(status, MBL_STATUS_HAS_MESH_BIT); }
|
46
|
|
- void set_has_mesh(bool onOff) { if (onOff) SBI(status, MBL_STATUS_HAS_MESH_BIT); else CBI(status, MBL_STATUS_HAS_MESH_BIT); }
|
|
43
|
+ bool active() const { return TEST(status, MBL_STATUS_ACTIVE_BIT); }
|
|
44
|
+ void set_active(const bool onOff) { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
|
|
45
|
+ bool has_mesh() const { return TEST(status, MBL_STATUS_HAS_MESH_BIT); }
|
|
46
|
+ void set_has_mesh(const bool onOff) { onOff ? SBI(status, MBL_STATUS_HAS_MESH_BIT) : CBI(status, MBL_STATUS_HAS_MESH_BIT); }
|
47
|
47
|
|
48
|
|
- inline void zigzag(int8_t index, int8_t &px, int8_t &py) {
|
|
48
|
+ inline void zigzag(const int8_t index, int8_t &px, int8_t &py) const {
|
49
|
49
|
px = index % (MESH_NUM_X_POINTS);
|
50
|
50
|
py = index / (MESH_NUM_X_POINTS);
|
51
|
51
|
if (py & 1) px = (MESH_NUM_X_POINTS - 1) - px; // Zig zag
|
52
|
52
|
}
|
53
|
53
|
|
54
|
|
- void set_zigzag_z(int8_t index, float z) {
|
|
54
|
+ void set_zigzag_z(const int8_t index, const float &z) {
|
55
|
55
|
int8_t px, py;
|
56
|
56
|
zigzag(index, px, py);
|
57
|
57
|
set_z(px, py, z);
|
58
|
58
|
}
|
59
|
59
|
|
60
|
|
- int8_t cell_index_x(float x) {
|
|
60
|
+ int8_t cell_index_x(const float &x) const {
|
61
|
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
|
|
- int8_t cell_index_y(float y) {
|
|
65
|
+ int8_t cell_index_y(const float &y) const {
|
66
|
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
|
|
- int8_t probe_index_x(float x) {
|
|
70
|
+ int8_t probe_index_x(const float &x) const {
|
71
|
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
|
|
- int8_t probe_index_y(float y) {
|
|
75
|
+ int8_t probe_index_y(const float &y) const {
|
76
|
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
|
|
80
|
|
- float calc_z0(float a0, float a1, float z1, float a2, float z2) {
|
81
|
|
- float delta_z = (z2 - z1) / (a2 - a1);
|
82
|
|
- float delta_a = a0 - a1;
|
|
80
|
+ float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) const {
|
|
81
|
+ const float delta_z = (z2 - z1) / (a2 - a1);
|
|
82
|
+ const float delta_a = a0 - a1;
|
83
|
83
|
return z1 + delta_a * delta_z;
|
84
|
84
|
}
|
85
|
85
|
|
86
|
|
- float get_z(float x0, float y0) {
|
|
86
|
+ float get_z(const float &x0, const float &y0
|
|
87
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
88
|
+ , const float &factor
|
|
89
|
+ #endif
|
|
90
|
+ ) const {
|
87
|
91
|
int8_t cx = cell_index_x(x0),
|
88
|
92
|
cy = cell_index_y(y0);
|
89
|
93
|
if (cx < 0 || cy < 0) return z_offset;
|
|
@@ -96,7 +100,12 @@
|
96
|
100
|
float z0 = calc_z0(y0,
|
97
|
101
|
get_probe_y(cy), z1,
|
98
|
102
|
get_probe_y(cy + 1), z2);
|
99
|
|
- return z0 + z_offset;
|
|
103
|
+
|
|
104
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
105
|
+ return z0 * factor + z_offset;
|
|
106
|
+ #else
|
|
107
|
+ return z0 + z_offset;
|
|
108
|
+ #endif
|
100
|
109
|
}
|
101
|
110
|
};
|
102
|
111
|
|