瀏覽代碼

Start of process to get UBL running again.

The wait_for_user change totally broke UBL.   But there is stuff wrong
now in the thermal code and/or LCD Panel code.
Roxy-3D 8 年之前
父節點
當前提交
aec85ad45a
共有 3 個檔案被更改,包括 99 行新增59 行删除
  1. 51
    33
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 36
    15
      Marlin/UBL_Bed_Leveling.cpp
  3. 12
    11
      Marlin/UBL_G29.cpp

+ 51
- 33
Marlin/G26_Mesh_Validation_Tool.cpp 查看文件

@@ -199,6 +199,7 @@
199 199
       set_current_to_destination();
200 200
     }
201 201
 
202
+    ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
202 203
     if (turn_on_heaters())     // Turn on the heaters, leave the command if anything
203 204
       goto LEAVE;              // has gone wrong.
204 205
 
@@ -233,19 +234,30 @@
233 234
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
234 235
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
235 236
 
236
-    ubl_has_control_of_lcd_panel++; // Take control of the LCD Panel!
237
+    ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
237 238
     debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
238 239
 
239
-    wait_for_user = true;
240
+    /**
241
+     * Declare and generate a sin() & cos() table to be used during the circle drawing.  This will lighten
242
+     * the CPU load and make the arc drawing faster and more smooth
243
+     */
244
+    float sin_table[360 / 30 + 1], cos_table[360 / 30 + 1];
245
+    for (i = 0; i <= 360 / 30; i++) {
246
+      cos_table[i] = SIZE_OF_INTERSECTION_CIRCLES * cos(RADIANS(valid_trig_angle(i * 30.0)));
247
+      sin_table[i] = SIZE_OF_INTERSECTION_CIRCLES * sin(RADIANS(valid_trig_angle(i * 30.0)));
248
+    }
240 249
 
241 250
     do {
242 251
 
243
-      if (!wait_for_user) {                                     // Check if the user wants to stop the Mesh Validation
252
+      if (ubl_lcd_clicked()) {                                  // Check if the user wants to stop the Mesh Validation
244 253
         strcpy(lcd_status_message, "Mesh Validation Stopped."); // We can't do lcd_setstatus() without having it continue;
245 254
         #if ENABLED(ULTRA_LCD)
246 255
           lcd_setstatus("Mesh Validation Stopped.", true);
247 256
           lcd_quick_feedback();
248 257
         #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
260
+        }
249 261
         goto LEAVE;
250 262
       }
251 263
 
@@ -309,16 +321,6 @@
309 321
           end_angle   = 360.0;
310 322
         }
311 323
 
312
-        /**
313
-         * Declare and generate a sin() & cos() table to be used during the circle drawing.  This will lighten
314
-         * the CPU load and make the arc drawing faster and more smooth
315
-         */
316
-        float sin_table[360 / 30 + 1], cos_table[360 / 30 + 1];
317
-        for (i = 0; i <= 360 / 30; i++) {
318
-          cos_table[i] = SIZE_OF_INTERSECTION_CIRCLES * cos(RADIANS(valid_trig_angle(i * 30.0)));
319
-          sin_table[i] = SIZE_OF_INTERSECTION_CIRCLES * sin(RADIANS(valid_trig_angle(i * 30.0)));
320
-        }
321
-
322 324
         for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
323 325
           int tmp_div_30 = tmp / 30.0;
324 326
           if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
@@ -351,13 +353,16 @@
351 353
           }
352 354
 
353 355
           print_line_from_here_to_there(x, y, layer_height, xe, ye, layer_height);
356
+
354 357
         }
355
-        lcd_init_counter++;
356
-        if (lcd_init_counter > 10) {
357
-          lcd_init_counter = 0;
358
-          lcd_init(); // Some people's LCD Displays are locking up.  This might help them
359
-        }
358
+//      lcd_init_counter++;
359
+//      if (lcd_init_counter > 10) {
360
+//        lcd_init_counter = 0;
361
+//        lcd_init(); // Some people's LCD Displays are locking up.  This might help them
362
+//        ubl_has_control_of_lcd_panel = true;     // Make sure UBL still is controlling the LCD Panel
363
+//      }
360 364
 
365
+    // If the end point of the line is closer to the nozzle, we are going to
361 366
         debug_current_and_destination((char*)"Looking for lines to connect.");
