19
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
*
21
21
*/
22
-
22
+
23
23
/* *
24
24
* Bed Level Tools for Pro UI
25
25
* Extended by: Miguel A. Risco-Castillo (MRISCOC)
26
- * Version: 2.0 .0
27
- * Date: 2022/05/23
28
- *
26
+ * Version: 2.1 .0
27
+ * Date: 2022/08/27
28
+ *
29
29
* Based on the original work of: Henri-J-Norden
30
30
* https://github.com/Jyers/Marlin/pull/126
31
+ *
32
+ * This program is free software: you can redistribute it and/or modify
33
+ * it under the terms of the GNU General Public License as published by
34
+ * the Free Software Foundation, either version 3 of the License, or
35
+ * (at your option) any later version.
36
+ *
37
+ * This program is distributed in the hope that it will be useful,
38
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40
+ * GNU General Public License for more details.
41
+ *
42
+ * You should have received a copy of the GNU General Public License
43
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
44
+ *
31
45
*/
32
46
33
47
#include " ../../../inc/MarlinConfigPre.h"
34
- #include " bedlevel_tools.h"
35
48
36
49
#if BOTH(DWIN_LCD_PROUI, HAS_LEVELING)
37
50
38
51
#include " ../../marlinui.h"
39
52
#include " ../../../core/types.h"
40
- #include " dwin.h"
41
- #include " dwinui.h"
42
- #include " dwin_popup.h"
43
53
#include " ../../../feature/bedlevel/bedlevel.h"
44
54
#include " ../../../module/probe.h"
45
55
#include " ../../../gcode/gcode.h"
48
58
#include " ../../../libs/least_squares_fit.h"
49
59
#include " ../../../libs/vector_3.h"
50
60
51
- BedLevelToolsClass BedLevelTools;
61
+ #include " dwin.h"
62
+ #include " dwinui.h"
63
+ #include " dwin_popup.h"
64
+ #include " bedlevel_tools.h"
65
+
66
+ BedLevelToolsClass bedLevelTools;
52
67
53
- #if USE_UBL_VIEWER
68
+ #if ENABLED( USE_UBL_VIEWER)
54
69
bool BedLevelToolsClass::viewer_asymmetric_range = false ;
55
70
bool BedLevelToolsClass::viewer_print_value = false ;
56
71
#endif
@@ -153,26 +168,30 @@ void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y,
153
168
}
154
169
}
155
170
171
+ // Move / Probe methods. As examples, not yet used.
156
172
void BedLevelToolsClass::MoveToXYZ () {
157
- BedLevelTools .goto_mesh_value = true ;
158
- BedLevelTools .manual_move (BedLevelTools .mesh_x , BedLevelTools .mesh_y , false );
173
+ bedLevelTools .goto_mesh_value = true ;
174
+ bedLevelTools .manual_move (bedLevelTools .mesh_x , bedLevelTools .mesh_y , false );
159
175
}
160
176
void BedLevelToolsClass::MoveToXY () {
161
- BedLevelTools .goto_mesh_value = false ;
162
- BedLevelTools .manual_move (BedLevelTools .mesh_x , BedLevelTools .mesh_y , false );
177
+ bedLevelTools .goto_mesh_value = false ;
178
+ bedLevelTools .manual_move (bedLevelTools .mesh_x , bedLevelTools .mesh_y , false );
163
179
}
164
180
void BedLevelToolsClass::MoveToZ () {
165
- BedLevelTools .goto_mesh_value = true ;
166
- BedLevelTools .manual_move (BedLevelTools .mesh_x , BedLevelTools .mesh_y , true );
181
+ bedLevelTools .goto_mesh_value = true ;
182
+ bedLevelTools .manual_move (bedLevelTools .mesh_x , bedLevelTools .mesh_y , true );
167
183
}
168
184
void BedLevelToolsClass::ProbeXY () {
169
- sprintf_P (cmd, PSTR (" G30X%sY%s" ),
170
- dtostrf (bedlevel.get_mesh_x (BedLevelTools.mesh_x ), 1 , 2 , str_1),
171
- dtostrf (bedlevel.get_mesh_y (BedLevelTools.mesh_y ), 1 , 2 , str_2)
185
+ const uint16_t Clear = Z_CLEARANCE_DEPLOY_PROBE;
186
+ sprintf_P (cmd, PSTR (" G0Z%i\n G30X%sY%s" ),
187
+ Clear,
188
+ dtostrf (bedlevel.get_mesh_x (bedLevelTools.mesh_x ), 1 , 2 , str_1),
189
+ dtostrf (bedlevel.get_mesh_y (bedLevelTools.mesh_y ), 1 , 2 , str_2)
172
190
);
173
191
gcode.process_subcommands_now (cmd);
174
192
}
175
193
194
+ // Accessors
176
195
float BedLevelToolsClass::get_max_value () {
177
196
float max = __FLT_MAX__ * -1 ;
178
197
GRID_LOOP (x, y) {
@@ -191,18 +210,16 @@ float BedLevelToolsClass::get_min_value() {
191
210
return min;
192
211
}
193
212
213
+ // Return 'true' if mesh is good and within LCD limits
194
214
bool BedLevelToolsClass::meshvalidate () {
195
- float min = __FLT_MAX__, max = __FLT_MAX__ * -1 ;
196
-
197
215
GRID_LOOP (x, y) {
198
- if (isnan (bedlevel.z_values [x][y])) return false ;
199
- if (bedlevel.z_values [x][y] < min) min = bedlevel.z_values [x][y];
200
- if (bedlevel.z_values [x][y] > max) max = bedlevel.z_values [x][y];
216
+ const float v = bedlevel.z_values [x][y];
217
+ if (isnan (v) || !WITHIN (v, UBL_Z_OFFSET_MIN, UBL_Z_OFFSET_MAX)) return false ;
201
218
}
202
- return WITHIN (max, MESH_Z_OFFSET_MIN, MESH_Z_OFFSET_MAX) ;
219
+ return true ;
203
220
}
204
221
205
- #if USE_UBL_VIEWER
222
+ #if ENABLED( USE_UBL_VIEWER)
206
223
207
224
void BedLevelToolsClass::Draw_Bed_Mesh (int16_t selected /* = -1*/ , uint8_t gridline_width /* = 1*/ , uint16_t padding_x /* = 8*/ , uint16_t padding_y_top /* = 40 + 53 - 7*/ ) {
208
225
drawing_mesh = true ;
0 commit comments