Browse Source

Cleaned up G26 ready to replace existing one at MarlinFirmware/Marlin

Roxy-3D 8 years ago
parent
commit
9a1949a91e
1 changed files with 68 additions and 70 deletions
  1. 68
    70
      Marlin/G26_Mesh_Validation_Tool.cpp

+ 68
- 70
Marlin/G26_Mesh_Validation_Tool.cpp View File

35
   #include "temperature.h"
35
   #include "temperature.h"
36
   #include "UBL.h"
36
   #include "UBL.h"
37
   #include "ultralcd.h"
37
   #include "ultralcd.h"
38
+//#include <avr/pgmspace.h>
38
 
39
 
39
   #define EXTRUSION_MULTIPLIER 1.0    // This is too much clutter for the main Configuration.h file  But
40
   #define EXTRUSION_MULTIPLIER 1.0    // This is too much clutter for the main Configuration.h file  But
40
   #define RETRACTION_MULTIPLIER 1.0   // some user have expressed an interest in being able to customize
41
   #define RETRACTION_MULTIPLIER 1.0   // some user have expressed an interest in being able to customize
127
   extern bool code_value_bool();
128
   extern bool code_value_bool();
128
   extern bool code_has_value();
129
   extern bool code_has_value();
129
   extern void lcd_init();
130
   extern void lcd_init();
131
+  extern void lcd_setstatuspgm(const char* const message, uint8_t level);
130
   #define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS])) //bob
132
   #define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS])) //bob
131
   bool prepare_move_to_destination_cartesian();
133
   bool prepare_move_to_destination_cartesian();
132
   void line_to_destination();
134
   void line_to_destination();
152
                               // is currently retracted or not.  This allows us to be
154
                               // is currently retracted or not.  This allows us to be
153
                               // less careful because mis-matched retractions and un-retractions
155
                               // less careful because mis-matched retractions and un-retractions
154
                               // won't leave us in a bad state.
156
                               // won't leave us in a bad state.
155
-  #if ENABLED(ULTRA_LCD)
156
-    void lcd_setstatus(const char* message, bool persist);
157
-  #endif
158
 
157
 
159
   float valid_trig_angle(float);
158
   float valid_trig_angle(float);
160
   mesh_index_pair find_closest_circle_to_print(float, float);
159
   mesh_index_pair find_closest_circle_to_print(float, float);
235
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
234
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
236
 
235
 
237
     ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
236
     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.");
239
 
238
 