362 367
         look_for_lines_to_connect();
363 368
         debug_current_and_destination((char*)"Done with line connect.");
@@ -365,21 +370,24 @@
365 370
 
366 371
       debug_current_and_destination((char*)"Done with current circle.");
367 372
 
373
+    // If the end point of the line is closer to the nozzle, we are going to
374
+
368 375
     }
369 376
     while (location.x_index >= 0 && location.y_index >= 0);
370 377
 
371 378
     LEAVE:
372 379
 
373
-    wait_for_user = false;
374
-
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
+    }
375 383
     retract_filament();
376 384
     destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;                             // Raise the nozzle
377 385
 
378 386
     debug_current_and_destination((char*)"ready to do Z-Raise.");
379
-    move_to( destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Raise the nozzle
387
+    move_to( destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0);   // Raise the nozzle
380 388
     debug_current_and_destination((char*)"done doing Z-Raise.");
381 389
 
382
-    destination[X_AXIS] = x_pos;                                                // Move back to the starting position
390
+    destination[X_AXIS] = x_pos;                                                  // Move back to the starting position
383 391
     destination[Y_AXIS] = y_pos;
384 392
     destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;                             // Keep the nozzle where it is
385 393
 
@@ -538,6 +546,8 @@
538 546
     float feed_value;
539 547
     static float last_z = -999.99;
540 548
 
549
+
550
+
541 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.
542 552
 
543 553
     if (g26_debug_flag) {
@@ -591,6 +601,7 @@
591 601
 
592 602
     stepper.synchronize();
593 603
     set_destination_to_current();
604
+
594 605
   }
595 606
 
596 607
   void retract_filament() {
@@ -658,16 +669,23 @@
658 669
       if (g26_debug_flag)
659 670
         SERIAL_ECHOLNPGM("  filament retracted.");
660 671
     }
672
+    // If the end point of the line is closer to the nozzle, we are going to
661 673
     move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion
662 674
 
675
+    // If the end point of the line is closer to the nozzle, we are going to
676
+
663 677
     float e_pos_delta = Line_Length * g26_e_axis_feedrate * extrusion_multiplier;
664 678
 
665 679
     un_retract_filament();
680
+
681
+    // If the end point of the line is closer to the nozzle, we are going to
666 682
     if (g26_debug_flag) {
667 683
       SERIAL_ECHOLNPGM("  doing printing move.");
668 684
       debug_current_and_destination((char*)"doing final move_to() inside print_line_from_here_to_there()");
669 685
     }
670 686
     move_to(ex, ey, ez, e_pos_delta);  // Get to the ending point with an appropriate amount of extrusion
687
+
688
+    // If the end point of the line is closer to the nozzle, we are going to
671 689
   }
672 690
 
