Skip to content

Commit 9a1949a

Browse files
committed
Cleaned up G26 ready to replace existing one at MarlinFirmware/Marlin
1 parent aec85ad commit 9a1949a

File tree

1 file changed

+68
-70
lines changed

1 file changed

+68
-70
lines changed

Marlin/G26_Mesh_Validation_Tool.cpp

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "temperature.h"
3636
#include "UBL.h"
3737
#include "ultralcd.h"
38+
//#include <avr/pgmspace.h>
3839

3940
#define EXTRUSION_MULTIPLIER 1.0 // This is too much clutter for the main Configuration.h file But
4041
#define RETRACTION_MULTIPLIER 1.0 // some user have expressed an interest in being able to customize
@@ -127,6 +128,7 @@
127128
extern bool code_value_bool();
128129
extern bool code_has_value();
129130
extern void lcd_init();
131+
extern void lcd_setstatuspgm(const char* const message, uint8_t level);
130132
#define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS])) //bob
131133
bool prepare_move_to_destination_cartesian();
132134
void line_to_destination();
@@ -152,9 +154,6 @@
152154
// is currently retracted or not. This allows us to be
153155
// less careful because mis-matched retractions and un-retractions
154156
// won't leave us in a bad state.
155-
#if ENABLED(ULTRA_LCD)
156-
void lcd_setstatus(const char* message, bool persist);
157-
#endif
158157

159158
float valid_trig_angle(float);
160159
mesh_index_pair find_closest_circle_to_print(float, float);
@@ -235,7 +234,7 @@
235234
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
236235

237236
ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
238-
debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
237+
// debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
239238