240
     /**
239
     /**
241
      * Declare and generate a sin() & cos() table to be used during the circle drawing.  This will lighten
240
      * Declare and generate a sin() & cos() table to be used during the circle drawing.  This will lighten
249
 
248
 
250
     do {
249
     do {
251
 
250
 
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
254
         #if ENABLED(ULTRA_LCD)
252
         #if ENABLED(ULTRA_LCD)
255
-          lcd_setstatus("Mesh Validation Stopped.", true);
253
+          lcd_setstatuspgm(PSTR("Mesh Validation Stopped."), (uint8_t) 99);
256
           lcd_quick_feedback();
254
           lcd_quick_feedback();
257
         #endif
255
         #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);
260
         }
263
         }
261
         goto LEAVE;
264
         goto LEAVE;
262
       }
265
       }
341
             ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
344
             ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
342
           #endif
345
           #endif
343
 
346
 
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
+//          }
354
 
357
 
355
           print_line_from_here_to_there(x, y, layer_height, xe, ye, layer_height);
358
           print_line_from_here_to_there(x, y, layer_height, xe, ye, layer_height);
356
 
359
 
363
 //      }
366
 //      }
364
 
367
 
365
     // If the end point of the line is closer to the nozzle, we are going to
368
     // 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.");
367
         look_for_lines_to_connect();
370
         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.");
369
       }
372
       }
370
 
373
 
371
-      debug_current_and_destination((char*)"Done with current circle.");
374
+//    debug_current_and_destination((char*)"Done with current circle.");
372
 
375
 
373
     // If the end point of the line is closer to the nozzle, we are going to
376
     // If the end point of the line is closer to the nozzle, we are going to
374
 
377
 
376
     while (location.x_index >= 0 && location.y_index >= 0);
379
     while (location.x_index >= 0 && location.y_index >= 0);
377
 
380
 
378
     LEAVE:
381
     LEAVE:
382
+    lcd_setstatuspgm(PSTR("Leaving G26 "), (uint8_t) 99);
379
 
383
 
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
-    }
383
     retract_filament();
384
     retract_filament();
384
     destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;                             // Raise the nozzle
385
     destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;                             // Raise the nozzle
385
 
386
 
386
-    debug_current_and_destination((char*)"ready to do Z-Raise.");
387
+//  debug_current_and_destination((char*)"ready to do Z-Raise.");
387
     move_to( destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0);   // Raise the nozzle
388
     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.");
389
 
390
 
390
     destination[X_AXIS] = x_pos;                                                  // Move back to the starting position
391
     destination[X_AXIS] = x_pos;                                                  // Move back to the starting position
391
     destination[Y_AXIS] = y_pos;
392
     destination[Y_AXIS] = y_pos;
392
     destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;                             // Keep the nozzle where it is
393
     destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;                             // Keep the nozzle where it is
393
 
394
 
394
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Move back to the starting position
395
     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.");
396
 
397
 
397
     ubl_has_control_of_lcd_panel = false;     // Give back control of the LCD Panel!
398
     ubl_has_control_of_lcd_panel = false;     // Give back control of the LCD Panel!
398
 
399
 
402
       #endif
403
       #endif
403
       thermalManager.setTargetHotend(0.0, 0);
404
       thermalManager.setTargetHotend(0.0, 0);
404
     }
405
     }
405
-    lcd_init(); // Some people's LCD Displays are locking up.  This might help them
406
   }
406
   }
407
 
407
 
408
 
408
 
490
                 SERIAL_ECHOPGM(", ey=");
490
                 SERIAL_ECHOPGM(", ey=");
491
                 SERIAL_ECHO(ey);
491
                 SERIAL_ECHO(ey);
492
                 SERIAL_ECHOLNPGM(")");
492
                 SERIAL_ECHOLNPGM(")");
493
-                debug_current_and_destination((char*)"Connecting horizontal line.");
493
+//              debug_current_and_destination((char*)"Connecting horizontal line.");
494
               }
494
               }
495
 
495
 
496
               print_line_from_here_to_there(sx, sy, layer_height, ex, ey, layer_height);
496
               print_line_from_here_to_there(sx, sy, layer_height, ex, ey, layer_height);
546
     float feed_value;
546
     float feed_value;
547
     static float last_z = -999.99;
547
     static float last_z = -999.99;
548
 
548
 
549
-
550
-
551
     bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
549
     bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
552
 
550
 
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
+//  }
557
 
555
 
558
     if (z != last_z) {
556
     if (z != last_z) {
557
+//    if (g26_debug_flag) {
558
+//      SERIAL_ECHOPAIR("in move_to()  changing Z to ", (int)z);
559
+//      SERIAL_EOL;
560
+//    }
559
 
561
 
560
-      if (g26_debug_flag) {
561
-        SERIAL_ECHOPAIR("in move_to()  changing Z to ", (int)z);
562
-        SERIAL_EOL;
563
-      }
564
       last_z = z;
562
       last_z = z;
565
       feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0);  // Base the feed rate off of the configured Z_AXIS feed rate
563
       feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0);  // Base the feed rate off of the configured Z_AXIS feed rate
566
 
564
 
574
       stepper.synchronize();
572
       stepper.synchronize();
575
       set_destination_to_current();
573
       set_destination_to_current();
576
 
574
 
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");
579
     }
577
     }
580
 
578
 
581
     // Check if X or Y is involved in the movement.
579
     // Check if X or Y is involved in the movement.
591
     destination[Y_AXIS] = y;
589
     destination[Y_AXIS] = y;
592
     destination[E_AXIS] += e_delta;
590
     destination[E_AXIS] += e_delta;
593
 
591
 
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");
596
 
594
 
597
     ubl_line_to_destination(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feed_value, 0);
595
     ubl_line_to_destination(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feed_value, 0);
598
 
596
 
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");
601
 
599
 
602
     stepper.synchronize();
600
     stepper.synchronize();
603
     set_destination_to_current();
601
     set_destination_to_current();
607
   void retract_filament() {
605
   void retract_filament() {
608
     if (!g26_retracted) { // Only retract if we are not already retracted!
606
     if (!g26_retracted) { // Only retract if we are not already retracted!
609
       g26_retracted = true;
607
       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.");
611
       move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], -1.0 * retraction_multiplier);
609
       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.");
613
     }
611
     }
614
   }
612
   }
615
 
613
 
617
     if (g26_retracted) { // Only un-retract if we are retracted.
615
     if (g26_retracted) { // Only un-retract if we are retracted.
618
       move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 1.2 * retraction_multiplier);
616
       move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 1.2 * retraction_multiplier);
619
       g26_retracted = false;
617
       g26_retracted = false;
620
-      if (g26_debug_flag) SERIAL_ECHOLNPGM(" unretract done.");
618
+//    if (g26_debug_flag) SERIAL_ECHOLNPGM(" unretract done.");
621
     }
619
     }
622
   }
620
   }
623
 
621
 
656
     // On very small lines we don't do the optimization because it just isn't worth it.
654
     // On very small lines we don't do the optimization because it just isn't worth it.
657
     //
655
     //
658
     if (dist_end < dist_start && (SIZE_OF_INTERSECTION_CIRCLES) < abs(Line_Length)) {
656
     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()");
661
       print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
659
       print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
662
       return;
660
       return;
663
     }
661
     }
666
 
664
 
667
     if (dist_start > 2.0) {
665
     if (dist_start > 2.0) {
668
       retract_filament();
666
       retract_filament();
669
-      if (g26_debug_flag)
670
-        SERIAL_ECHOLNPGM("  filament retracted.");
667
+//    if (g26_debug_flag)
668
+//      SERIAL_ECHOLNPGM("  filament retracted.");
671
     }
669
     }
672
     // If the end point of the line is closer to the nozzle, we are going to
670
     // If the end point of the line is closer to the nozzle, we are going to
673
     move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion
671
     move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion
679
     un_retract_filament();
677
     un_retract_filament();
680
 
678
 
681
     // If the end point of the line is closer to the nozzle, we are going to
679
     // 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
+//  }
686
     move_to(ex, ey, ez, e_pos_delta);  // Get to the ending point with an appropriate amount of extrusion
684
     move_to(ex, ey, ez, e_pos_delta);  // Get to the ending point with an appropriate amount of extrusion
687
 
685
 
688
     // If the end point of the line is closer to the nozzle, we are going to
686
     // If the end point of the line is closer to the nozzle, we are going to
830
     #if HAS_TEMP_BED
828
     #if HAS_TEMP_BED
831
       #if ENABLED(ULTRA_LCD)
829
       #if ENABLED(ULTRA_LCD)
832
         if (bed_temp > 25) {
830
         if (bed_temp > 25) {
833
-          lcd_setstatus("G26 Heating Bed.", true);
831
+          lcd_setstatuspgm(PSTR("G26 Heating Bed."), (uint8_t) 99);
834
           lcd_quick_feedback();
832
           lcd_quick_feedback();
835
       #endif
833
       #endif
836
           ubl_has_control_of_lcd_panel = true;
834
           ubl_has_control_of_lcd_panel = true;
837
           thermalManager.setTargetBed(bed_temp);
835
           thermalManager.setTargetBed(bed_temp);
838
           while (abs(thermalManager.degBed() - bed_temp) > 3) {
836
           while (abs(thermalManager.degBed() - bed_temp) > 3) {
839
             if (ubl_lcd_clicked()) {
837
             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 
843
                 idle();
841
                 idle();
844
               return UBL_ERR;
842
               return UBL_ERR;
845
             }
843
             }
847
           }
845
           }
848
       #if ENABLED(ULTRA_LCD)
846
       #if ENABLED(ULTRA_LCD)
849
         }
847
         }
850
-        lcd_setstatus("G26 Heating Nozzle.", true);
848
+        lcd_setstatuspgm(PSTR("G26 Heating Nozzle."), (uint8_t) 99);
851
         lcd_quick_feedback();
849
         lcd_quick_feedback();
852
       #endif
850
       #endif
853
     #endif
851
     #endif
856
     thermalManager.setTargetHotend(hotend_temp, 0);
854
     thermalManager.setTargetHotend(hotend_temp, 0);
857
     while (abs(thermalManager.degHotend(0) - hotend_temp) > 3) {
855
     while (abs(thermalManager.degHotend(0) - hotend_temp) > 3) {
858
       if (ubl_lcd_clicked()) {
856
       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 
862
           idle();
860
           idle();
863
         return UBL_ERR;
861
         return UBL_ERR;
864
       }
862
       }
866
     }
864
     }
867
 
865
 
868
     #if ENABLED(ULTRA_LCD)
866
     #if ENABLED(ULTRA_LCD)
869
-      lcd_setstatus("", true);
867
+      lcd_setstatuspgm(PSTR(""), (uint8_t) 99);
870
       lcd_quick_feedback();
868
       lcd_quick_feedback();
871
     #endif
869
     #endif
872
     return UBL_OK;
870
     return UBL_OK;
879
     float Total_Prime = 0.0;
877
     float Total_Prime = 0.0;
880
 
878
 
881
     if (prime_flag == -1) {  // The user wants to control how much filament gets purged
879
     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);
883
       chirp_at_user();
881
       chirp_at_user();
884
 
882
 
885
       set_destination_to_current();
883
       set_destination_to_current();
908
         idle();
906
         idle();
909
       }
907
       }
910
 
908
 
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;
912
                                                   // So...  We cheat to get a message up.
910
                                                   // So...  We cheat to get a message up.
913
       while (ubl_lcd_clicked())                   // Debounce Encoder Wheel 
911
       while (ubl_lcd_clicked())                   // Debounce Encoder Wheel 
914
         idle();
912
         idle();
915
 
913
 
916
       #if ENABLED(ULTRA_LCD)
914
       #if ENABLED(ULTRA_LCD)
917
-        lcd_setstatus("Done Priming", true);      // Now we do it right.
915
+        lcd_setstatuspgm(PSTR("Done Priming"), (uint8_t) 99); 
918
         lcd_quick_feedback();
916
         lcd_quick_feedback();
919
       #endif
917
       #endif
920
     }
918
     }
921
     else {
919
     else {
922
       #if ENABLED(ULTRA_LCD)
920
       #if ENABLED(ULTRA_LCD)
923
-        lcd_setstatus("Fixed Length Prime.", true);
921
+        lcd_setstatuspgm(PSTR("Fixed Length Prime."), (uint8_t) 99);
924
         lcd_quick_feedback();
922
         lcd_quick_feedback();
925
       #endif
923
       #endif
926
       set_destination_to_current();
924
       set_destination_to_current();

Loading…
Cancel
Save