673 691
   /**
@@ -815,18 +833,18 @@
815 833
           lcd_setstatus("G26 Heating Bed.", true);
816 834
           lcd_quick_feedback();
817 835
       #endif
818
-          ubl_has_control_of_lcd_panel++;
836
+          ubl_has_control_of_lcd_panel = true;
819 837
           thermalManager.setTargetBed(bed_temp);
820
-          wait_for_user = true;
821 838
           while (abs(thermalManager.degBed() - bed_temp) > 3) {
822
-            if (!wait_for_user) {
839
+            if (ubl_lcd_clicked()) {
823 840
               strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatus() without having it continue;
824 841
               lcd_setstatus("Leaving G26", true);        // Now we do it right.
842
+              while (ubl_lcd_clicked())                  // Debounce Encoder Wheel 
843
+                idle();
825 844
               return UBL_ERR;
826 845
             }
827 846
             idle();
828 847
           }
829
-          wait_for_user = false;
830 848
       #if ENABLED(ULTRA_LCD)
831 849
         }
832 850
         lcd_setstatus("G26 Heating Nozzle.", true);
@@ -836,16 +854,16 @@
836 854
 
837 855
     // Start heating the nozzle and wait for it to reach temperature.
838 856
     thermalManager.setTargetHotend(hotend_temp, 0);
839
-    wait_for_user = true;
840 857
     while (abs(thermalManager.degHotend(0) - hotend_temp) > 3) {
841
-      if (!wait_for_user) {
858
+      if (ubl_lcd_clicked()) {
842 859
         strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatus() without having it continue;
843 860
         lcd_setstatus("Leaving G26", true);        // Now we do it right.
861
+        while (ubl_lcd_clicked())                  // Debounce Encoder Wheel 
862
+          idle();
844 863
         return UBL_ERR;
845 864
       }
846 865
       idle();
847 866
     }
848
-    wait_for_user = false;
849 867
 
850 868
     #if ENABLED(ULTRA_LCD)
851 869
       lcd_setstatus("", true);
@@ -869,9 +887,7 @@
869 887
       un_retract_filament();    // Lets make sure the G26 command doesn't think the filament is
870 888
                                 // retracted().  We are here because we want to prime the nozzle.
871 889
                                 // So let's just unretract just to be sure.
872
-
873
-      wait_for_user = true;
874
-      while (wait_for_user) {
890
+      while (!ubl_lcd_clicked()) {
875 891
         chirp_at_user();
876 892
         destination[E_AXIS] += 0.25;
877 893
         #ifdef PREVENT_LENGTHY_EXTRUDE
@@ -894,9 +910,10 @@
894 910
 
895 911
       strcpy(lcd_status_message, "Done Priming"); // We can't do lcd_setstatus() without having it continue;
896 912
                                                   // So...  We cheat to get a message up.
913
+      while (ubl_lcd_clicked())                   // Debounce Encoder Wheel 
914
+        idle();
897 915
 
898 916
       #if ENABLED(ULTRA_LCD)
899
-        ubl_has_control_of_lcd_panel = false;
900 917
         lcd_setstatus("Done Priming", true);      // Now we do it right.
901 918
         lcd_quick_feedback();
902 919
       #endif
@@ -917,6 +934,7 @@
917 934
       set_destination_to_current();
918 935
       retract_filament();
919 936
     }
937
+
920 938
     return UBL_OK;
921 939
   }
922 940
 

+ 36
- 15
Marlin/UBL_Bed_Leveling.cpp 查看文件

@@ -175,8 +175,13 @@
175 175
     current_xi = ubl.get_cell_index_x(current_position[X_AXIS] + (MESH_X_DIST) / 2.0);
176 176
     current_yi = ubl.get_cell_index_y(current_position[Y_AXIS] + (MESH_Y_DIST) / 2.0);
177 177
 
178
-    for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
179
-      SERIAL_ECHOPGM("                 ");
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
+    }
180 185
 
181 186
     SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS - 1);
182 187
     SERIAL_ECHOPAIR(",", UBL_MESH_NUM_Y_POINTS - 1);
@@ -188,8 +193,13 @@
188 193
       SERIAL_ECHOPAIR(",", UBL_MESH_MAX_Y);
189 194
       SERIAL_CHAR(')');
190 195
 
191
-      for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
192
-        SERIAL_ECHOPGM("                 ");
196
+      for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
197
+        SERIAL_ECHOPGM("            ");
198
+        #if TX_BUFFER_SIZE>0
199
+          MYSERIAL.flushTX();
200
+        #endif
201
+        delay(15);
202
+      }
193 203
 
194 204
       SERIAL_ECHOPAIR("(", UBL_MESH_MAX_X);
195 205
       SERIAL_ECHOPAIR(",", UBL_MESH_MAX_Y);
@@ -205,13 +215,17 @@
205 215
         SERIAL_CHAR(i == current_xi && j == current_yi ? '[' : ' ');
206 216
 
207 217
         if (isnan(f))
208
-          SERIAL_PROTOCOLPGM("      .       ");
218
+          SERIAL_PROTOCOLPGM("    .    ");
209 219
         else {
210 220
           // if we don't do this, the columns won't line up nicely
211 221
           if (f >= 0.0) SERIAL_CHAR(' ');
212
-          SERIAL_PROTOCOL_F(f, 5);
222
+          SERIAL_PROTOCOL_F(f, 3);
213 223
           idle();
214 224
         }
225
+        #if TX_BUFFER_SIZE>0
226
+          MYSERIAL.flushTX();
227
+        #endif
228
+        delay(15);
215 229
         if (i == current_xi && j == current_yi) // is the nozzle here? if so, finish marking the number
216 230
           SERIAL_CHAR(']');
217 231
         else
@@ -231,27 +245,34 @@
231 245
     SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
232 246
     SERIAL_ECHOPGM(")    ");
233 247
 
234
-    for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
235
-      SERIAL_ECHOPGM("                 ");
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
+    }
236 255
 
237 256
     SERIAL_ECHOPAIR("(", int(UBL_MESH_MAX_X));
238 257
     SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
239 258
     SERIAL_CHAR(')');
240
-    //  }
259
+    SERIAL_EOL;
241 260
 
242 261
     SERIAL_ECHOPAIR("(", 0);
243 262
     SERIAL_ECHOPAIR(",", 0);
244 263
     SERIAL_ECHOPGM(")       ");
245 264
 
246
-    for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
247
-      SERIAL_ECHOPGM("                 ");
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);
271
+    }
248 272
 
249 273
     SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS-1);
250 274
     SERIAL_ECHOPAIR(",", 0);
251
-    SERIAL_CHAR(')');
252
-
253
-    SERIAL_CHAR(' ');
254
-    SERIAL_EOL;
275
+    SERIAL_ECHOLNPGM(")");
255 276
   }
256 277
 
257 278
   bool unified_bed_leveling::sanity_check() {

+ 12
- 11
Marlin/UBL_G29.cpp 查看文件

@@ -594,18 +594,18 @@
594 594
         save_ubl_active_state_and_disable();
595 595
         //measured_z = probe_pt(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, ProbeDeployAndStow, g29_verbose_level);
596 596
 
597
+        ubl_has_control_of_lcd_panel = true;// Grab the LCD Hardware
597 598
         measured_z = 1.5;
598 599
         do_blocking_move_to_z(measured_z);  // Get close to the bed, but leave some space so we don't damage anything
599 600
                                             // The user is not going to be locking in a new Z-Offset very often so
600 601
                                             // it won't be that painful to spin the Encoder Wheel for 1.5mm
601 602
         lcd_implementation_clear();
602 603
         lcd_z_offset_edit_setup(measured_z);
603
-        wait_for_user = true;
604 604
         do {
605 605
           measured_z = lcd_z_offset_edit();
606 606
           idle();
607 607
           do_blocking_move_to_z(measured_z);
608
-        } while (wait_for_user);
608
+        } while (!ubl_lcd_clicked());
609 609
 
610 610
         ubl_has_control_of_lcd_panel++;   // There is a race condition for the Encoder Wheel getting clicked.
611 611
                                           // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
@@ -707,14 +707,17 @@
707 707
     save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
708 708
     DEPLOY_PROBE();
709 709
 
710
-    wait_for_user = true;
711 710
     do {
712
-      if (!wait_for_user) {
713
-        SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
711
+      if (ubl_lcd_clicked()) {
712
+        SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
714 713
         lcd_quick_feedback();
715
-        ubl_has_control_of_lcd_panel = false;
716 714
         STOW_PROBE();
715
+        while (ubl_lcd_clicked() ) {
716
+          idle();
717
+        }
718
+        ubl_has_control_of_lcd_panel = false;
717 719
         restore_ubl_active_state_and_leave();
720
+        delay(50);  // Debounce the Encoder wheel
718 721
         return;
719 722
       }
720 723
 
@@ -737,7 +740,6 @@
737 740
 
738 741
     LEAVE:
739 742
 
740
-    wait_for_user = false;
741 743
     STOW_PROBE();
742 744
     restore_ubl_active_state_and_leave();
743 745
 
@@ -813,8 +815,7 @@
813 815
   }
814 816
 
815 817
   float use_encoder_wheel_to_measure_point() {
816
-    wait_for_user = true;
817
-    while (wait_for_user) {     // we need the loop to move the nozzle based on the encoder wheel here!
818
+    while (!ubl_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
818 819
       idle();
819 820
       if (ubl_encoderDiff) {
820 821
         do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(ubl_encoderDiff));
@@ -891,8 +892,8 @@
891 892
       last_x = xProbe;
892 893
       last_y = yProbe;
893 894
 
894
-      wait_for_user = true;
895
-      while (wait_for_user) {     // we need the loop to move the nozzle based on the encoder wheel here!
895
+      ubl_has_control_of_lcd_panel = true;
896
+      while (!ubl_lcd_clicked) {     // we need the loop to move the nozzle based on the encoder wheel here!
896 897
         idle();
897 898
         if (ubl_encoderDiff) {
898 899
           do_blocking_move_to_z(current_position[Z_AXIS] + float(ubl_encoderDiff) / 100.0);

Loading…
取消
儲存