240239
/**
241240
* Declare and generate a sin() & cos() table to be used during the circle drawing. This will lighten
@@ -249,14 +248,18 @@
249248

250249
do {
251250

252-
if (ubl_lcd_clicked()) { // Check if the user wants to stop the Mesh Validation
253-
strcpy(lcd_status_message, "Mesh Validation Stopped."); // We can't do lcd_setstatus() without having it continue;
251+
if (ubl_lcd_clicked()) { // Check if the user wants to stop the Mesh Validation
254252
#if ENABLED(ULTRA_LCD)
255-
lcd_setstatus("Mesh Validation Stopped.", true);
253+
lcd_setstatuspgm(PSTR("Mesh Validation Stopped."), (uint8_t) 99);
256254
lcd_quick_feedback();
257255
#endif
258-
while (ubl_lcd_clicked()) { // Wait until the user is done pressing the
259-
idle(); // Encoder Wheel if that is why we are leaving
256+
while (!ubl_lcd_clicked()) { // Wait until the user is done pressing the
257+
idle(); // Encoder Wheel if that is why we are leaving
258+
lcd_setstatuspgm(PSTR(" "), (uint8_t) 99);
259+
}
260+
while ( ubl_lcd_clicked()) { // Wait until the user is done pressing the
261+
idle(); // Encoder Wheel if that is why we are leaving
262+
lcd_setstatuspgm(PSTR("Unpress Wheel "), (uint8_t) 99);
260263
}
261264
goto LEAVE;
262265
}
@@ -341,16 +344,16 @@
341344
ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
342345
#endif
343346

344-
if (g26_debug_flag) {
345-
char ccc, *cptr, seg_msg[50], seg_num[10];
346-
strcpy(seg_msg, " segment: ");
347-
strcpy(seg_num, " \n");
348-
cptr = (char*) "01234567890ABCDEF????????";
349-
ccc = cptr[tmp_div_30];
350-
seg_num[1] = ccc;
351-
strcat(seg_msg, seg_num);
352-
debug_current_and_destination(seg_msg);
353-
}
347+
// if (g26_debug_flag) {
348+
// char ccc, *cptr, seg_msg[50], seg_num[10];
349+
// strcpy(seg_msg, " segment: ");
350+
// strcpy(seg_num, " \n");
351+
// cptr = (char*) "01234567890ABCDEF????????";
352+
// ccc = cptr[tmp_div_30];
353+
// seg_num[1] = ccc;
354+
// strcat(seg_msg, seg_num);
355+
// debug_current_and_destination(seg_msg);
356+
// }
354357

355358
print_line_from_here_to_there(x, y, layer_height, xe, ye, layer_height);
356359

@@ -363,36 +366,34 @@
363366
// }
364367

365368
// If the end point of the line is closer to the nozzle, we are going to
366-
debug_current_and_destination((char*)"Looking for lines to connect.");
369+
// debug_current_and_destination((char*)"Looking for lines to connect.");
367370
look_for_lines_to_connect();
368-
debug_current_and_destination((char*)"Done with line connect.");
371+
// debug_current_and_destination((char*)"Done with line connect.");
369372
}
370373

371-
debug_current_and_destination((char*)"Done with current circle.");
374+
// debug_current_and_destination((char*)"Done with current circle.");
372375

373376
// If the end point of the line is closer to the nozzle, we are going to
374377

375378
}
376379
while (location.x_index >= 0 && location.y_index >= 0);
377380

378381
LEAVE:
382+
lcd_setstatuspgm(PSTR("Leaving G26 "), (uint8_t) 99);
379383

380-
while (ubl_lcd_clicked()) { // Wait until the user is done pressing the
381-
idle(); // Encoder Wheel if that is why we are leaving
382-
}
383384
retract_filament();
384385
destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Raise the nozzle
385386

386-
debug_current_and_destination((char*)"ready to do Z-Raise.");
387+
// debug_current_and_destination((char*)"ready to do Z-Raise.");
387388
move_to( destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Raise the nozzle
388-
debug_current_and_destination((char*)"done doing Z-Raise.");
389+
// debug_current_and_destination((char*)"done doing Z-Raise.");
389390

390391
destination[X_AXIS] = x_pos; // Move back to the starting position
391392
destination[Y_AXIS] = y_pos;
392393
destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
393394

394395
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Move back to the starting position
395-
debug_current_and_destination((char*)"done doing X/Y move.");
396+
// debug_current_and_destination((char*)"done doing X/Y move.");
396397

397398
ubl_has_control_of_lcd_panel = false; // Give back control of the LCD Panel!
398399

@@ -402,7 +403,6 @@
402403
#endif
403404
thermalManager.setTargetHotend(0.0, 0);
404405
}
405-
lcd_init(); // Some people's LCD Displays are locking up. This might help them
406406
}
407407

408408

@@ -490,7 +490,7 @@
490490
SERIAL_ECHOPGM(", ey=");
491491
SERIAL_ECHO(ey);
492492
SERIAL_ECHOLNPGM(")");
493-
debug_current_and_destination((char*)"Connecting horizontal line.");
493+
// debug_current_and_destination((char*)"Connecting horizontal line.");
494494
}
495495

496496
print_line_from_here_to_there(sx, sy, layer_height, ex, ey, layer_height);
@@ -546,21 +546,19 @@
546546
float feed_value;
547547
static float last_z = -999.99;
548548

549-
550-
551549
bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
552550

553-
if (g26_debug_flag) {
554-
SERIAL_ECHOPAIR("in move_to() has_xy_component:", (int)has_xy_component);
555-
SERIAL_EOL;
556-
}
551+
// if (g26_debug_flag) {
552+
// SERIAL_ECHOPAIR("in move_to() has_xy_component:", (int)has_xy_component);
553+
// SERIAL_EOL;
554+
// }
557555

558556
if (z != last_z) {
557+
// if (g26_debug_flag) {
558+
// SERIAL_ECHOPAIR("in move_to() changing Z to ", (int)z);
559+
// SERIAL_EOL;
560+
// }
559561

560-
if (g26_debug_flag) {
561-
SERIAL_ECHOPAIR("in move_to() changing Z to ", (int)z);
562-
SERIAL_EOL;
563-
}
564562
last_z = z;
565563
feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0); // Base the feed rate off of the configured Z_AXIS feed rate
566564

@@ -574,8 +572,8 @@
574572
stepper.synchronize();
575573
set_destination_to_current();
576574

577-
if (g26_debug_flag)
578-
debug_current_and_destination((char*)" in move_to() done with Z move");
575+
// if (g26_debug_flag)
576+
// debug_current_and_destination((char*)" in move_to() done with Z move");
579577
}
580578

581579
// Check if X or Y is involved in the movement.
@@ -591,13 +589,13 @@
591589
destination[Y_AXIS] = y;
592590
destination[E_AXIS] += e_delta;
593591

594-
if (g26_debug_flag)
595-
debug_current_and_destination((char*)" in move_to() doing last move");
592+
// if (g26_debug_flag)
593+
// debug_current_and_destination((char*)" in move_to() doing last move");
596594

597595
ubl_line_to_destination(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feed_value, 0);
598596

599-
if (g26_debug_flag)
600-
debug_current_and_destination((char*)" in move_to() after last move");
597+
// if (g26_debug_flag)
598+
// debug_current_and_destination((char*)" in move_to() after last move");
601599

602600
stepper.synchronize();
603601
set_destination_to_current();
@@ -607,17 +605,17 @@
607605
void retract_filament() {
608606
if (!g26_retracted) { // Only retract if we are not already retracted!
609607
g26_retracted = true;
610-
if (g26_debug_flag) SERIAL_ECHOLNPGM(" Decided to do retract.");
608+
// if (g26_debug_flag) SERIAL_ECHOLNPGM(" Decided to do retract.");
611609
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], -1.0 * retraction_multiplier);
612-
if (g26_debug_flag) SERIAL_ECHOLNPGM(" Retraction done.");
610+
// if (g26_debug_flag) SERIAL_ECHOLNPGM(" Retraction done.");
613611
}
614612
}
615613

616614
void un_retract_filament() {
617615
if (g26_retracted) { // Only un-retract if we are retracted.
618616
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 1.2 * retraction_multiplier);
619617
g26_retracted = false;
620-
if (g26_debug_flag) SERIAL_ECHOLNPGM(" unretract done.");
618+
// if (g26_debug_flag) SERIAL_ECHOLNPGM(" unretract done.");
621619
}
622620
}
623621

@@ -656,8 +654,8 @@
656654
// On very small lines we don't do the optimization because it just isn't worth it.
657655
//
658656
if (dist_end < dist_start && (SIZE_OF_INTERSECTION_CIRCLES) < abs(Line_Length)) {
659-
if (g26_debug_flag)
660-
SERIAL_ECHOLNPGM(" Reversing start and end of print_line_from_here_to_there()");
657+
// if (g26_debug_flag)
658+
// SERIAL_ECHOLNPGM(" Reversing start and end of print_line_from_here_to_there()");
661659
print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
662660
return;
663661
}
@@ -666,8 +664,8 @@
666664

667665
if (dist_start > 2.0) {
668666
retract_filament();
669-
if (g26_debug_flag)
670-
SERIAL_ECHOLNPGM(" filament retracted.");
667+
// if (g26_debug_flag)
668+
// SERIAL_ECHOLNPGM(" filament retracted.");
671669
}
672670
// If the end point of the line is closer to the nozzle, we are going to
673671
move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion
@@ -679,10 +677,10 @@
679677
un_retract_filament();
680678

681679
// If the end point of the line is closer to the nozzle, we are going to
682-
if (g26_debug_flag) {
683-
SERIAL_ECHOLNPGM(" doing printing move.");
684-
debug_current_and_destination((char*)"doing final move_to() inside print_line_from_here_to_there()");
685-
}
680+
// if (g26_debug_flag) {
681+
// SERIAL_ECHOLNPGM(" doing printing move.");
682+
// debug_current_and_destination((char*)"doing final move_to() inside print_line_from_here_to_there()");
683+
// }
686684
move_to(ex, ey, ez, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion
687685

688686
// If the end point of the line is closer to the nozzle, we are going to
@@ -830,24 +828,24 @@
830828
#if HAS_TEMP_BED
831829
#if ENABLED(ULTRA_LCD)
832830
if (bed_temp > 25) {
833-
lcd_setstatus("G26 Heating Bed.", true);
831+
lcd_setstatuspgm(PSTR("G26 Heating Bed."), (uint8_t) 99);
834832
lcd_quick_feedback();
835833
#endif
836834
ubl_has_control_of_lcd_panel = true;
837835
thermalManager.setTargetBed(bed_temp);
838836
while (abs(thermalManager.degBed() - bed_temp) > 3) {
839837
if (ubl_lcd_clicked()) {
840-
strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatus() without having it continue;
841-
lcd_setstatus("Leaving G26", true); // Now we do it right.
842-
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
838+
strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatus() without having it continue;
839+
lcd_setstatuspgm(PSTR("Leaving G26"), (uint8_t) 99); // Now we do it right.
840+
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
843841
idle();
844842
return UBL_ERR;
845843
}
846844
idle();
847845
}
848846
#if ENABLED(ULTRA_LCD)
849847
}
850-
lcd_setstatus("G26 Heating Nozzle.", true);
848+
lcd_setstatuspgm(PSTR("G26 Heating Nozzle."), (uint8_t) 99);
851849
lcd_quick_feedback();
852850
#endif
853851
#endif
@@ -856,17 +854,17 @@
856854
thermalManager.setTargetHotend(hotend_temp, 0);
857855
while (abs(thermalManager.degHotend(0) - hotend_temp) > 3) {
858856
if (ubl_lcd_clicked()) {
859-
strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatus() without having it continue;
860-
lcd_setstatus("Leaving G26", true); // Now we do it right.
861-
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
857+
strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatuspgm() without having it continue;
858+
lcd_setstatuspgm(PSTR("Leaving G26"), (uint8_t) 99); // Now we do it right.
859+
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
862860
idle();
863861
return UBL_ERR;
864862
}
865863
idle();
866864
}
867865

868866
#if ENABLED(ULTRA_LCD)
869-
lcd_setstatus("", true);
867+
lcd_setstatuspgm(PSTR(""), (uint8_t) 99);
870868
lcd_quick_feedback();
871869
#endif
872870
return UBL_OK;
@@ -879,7 +877,7 @@
879877
float Total_Prime = 0.0;
880878

881879
if (prime_flag == -1) { // The user wants to control how much filament gets purged
882-
lcd_setstatus("User-Controlled Prime", true);
880+
lcd_setstatuspgm(PSTR("User-Controlled Prime"), (uint8_t) 99);
883881
chirp_at_user();
884882

885883
set_destination_to_current();
@@ -908,19 +906,19 @@
908906
idle();
909907
}
910908

911-
strcpy(lcd_status_message, "Done Priming"); // We can't do lcd_setstatus() without having it continue;
909+
strcpy(lcd_status_message, "Done Priming"); // We can't do lcd_setstatuspgm() without having it continue;
912910
// So... We cheat to get a message up.
913911
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
914912
idle();
915913

916914
#if ENABLED(ULTRA_LCD)
917-
lcd_setstatus("Done Priming", true); // Now we do it right.
915+
lcd_setstatuspgm(PSTR("Done Priming"), (uint8_t) 99);
918916
lcd_quick_feedback();
919917
#endif
920918
}
921919
else {
922920
#if ENABLED(ULTRA_LCD)
923-
lcd_setstatus("Fixed Length Prime.", true);
921+
lcd_setstatuspgm(PSTR("Fixed Length Prime."), (uint8_t) 99);
924922
lcd_quick_feedback();
925923
#endif
926924
set_destination_to_current();

0 commit comments

Comments
 (0)