Browse Source

Make G26 compatible with G92 and M206

Scott Lahteine 8 years ago
parent
commit
65ca6472ba
1 changed files with 29 additions and 39 deletions
  1. 29
    39
      Marlin/G26_Mesh_Validation_Tool.cpp

+ 29
- 39
Marlin/G26_Mesh_Validation_Tool.cpp View File

178
    * nozzle in a problem area and doing a G29 P4 R command.
178
    * nozzle in a problem area and doing a G29 P4 R command.
179
    */
179
    */
180
   void gcode_G26() {
180
   void gcode_G26() {
181
-    float circle_x, circle_y, x, y, xe, ye, tmp,
182
-          start_angle, end_angle;
183
-    int   i, xi, yi, lcd_init_counter = 0;
181
+    float tmp, start_angle, end_angle;
182
+    int   i, xi, yi;
184
     mesh_index_pair location;
183
     mesh_index_pair location;
185
 
184
 
186
-    if (axis_unhomed_error(true, true, true)) // Don't allow Mesh Validation without homing first
187
-      gcode_G28();
188
-
189
-    if (parse_G26_parameters()) return; // If the paramter parsing did not go OK, we abort the command
185
+    // Don't allow Mesh Validation without homing first
186
+    // If the paramter parsing did not go OK, we abort the command
187
+    if (axis_unhomed_error(true, true, true) || parse_G26_parameters()) return;
190
 
188
 
191
     if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
189
     if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
192
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
190
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
194
       set_current_to_destination();
192
       set_current_to_destination();
195
     }
193
     }
196
 
194
 
197
-    ubl.has_control_of_lcd_panel = true; // Take control of the LCD Panel!
198
-    if (turn_on_heaters())     // Turn on the heaters, leave the command if anything
199
-      goto LEAVE;              // has gone wrong.
195
+    if (turn_on_heaters()) goto LEAVE;
200
 
196
 
201
     current_position[E_AXIS] = 0.0;
197
     current_position[E_AXIS] = 0.0;
202
     sync_plan_position_e();
198
     sync_plan_position_e();
203
 
199
 
204
-    if (prime_flag && prime_nozzle())       // if prime_nozzle() returns an error, we just bail out.
205
-      goto LEAVE;
200
+    if (prime_flag && prime_nozzle()) goto LEAVE;
206
 
201
 
207
     /**
202
     /**
208
      *  Bed is preheated
203
      *  Bed is preheated
214
      *  It's  "Show Time" !!!
209
      *  It's  "Show Time" !!!
215
      */
210
      */
216
 
211
 
217
-    // Clear all of the flags we need
218
     ZERO(circle_flags);
212
     ZERO(circle_flags);
219
     ZERO(horizontal_mesh_line_flags);
213
     ZERO(horizontal_mesh_line_flags);
220
     ZERO(vertical_mesh_line_flags);
214
     ZERO(vertical_mesh_line_flags);
221
 
215
 
222
-    //
223
     // Move nozzle to the specified height for the first layer
216
     // Move nozzle to the specified height for the first layer
224
-    //
225
     set_destination_to_current();
217
     set_destination_to_current();
226
     destination[Z_AXIS] = layer_height;
218
     destination[Z_AXIS] = layer_height;
227
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
219
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
228
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
220
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
229
 
221
 
230
-    ubl.has_control_of_lcd_panel = true; // Take control of the LCD Panel!
222
+    ubl.has_control_of_lcd_panel++;
231
     //debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
223
     //debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
232
 
224
 
