|
33 | 33 | #include "planner.h"
|
34 | 34 | #include "ultralcd.h"
|
35 | 35 |
|
36 |
| - #include <avr/io.h> |
| 36 | + #include <math.h> |
37 | 37 |
|
38 | 38 | void lcd_babystep_z();
|
39 | 39 | void lcd_return_to_status();
|
|
300 | 300 |
|
301 | 301 | int ubl_eeprom_start = -1;
|
302 | 302 | bool ubl_has_control_of_lcd_panel = false;
|
303 |
| - volatile uint8_t ubl_encoderDiff = 0; // Volatile because it's changed by Temperature ISR button update |
| 303 | + volatile int8_t ubl_encoderDiff = 0; // Volatile because it's changed by Temperature ISR button update |
304 | 304 |
|
305 | 305 | // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
|
306 | 306 | static int g29_verbose_level = 0, phase_value = -1, repetition_cnt = 1,
|
|
496 | 496 | SERIAL_ECHO_START;
|
497 | 497 | SERIAL_ECHOLNPGM("Checking G29 has control of LCD Panel:");
|
498 | 498 | wait_for_user = true;
|
499 |
| - while (wait_for_user) { |
| 499 | + while (!ubl_lcd_clicked()) { |
500 | 500 | safe_delay(250);
|
501 | 501 | SERIAL_ECHO((int)ubl_encoderDiff);
|
502 | 502 | ubl_encoderDiff = 0;
|
|
1310 | 1310 |
|
1311 | 1311 | if (far_flag) { // If doing the far_flag action, we want to be as far as possible
|
1312 | 1312 | for (k = 0; k < UBL_MESH_NUM_X_POINTS; k++) { // from the starting point and from any other probed points. We
|
1313 |
| - for (l = 0; j < UBL_MESH_NUM_Y_POINTS; l++) { // want the next point spread out and filling in any blank spaces |
| 1313 | + for (l = 0; l < UBL_MESH_NUM_Y_POINTS; l++) { // want the next point spread out and filling in any blank spaces |
1314 | 1314 | if ( !isnan(z_values[k][l])) { // in the mesh. So we add in some of the distance to every probed
|
1315 | 1315 | distance += (i-k)*(i-k)*MESH_X_DIST*.05; // point we can find.
|
1316 | 1316 | distance += (j-l)*(j-l)*MESH_Y_DIST*.05;
|
|
1366 | 1366 |
|
1367 | 1367 | do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE); // Move the nozzle to where we are going to edit
|
1368 | 1368 | do_blocking_move_to_xy(xProbe, yProbe);
|
1369 |
| - float new_z = z_values[location.x_index][location.y_index] + 0.001; |
1370 |
| - |
1371 |
| - round_off = (int32_t)(new_z * 1000.0 + 2.5); // we chop off the last digits just to be clean. We are rounding to the |
1372 |
| - round_off -= (round_off % 5L); // closest 0 or 5 at the 3rd decimal place. |
| 1369 | + float new_z = z_values[location.x_index][location.y_index]; |
| 1370 | + |
| 1371 | + round_off = (int32_t)(new_z * 1000.0); // we chop off the last digits just to be clean. We are rounding to the |
1373 | 1372 | new_z = float(round_off) / 1000.0;
|
1374 | 1373 |
|
1375 |
| - //SERIAL_ECHOPGM("Mesh Point Currently At: "); |
1376 |
| - //SERIAL_PROTOCOL_F(new_z, 6); |
1377 |
| - //SERIAL_EOL; |
| 1374 | + ubl_has_control_of_lcd_panel = true; |
1378 | 1375 |
|
1379 | 1376 | lcd_implementation_clear();
|
1380 | 1377 | lcd_mesh_edit_setup(new_z);
|
|
1383 | 1380 | do {
|
1384 | 1381 | new_z = lcd_mesh_edit();
|
1385 | 1382 | idle();
|
1386 |
| - } while (wait_for_user); |
| 1383 | + } while (!ubl_lcd_clicked()); |
1387 | 1384 |
|
1388 | 1385 | lcd_return_to_status();
|
1389 | 1386 |
|
1390 |
| - ubl_has_control_of_lcd_panel++; // There is a race condition for the Encoder Wheel getting clicked. |
1391 |
| - // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) |
1392 |
| - // or here. |
| 1387 | + ubl_has_control_of_lcd_panel = true; // There is a race condition for the Encoder Wheel getting clicked. |
| 1388 | + // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) |
| 1389 | + // or here. |
1393 | 1390 |
|
1394 | 1391 | const millis_t nxt = millis() + 1500UL;
|
1395 | 1392 | while (ubl_lcd_clicked()) { // debounce and watch for abort
|
1396 | 1393 | idle();
|
1397 | 1394 | if (ELAPSED(millis(), nxt)) {
|
1398 | 1395 | lcd_return_to_status();
|
1399 |
| - SERIAL_PROTOCOLLNPGM("\nFine Tuning of Mesh Stopped."); |
| 1396 | +// SERIAL_PROTOCOLLNPGM("\nFine Tuning of Mesh Stopped."); |
1400 | 1397 | do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
|
1401 | 1398 | lcd_setstatus("Mesh Editing Stopped", true);
|
1402 | 1399 |
|
|
0 commit comments