Просмотр исходного кода

Fix MBL to handle re-entrant calls

Scott Lahteine 8 лет назад
Родитель
Сommit
d659777e70
1 измененных файлов: 22 добавлений и 2 удалений
  1. 22
    2
      Marlin/ultralcd.cpp

+ 22
- 2
Marlin/ultralcd.cpp Просмотреть файл

@@ -2483,8 +2483,19 @@ char* ftostr52(const float& x) {
2483 2483
    *   - Click saves the Z and goes to the next mesh point
2484 2484
    */
2485 2485
   static void _lcd_level_bed() {
2486
+    static bool mbl_wait_for_move = false;
2487
+    // Menu handlers may be called in a re-entrant fashion
2488
+    // if they call st_synchronize or plan_buffer_line. So
2489
+    // while waiting for a move we just ignore new input.
2490
+    if (mbl_wait_for_move) {
2491
+      lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
2492
+      return;
2493
+    }
2494
+
2486 2495
     ENCODER_DIRECTION_NORMAL();
2487
-    if ((encoderPosition != 0) && (movesplanned() <= 3)) {
2496
+
2497
+    // Encoder wheel adjusts the Z position
2498
+    if (encoderPosition != 0 && movesplanned() <= 3) {
2488 2499
       refresh_cmd_timeout();
2489 2500
       current_position[Z_AXIS] += float((int)encoderPosition) * (MBL_Z_STEP);
2490 2501
       if (min_software_endstops) NOLESS(current_position[Z_AXIS], Z_MIN_POS);
@@ -2493,10 +2504,18 @@ char* ftostr52(const float& x) {
2493 2504
       line_to_current(Z_AXIS);
2494 2505
       lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
2495 2506
     }
2507
+
2508
+    // Update on first display, then only on updates to Z position
2496 2509
     if (lcdDrawUpdate) {
2497 2510
       float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
2498 2511
       lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001), '+'));
2499 2512
     }
2513
+
2514
+    // We want subsequent calls, but don't force redraw
2515
+    // Set here so it can be overridden by lcd_return_to_status below
2516
+    lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
2517
+
2518
+    // Click sets the current Z and moves to the next position
2500 2519
     static bool debounce_click = false;
2501 2520
     if (LCD_CLICKED) {
2502 2521
       if (!debounce_click) {
@@ -2508,10 +2527,12 @@ char* ftostr52(const float& x) {
2508 2527
         _lcd_level_bed_position++;
2509 2528
         if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
2510 2529
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2530
+          mbl_wait_for_move = true;
2511 2531
           line_to_current(Z_AXIS);
2512 2532
           st_synchronize();
2513 2533
           mbl.active = 1;
2514 2534
           enqueue_and_echo_commands_P(PSTR("G28"));
2535
+          mbl_wait_for_move = false;
2515 2536
           lcd_return_to_status();
2516 2537
           #if ENABLED(NEWPANEL)
2517 2538
             lcd_quick_feedback();
@@ -2531,7 +2552,6 @@ char* ftostr52(const float& x) {
2531 2552
           current_position[X_AXIS] = mbl.get_x(ix);
2532 2553
           current_position[Y_AXIS] = mbl.get_y(iy);
2533 2554
           line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
2534
-          lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
2535 2555
         }
2536 2556
       }
2537 2557
     }

Загрузка…
Отмена
Сохранить