233
     /**
225
     /**
259
         goto LEAVE;
251
         goto LEAVE;
260
       }
252
       }
261
 
253
 
262
-      if (continue_with_closest)
263
-        location = find_closest_circle_to_print(current_position[X_AXIS], current_position[Y_AXIS]);
264
-      else
265
-        location = find_closest_circle_to_print(x_pos, y_pos); // Find the closest Mesh Intersection to where we are now.
254
+      location = continue_with_closest
255
+        ? find_closest_circle_to_print(current_position[X_AXIS], current_position[Y_AXIS])
256
+        : find_closest_circle_to_print(x_pos, y_pos); // Find the closest Mesh Intersection to where we are now.
266
 
257
 
267
       if (location.x_index >= 0 && location.y_index >= 0) {
258
       if (location.x_index >= 0 && location.y_index >= 0) {
268
-        circle_x = ubl.mesh_index_to_xpos[location.x_index];
269
-        circle_y = ubl.mesh_index_to_ypos[location.y_index];
259
+        const float circle_x = ubl.mesh_index_to_xpos[location.x_index],
260
+                    circle_y = ubl.mesh_index_to_ypos[location.y_index];
270
 
261
 
271
         // Let's do a couple of quick sanity checks.  We can pull this code out later if we never see it catch a problem
262
         // Let's do a couple of quick sanity checks.  We can pull this code out later if we never see it catch a problem
272
         #ifdef DELTA
263
         #ifdef DELTA
324
         for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
315
         for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
325
           int tmp_div_30 = tmp / 30.0;
316
           int tmp_div_30 = tmp / 30.0;
326
           if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
317
           if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
327
-
328
-          x = circle_x + cos_table[tmp_div_30];    // for speed, these are now a lookup table entry
329
-          y = circle_y + sin_table[tmp_div_30];
330
-
331
           if (tmp_div_30 > 11) tmp_div_30 -= 360 / 30;
318
           if (tmp_div_30 > 11) tmp_div_30 -= 360 / 30;
332
-          xe = circle_x + cos_table[tmp_div_30 + 1]; // for speed, these are now a lookup table entry
333
-          ye = circle_y + sin_table[tmp_div_30 + 1];
319
+
320
+          float x = circle_x + cos_table[tmp_div_30],    // for speed, these are now a lookup table entry
321
+                y = circle_y + sin_table[tmp_div_30],
322
+                xe = circle_x + cos_table[tmp_div_30 + 1],
323
+                ye = circle_y + sin_table[tmp_div_30 + 1];
334
           #ifdef DELTA
324
           #ifdef DELTA
335
             if (HYPOT2(x, y) > sq(DELTA_PRINTABLE_RADIUS))   // Check to make sure this part of
325
             if (HYPOT2(x, y) > sq(DELTA_PRINTABLE_RADIUS))   // Check to make sure this part of
336
               continue;                                      // the 'circle' is on the bed.  If
326
               continue;                                      // the 'circle' is on the bed.  If
337
           #else                                              // not, we need to skip
327
           #else                                              // not, we need to skip
338
-            x  = constrain(x, X_MIN_POS + 1, X_MAX_POS - 1);     // This keeps us from bumping the endstops
328
+            x  = constrain(x, X_MIN_POS + 1, X_MAX_POS - 1); // This keeps us from bumping the endstops
339
             y  = constrain(y, Y_MIN_POS + 1, Y_MAX_POS - 1);
329
             y  = constrain(y, Y_MIN_POS + 1, Y_MAX_POS - 1);
340
             xe = constrain(xe, X_MIN_POS + 1, X_MAX_POS - 1);
330
             xe = constrain(xe, X_MIN_POS + 1, X_MAX_POS - 1);
341
             ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
331
             ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
352
           //  debug_current_and_destination(seg_msg);
342
           //  debug_current_and_destination(seg_msg);
353
           //}
343
           //}
354
 
344
 
355
-          print_line_from_here_to_there(x, y, layer_height, xe, ye, layer_height);
345
+          print_line_from_here_to_there(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y), layer_height, LOGICAL_X_POSITION(xe), LOGICAL_Y_POSITION(ye), layer_height);
356
 
346
 
357
         }
347
         }
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
-        //}
364
 
348
 
365
         //debug_current_and_destination((char*)"Looking for lines to connect.");
349
         //debug_current_and_destination((char*)"Looking for lines to connect.");
366
         look_for_lines_to_connect();
350
         look_for_lines_to_connect();
368
       }
352
       }
369
 
353
 
370
       //debug_current_and_destination((char*)"Done with current circle.");
354
       //debug_current_and_destination((char*)"Done with current circle.");
371
-    }
372
-    while (location.x_index >= 0 && location.y_index >= 0);
355
+
356
+    } while (location.x_index >= 0 && location.y_index >= 0);
373
 
357
 
374
     LEAVE:
358
     LEAVE:
375
     lcd_reset_alert_level();
359
     lcd_reset_alert_level();
805
           lcd_setstatuspgm(PSTR("G26 Heating Bed."), 99);
789
           lcd_setstatuspgm(PSTR("G26 Heating Bed."), 99);
806
           lcd_quick_feedback();
790
           lcd_quick_feedback();
807
       #endif
791
       #endif
808
-          ubl.has_control_of_lcd_panel = true;
792
+          ubl.has_control_of_lcd_panel++;
809
           thermalManager.setTargetBed(bed_temp);
793
           thermalManager.setTargetBed(bed_temp);
810
           while (abs(thermalManager.degBed() - bed_temp) > 3) {
794
           while (abs(thermalManager.degBed() - bed_temp) > 3) {
811
             if (ubl_lcd_clicked()) return exit_from_g26();
795
             if (ubl_lcd_clicked()) return exit_from_g26();
840
     float Total_Prime = 0.0;
824
     float Total_Prime = 0.0;
841
 
825
 
842
     if (prime_flag == -1) {  // The user wants to control how much filament gets purged
826
     if (prime_flag == -1) {  // The user wants to control how much filament gets purged
827
+
828
+      ubl.has_control_of_lcd_panel++;
829
+
843
       lcd_setstatuspgm(PSTR("User-Controlled Prime"), 99);
830
       lcd_setstatuspgm(PSTR("User-Controlled Prime"), 99);
844
       chirp_at_user();
831
       chirp_at_user();
845
 
832
 
876
         lcd_setstatuspgm(PSTR("Done Priming"), 99);
863
         lcd_setstatuspgm(PSTR("Done Priming"), 99);
877
         lcd_quick_feedback();
864
         lcd_quick_feedback();
878
       #endif
865
       #endif
866
+
867
+      ubl.has_control_of_lcd_panel = false;
868
+
879
     }
869
     }
880
     else {
870
     else {
881
       #if ENABLED(ULTRA_LCD)
871
       #if ENABLED(ULTRA_LCD)

Loading…
Cancel
Save