Skip to content

Commit 9d3ac66

Browse files
committed
Map clean up of UBL
UBL's maps are cleaner. And with a 1 value, G29 O 1 will generate a map suitable to be Cut & Pasted into Excel so a Suface Map can be generated.
1 parent 9a1949a commit 9d3ac66

File tree

3 files changed

+135
-79
lines changed

3 files changed

+135
-79
lines changed

Marlin/UBL.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
bool axis_unhomed_error(bool, bool, bool);
4343
void dump(char * const str, const float &f);
4444
bool ubl_lcd_clicked();
45-
void probe_entire_mesh(const float&, const float&, const bool, const bool);
45+
void probe_entire_mesh(const float&, const float&, const bool, const bool, const bool);
4646
void debug_current_and_destination(char *title);
4747
void ubl_line_to_destination(const float&, const float&, const float&, const float&, const float&, uint8_t);
4848
void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
4949
vector_3 tilt_mesh_based_on_3pts(const float&, const float&, const float&);
5050
float measure_business_card_thickness(const float&);
51-
mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, unsigned int[16]);
51+
mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, unsigned int[16], bool);
5252
void find_mean_mesh_height();
5353
void shift_mesh_height();
5454
bool g29_parameter_parsing();

Marlin/UBL_Bed_Leveling.cpp

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -166,32 +166,34 @@
166166
int8_t i, j;
167167
UNUSED(map_type);
168168

169-
SERIAL_PROTOCOLLNPGM("\nBed Topography Report:\n");
169+
if (map_type==0) {
170+
SERIAL_PROTOCOLLNPGM("\nBed Topography Report:\n");
170171

171-
SERIAL_ECHOPAIR("(", 0);
172-
SERIAL_ECHOPAIR(", ", UBL_MESH_NUM_Y_POINTS - 1);
173-
SERIAL_ECHOPGM(") ");
172+
SERIAL_ECHOPAIR("(", 0);
173+
SERIAL_ECHOPAIR(", ", UBL_MESH_NUM_Y_POINTS - 1);
174+
SERIAL_ECHOPGM(") ");
175+
}
174176

175177
current_xi = ubl.get_cell_index_x(current_position[X_AXIS] + (MESH_X_DIST) / 2.0);
176178
current_yi = ubl.get_cell_index_y(current_position[Y_AXIS] + (MESH_Y_DIST) / 2.0);
177179

178-
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
179-
SERIAL_ECHOPGM(" ");
180-
#if TX_BUFFER_SIZE>0
181-
MYSERIAL.flushTX();
182-
#endif
183-
delay(15);
184-
}
185-
186-
SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS - 1);
187-
SERIAL_ECHOPAIR(",", UBL_MESH_NUM_Y_POINTS - 1);
188-
SERIAL_ECHOLNPGM(")");
189-
190-
// if (map_type || 1) {
180+
if (map_type==0) {
181+
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
182+
SERIAL_ECHOPGM(" ");
183+
#if TX_BUFFER_SIZE>0
184+
MYSERIAL.flushTX();
185+
#endif
186+
delay(15);
187+
}
188+
189+
SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS - 1);
190+
SERIAL_ECHOPAIR(",", UBL_MESH_NUM_Y_POINTS - 1);
191+
SERIAL_ECHOLNPGM(")");
191192

192193
SERIAL_ECHOPAIR("(", UBL_MESH_MIN_X);
193194
SERIAL_ECHOPAIR(",", UBL_MESH_MAX_Y);
194195
SERIAL_CHAR(')');
196+
delay(15);
195197

196198
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
197199
SERIAL_ECHOPGM(" ");
@@ -204,75 +206,82 @@
204206
SERIAL_ECHOPAIR("(", UBL_MESH_MAX_X);
205207
SERIAL_ECHOPAIR(",", UBL_MESH_MAX_Y);
206208
SERIAL_ECHOLNPGM(")");
207-
208-
// }
209+
delay(15);
210+
}
209211

