|
@@ -24,6 +24,8 @@
|
24
|
24
|
|
25
|
25
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
26
|
26
|
|
|
27
|
+ //#define UBL_DEVEL_DEBUGGING
|
|
28
|
+
|
27
|
29
|
#include "ubl.h"
|
28
|
30
|
|
29
|
31
|
#include "../../../Marlin.h"
|
|
@@ -728,8 +730,31 @@
|
728
|
730
|
z_values[x][y] += g29_constant;
|
729
|
731
|
}
|
730
|
732
|
|
731
|
|
- #if HAS_BED_PROBE
|
|
733
|
+ #if ENABLED(NEWPANEL)
|
|
734
|
+
|
|
735
|
+ typedef void (*clickFunc_t)();
|
|
736
|
+
|
|
737
|
+ bool click_and_hold(const clickFunc_t func=NULL) {
|
|
738
|
+ if (is_lcd_clicked()) {
|
|
739
|
+ lcd_quick_feedback();
|
|
740
|
+ const millis_t nxt = millis() + 1500UL;
|
|
741
|
+ while (is_lcd_clicked()) { // Loop while the encoder is pressed. Uses hardware flag!
|
|
742
|
+ idle(); // idle, of course
|
|
743
|
+ if (ELAPSED(millis(), nxt)) { // After 1.5 seconds
|
|
744
|
+ lcd_quick_feedback();
|
|
745
|
+ if (func) (*func)();
|
|
746
|
+ wait_for_release();
|
|
747
|
+ safe_delay(50); // Debounce the Encoder wheel
|
|
748
|
+ return true;
|
|
749
|
+ }
|
|
750
|
+ }
|
|
751
|
+ }
|
|
752
|
+ return false;
|
|
753
|
+ }
|
732
|
754
|
|
|
755
|
+ #endif // NEWPANEL
|
|
756
|
+
|
|
757
|
+ #if HAS_BED_PROBE
|
733
|
758
|
/**
|
734
|
759
|
* Probe all invalidated locations of the mesh that can be reached by the probe.
|
735
|
760
|
* This attempts to fill in locations closest to the nozzle's start location first.
|
|
@@ -754,10 +779,9 @@
|
754
|
779
|
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
|
755
|
780
|
lcd_quick_feedback();
|
756
|
781
|
STOW_PROBE();
|
757
|
|
- while (is_lcd_clicked()) idle();
|
|
782
|
+ wait_for_release();
|
758
|
783
|
lcd_external_control = false;
|
759
|
784
|
restore_ubl_active_state_and_leave();
|
760
|
|
- safe_delay(50); // Debounce the Encoder wheel
|
761
|
785
|
return;
|
762
|
786
|
}
|
763
|
787
|
#endif
|
|
@@ -894,19 +918,20 @@
|
894
|
918
|
|
895
|
919
|
#if ENABLED(NEWPANEL)
|
896
|
920
|
|
897
|
|
- float unified_bed_leveling::measure_point_with_encoder() {
|
898
|
|
-
|
899
|
|
- while (is_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
900
|
|
- delay(50); // debounce
|
901
|
|
-
|
902
|
|
- KEEPALIVE_STATE(PAUSED_FOR_USER);
|
903
|
|
- while (!is_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
|
921
|
+ void unified_bed_leveling::move_z_with_encoder(const float &multiplier) {
|
|
922
|
+ wait_for_release();
|
|
923
|
+ while (!is_lcd_clicked()) {
|
904
|
924
|
idle();
|
905
|
925
|
if (encoder_diff) {
|
906
|
|
- do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(encoder_diff));
|
|
926
|
+ do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * multiplier);
|
907
|
927
|
encoder_diff = 0;
|
908
|
928
|
}
|
909
|
929
|
}
|
|
930
|
+ }
|
|
931
|
+
|
|
932
|
+ float unified_bed_leveling::measure_point_with_encoder() {
|
|
933
|
+ KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
934
|
+ move_z_with_encoder(0.01);
|
910
|
935
|
KEEPALIVE_STATE(IN_HANDLER);
|
911
|
936
|
return current_position[Z_AXIS];
|
912
|
937
|
}
|
|
@@ -953,12 +978,19 @@
|
953
|
978
|
return thickness;
|
954
|
979
|
}
|
955
|
980
|
|
|
981
|
+ void abort_manual_probe_remaining_mesh() {
|
|
982
|
+ SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
|
|
983
|
+ do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
|
984
|
+ lcd_external_control = false;
|
|
985
|
+ KEEPALIVE_STATE(IN_HANDLER);
|
|
986
|
+ ubl.restore_ubl_active_state_and_leave();
|
|
987
|
+ }
|
|
988
|
+
|
956
|
989
|
void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
|
957
|
990
|
|
958
|
991
|
lcd_external_control = true;
|
959
|
992
|
|
960
|
993
|
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
|
961
|
|
-
|
962
|
994
|
do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
|
963
|
995
|
|
964
|
996
|
lcd_return_to_status();
|
|
@@ -989,34 +1021,15 @@
|
989
|
1021
|
const float z_step = 0.01; // existing behavior: 0.01mm per click, occasionally step
|
990
|
1022
|
//const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS]; // approx one step each click
|
991
|
1023
|
|
992
|
|
- while (is_lcd_clicked()) delay(50); // wait for user to release encoder wheel
|
993
|
|
- delay(50); // debounce
|
994
|
|
- while (!is_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
|
995
|
|
- idle();
|
996
|
|
- if (encoder_diff) {
|
997
|
|
- do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * z_step);
|
998
|
|
- encoder_diff = 0;
|
999
|
|
- }
|
1000
|
|
- }
|
1001
|
|
-
|
1002
|
|
- // this sequence to detect an is_lcd_clicked() debounce it and leave if it is
|
1003
|
|
- // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp). This
|
1004
|
|
- // should be redone and compressed.
|
1005
|
|
- const millis_t nxt = millis() + 1500L;
|
1006
|
|
- while (is_lcd_clicked()) { // debounce and watch for abort
|
1007
|
|
- idle();
|
1008
|
|
- if (ELAPSED(millis(), nxt)) {
|
1009
|
|
- SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
|
1010
|
|
- do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
1011
|
|
-
|
1012
|
|
- lcd_quick_feedback();
|
1013
|
|
- while (is_lcd_clicked()) idle();
|
1014
|
|
- lcd_external_control = false;
|
|
1024
|
+ move_z_with_encoder(z_step);
|
1015
|
1025
|
|
1016
|
|
- KEEPALIVE_STATE(IN_HANDLER);
|
1017
|
|
- restore_ubl_active_state_and_leave();
|
1018
|
|
- return;
|
1019
|
|
- }
|
|
1026
|
+ if (click_and_hold()) {
|
|
1027
|
+ SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
|
|
1028
|
+ do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
|
1029
|
+ lcd_external_control = false;
|
|
1030
|
+ KEEPALIVE_STATE(IN_HANDLER);
|
|
1031
|
+ restore_ubl_active_state_and_leave();
|
|
1032
|
+ return;
|
1020
|
1033
|
}
|
1021
|
1034
|
|
1022
|
1035
|
z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - thick;
|
|
@@ -1150,36 +1163,39 @@
|
1150
|
1163
|
return UBL_OK;
|
1151
|
1164
|
}
|
1152
|
1165
|
|
1153
|
|
- static int ubl_state_at_invocation = 0,
|
1154
|
|
- ubl_state_recursion_chk = 0;
|
1155
|
|
-
|
1156
|
|
- void unified_bed_leveling::save_ubl_active_state_and_disable() {
|
1157
|
|
- ubl_state_recursion_chk++;
|
1158
|
|
- if (ubl_state_recursion_chk != 1) {
|
1159
|
|
- SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
|
|
1166
|
+ static uint8_t ubl_state_at_invocation = 0;
|
1160
|
1167
|
|
1161
|
|
- #if ENABLED(NEWPANEL)
|
1162
|
|
- LCD_MESSAGEPGM(MSG_UBL_SAVE_ERROR);
|
1163
|
|
- lcd_quick_feedback();
|
1164
|
|
- #endif
|
|
1168
|
+ #ifdef UBL_DEVEL_DEBUGGING
|
|
1169
|
+ static uint8_t ubl_state_recursion_chk = 0;
|
|
1170
|
+ #endif
|
1165
|
1171
|
|
1166
|
|
- return;
|
1167
|
|
- }
|
|
1172
|
+ void unified_bed_leveling::save_ubl_active_state_and_disable() {
|
|
1173
|
+ #ifdef UBL_DEVEL_DEBUGGING
|
|
1174
|
+ ubl_state_recursion_chk++;
|
|
1175
|
+ if (ubl_state_recursion_chk != 1) {
|
|
1176
|
+ SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
|
|
1177
|
+ #if ENABLED(NEWPANEL)
|
|
1178
|
+ LCD_MESSAGEPGM(MSG_UBL_SAVE_ERROR);
|
|
1179
|
+ lcd_quick_feedback();
|
|
1180
|
+ #endif
|
|
1181
|
+ return;
|
|
1182
|
+ }
|
|
1183
|
+ #endif
|
1168
|
1184
|
ubl_state_at_invocation = planner.leveling_active;
|
1169
|
1185
|
set_bed_leveling_enabled(false);
|
1170
|
1186
|
}
|
1171
|
1187
|
|
1172
|
1188
|
void unified_bed_leveling::restore_ubl_active_state_and_leave() {
|
1173
|
|
- if (--ubl_state_recursion_chk) {
|
1174
|
|
- SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
|
1175
|
|
-
|
1176
|
|
- #if ENABLED(NEWPANEL)
|
1177
|
|
- LCD_MESSAGEPGM(MSG_UBL_RESTORE_ERROR);
|
1178
|
|
- lcd_quick_feedback();
|
1179
|
|
- #endif
|
1180
|
|
-
|
1181
|
|
- return;
|
1182
|
|
- }
|
|
1189
|
+ #ifdef UBL_DEVEL_DEBUGGING
|
|
1190
|
+ if (--ubl_state_recursion_chk) {
|
|
1191
|
+ SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
|
|
1192
|
+ #if ENABLED(NEWPANEL)
|
|
1193
|
+ LCD_MESSAGEPGM(MSG_UBL_RESTORE_ERROR);
|
|
1194
|
+ lcd_quick_feedback();
|
|
1195
|
+ #endif
|
|
1196
|
+ return;
|
|
1197
|
+ }
|
|
1198
|
+ #endif
|
1183
|
1199
|
set_bed_leveling_enabled(ubl_state_at_invocation);
|
1184
|
1200
|
}
|
1185
|
1201
|
|
|
@@ -1249,28 +1265,30 @@
|
1249
|
1265
|
SERIAL_EOL();
|
1250
|
1266
|
safe_delay(50);
|
1251
|
1267
|
|
1252
|
|
- SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
|
1253
|
|
- SERIAL_EOL();
|
1254
|
|
- SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
|
1255
|
|
- SERIAL_EOL();
|
1256
|
|
- safe_delay(50);
|
|
1268
|
+ #ifdef UBL_DEVEL_DEBUGGING
|
|
1269
|
+ SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
|
|
1270
|
+ SERIAL_EOL();
|
|
1271
|
+ SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
|
|
1272
|
+ SERIAL_EOL();
|
|
1273
|
+ safe_delay(50);
|
1257
|
1274
|
|
1258
|
|
- SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
|
1259
|
|
- SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
|
1260
|
|
- safe_delay(50);
|
|
1275
|
+ SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
|
|
1276
|
+ SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
|
|
1277
|
+ safe_delay(50);
|
1261
|
1278
|
|
1262
|
|
- SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
|
1263
|
|
- SERIAL_EOL();
|
1264
|
|
- SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
|
1265
|
|
- SERIAL_EOL();
|
1266
|
|
- safe_delay(25);
|
|
1279
|
+ SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
|
|
1280
|
+ SERIAL_EOL();
|
|
1281
|
+ SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
|
|
1282
|
+ SERIAL_EOL();
|
|
1283
|
+ safe_delay(25);
|
1267
|
1284
|
|
1268
|
|
- SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
|
1269
|
|
- safe_delay(50);
|
|
1285
|
+ SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
|
|
1286
|
+ safe_delay(50);
|
1270
|
1287
|
|
1271
|
|
- SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
|
1272
|
|
- SERIAL_PROTOCOLLNPGM(" meshes.\n");
|
1273
|
|
- safe_delay(25);
|
|
1288
|
+ SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
|
|
1289
|
+ SERIAL_PROTOCOLLNPGM(" meshes.\n");
|
|
1290
|
+ safe_delay(25);
|
|
1291
|
+ #endif // UBL_DEVEL_DEBUGGING
|
1274
|
1292
|
|
1275
|
1293
|
if (!sanity_check()) {
|
1276
|
1294
|
echo_name();
|
|
@@ -1456,6 +1474,12 @@
|
1456
|
1474
|
|
1457
|
1475
|
#if ENABLED(NEWPANEL)
|
1458
|
1476
|
|
|
1477
|
+ void abort_fine_tune() {
|
|
1478
|
+ lcd_return_to_status();
|
|
1479
|
+ do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
|
1480
|
+ LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
|
|
1481
|
+ }
|
|
1482
|
+
|
1459
|
1483
|
void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
|
1460
|
1484
|
if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
|
1461
|
1485
|
g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
|
|
@@ -1513,13 +1537,13 @@
|
1513
|
1537
|
|
1514
|
1538
|
lcd_mesh_edit_setup(new_z);
|
1515
|
1539
|
|
1516
|
|
- do {
|
|
1540
|
+ while (!is_lcd_clicked()) {
|
1517
|
1541
|
new_z = lcd_mesh_edit();
|
1518
|
1542
|
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
|
1519
|
1543
|
do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
|
1520
|
1544
|
#endif
|
1521
|
1545
|
idle();
|
1522
|
|
- } while (!is_lcd_clicked());
|
|
1546
|
+ }
|
1523
|
1547
|
|
1524
|
1548
|
if (!lcd_map_control) lcd_return_to_status();
|
1525
|
1549
|
|
|
@@ -1531,19 +1555,8 @@
|
1531
|
1555
|
// this sequence to detect an is_lcd_clicked() debounce it and leave if it is
|
1532
|
1556
|
// a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp). This
|
1533
|
1557
|
// should be redone and compressed.
|
1534
|
|
- const millis_t nxt = millis() + 1500UL;
|
1535
|
|
- while (is_lcd_clicked()) { // debounce and watch for abort
|
1536
|
|
- idle();
|
1537
|
|
- if (ELAPSED(millis(), nxt)) {
|
1538
|
|
- lcd_return_to_status();
|
1539
|
|
- do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
1540
|
|
- LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
|
1541
|
|
-
|
1542
|
|
- while (is_lcd_clicked()) idle();
|
1543
|
|
-
|
1544
|
|
- goto FINE_TUNE_EXIT;
|
1545
|
|
- }
|
1546
|
|
- }
|
|
1558
|
+ if (click_and_hold(abort_fine_tune))
|
|
1559
|
+ goto FINE_TUNE_EXIT;
|
1547
|
1560
|
|
1548
|
1561
|
safe_delay(20); // We don't want any switch noise.
|
1549
|
1562
|
|