210212
for (j = UBL_MESH_NUM_Y_POINTS - 1; j >= 0; j--) {
211213
for (i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
212214
f = z_values[i][j];
213215

214216
// is the nozzle here? if so, mark the number
215-
SERIAL_CHAR(i == current_xi && j == current_yi ? '[' : ' ');
217+
if (map_type==0)
218+
SERIAL_CHAR(i == current_xi && j == current_yi ? '[' : ' ');
216219

217220
if (isnan(f))
218-
SERIAL_PROTOCOLPGM(" . ");
221+
if (map_type==0) {
222+
SERIAL_PROTOCOLPGM(" . ");
223+
} else
224+
SERIAL_PROTOCOLPGM("NAN");
219225
else {
220226
// if we don't do this, the columns won't line up nicely
221-
if (f >= 0.0) SERIAL_CHAR(' ');
227+
if (f>=0.0 && map_type==0) SERIAL_CHAR(' ');
222228
SERIAL_PROTOCOL_F(f, 3);
223229
idle();
224230
}
231+
if (map_type!=0 && i<UBL_MESH_NUM_X_POINTS-1)
232+
SERIAL_PROTOCOLPGM(",");
233+
225234
#if TX_BUFFER_SIZE>0
226235
MYSERIAL.flushTX();
227236
#endif
228237
delay(15);
229-
if (i == current_xi && j == current_yi) // is the nozzle here? if so, finish marking the number
230-
SERIAL_CHAR(']');
231-
else
232-
SERIAL_PROTOCOL(" ");
233-
234-
SERIAL_CHAR(' ');
238+
if (map_type==0) {
239+
if (i == current_xi && j == current_yi) // is the nozzle here? if so, finish marking the number
240+
SERIAL_CHAR(']');
241+
else
242+
SERIAL_PROTOCOL(" ");
243+
SERIAL_CHAR(' ');
244+
}
235245
}
236246
SERIAL_EOL;
237-
if (j) { // we want the (0,0) up tight against the block of numbers
247+
if (j && map_type==0) { // we want the (0,0) up tight against the block of numbers
238248
SERIAL_CHAR(' ');
239249
SERIAL_EOL;
240250
}
241251
}
242252

243-
// if (map_type) {
244-
SERIAL_ECHOPAIR("(", int(UBL_MESH_MIN_X));
245-
SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
246-
SERIAL_ECHOPGM(") ");
253+
if (map_type==0) {
254+
SERIAL_ECHOPAIR("(", int(UBL_MESH_MIN_X));
255+
SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
256+
SERIAL_ECHOPGM(") ");
247257

248-
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
249-
SERIAL_ECHOPGM(" ");
250-
#if TX_BUFFER_SIZE>0
251-
MYSERIAL.flushTX();
252-
#endif
253-
delay(15);
254-
}
255-
256-
SERIAL_ECHOPAIR("(", int(UBL_MESH_MAX_X));
257-
SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
258-
SERIAL_CHAR(')');
259-
SERIAL_EOL;
258+
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
259+
SERIAL_ECHOPGM(" ");
260+
#if TX_BUFFER_SIZE>0
261+
MYSERIAL.flushTX();
262+
#endif
263+
delay(15);
264+
}
265+
SERIAL_ECHOPAIR("(", int(UBL_MESH_MAX_X));
266+
SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
267+
SERIAL_CHAR(')');
268+
SERIAL_EOL;
260269

261-
SERIAL_ECHOPAIR("(", 0);
262-
SERIAL_ECHOPAIR(",", 0);
263-
SERIAL_ECHOPGM(") ");
270+
SERIAL_ECHOPAIR("(", 0);
271+
SERIAL_ECHOPAIR(",", 0);
272+
SERIAL_ECHOPGM(") ");
264273

265-
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
266-
SERIAL_ECHOPGM(" ");
267-
#if TX_BUFFER_SIZE>0
268-
MYSERIAL.flushTX();
269-
#endif
270-
delay(15);
274+
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
275+
SERIAL_ECHOPGM(" ");
276+
#if TX_BUFFER_SIZE>0
277+
MYSERIAL.flushTX();
278+
#endif
279+
delay(15);
280+
}
281+
SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS-1);
282+
SERIAL_ECHOPAIR(",", 0);
283+
SERIAL_ECHOLNPGM(")");
271284
}
272-
273-
SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS-1);
274-
SERIAL_ECHOPAIR(",", 0);
275-
SERIAL_ECHOLNPGM(")");
276285
}
277286

278287
bool unified_bed_leveling::sanity_check() {

0 commit comments

Comments
 (0)