Преглед на файлове

Merge pull request #8966 from thinkyhead/bf2_better_no_reentry

[2.0.x] ultralcd.cpp: Better no_reentry, use in queuing G-code
Scott Lahteine преди 7 години
родител
ревизия
2b1e6829b3
No account linked to committer's email address
променени са 5 файла, в които са добавени 53 реда и са изтрити 52 реда
  1. 1
    1
      Marlin/src/Marlin.cpp
  2. 9
    10
      Marlin/src/feature/pause.cpp
  3. 1
    1
      Marlin/src/feature/pause.h
  4. 2
    2
      Marlin/src/gcode/calibrate/G33.cpp
  5. 40
    38
      Marlin/src/lcd/ultralcd.cpp

+ 1
- 1
Marlin/src/Marlin.cpp Целия файл

@@ -346,7 +346,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
346 346
 
347 347
   // Prevent steppers timing-out in the middle of M600
348 348
   #if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT)
349
-    #define MOVE_AWAY_TEST !move_away_flag
349
+    #define MOVE_AWAY_TEST !did_pause_print
350 350
   #else
351 351
     #define MOVE_AWAY_TEST true
352 352
   #endif

+ 9
- 10
Marlin/src/feature/pause.cpp Целия файл

@@ -54,7 +54,6 @@ static float resume_position[XYZE];
54 54
 
55 55
 #if ENABLED(SDSUPPORT)
56 56
   #include "../sd/cardreader.h"
57
-  static bool sd_print_paused = false;
58 57
 #endif
59 58
 
60 59
 #if HAS_BUZZER
@@ -107,12 +106,12 @@ void do_pause_e_move(const float &length, const float fr) {
107 106
 
108 107
 // public:
109 108
 
110
-bool move_away_flag = false;
109
+uint8_t did_pause_print = 0;
111 110
 
112 111
 bool pause_print(const float &retract, const point_t &park_point, const float &unload_length/*=0*/,
113 112
                  const int8_t max_beep_count/*=0*/, const bool show_lcd/*=false*/
114 113
 ) {
115
-  if (move_away_flag) return false; // already paused
114
+  if (did_pause_print) return false; // already paused
116 115
 
117 116
   #ifdef ACTION_ON_PAUSE
118 117
     SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE);
@@ -132,13 +131,13 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u
132 131
   }
133 132
 
134 133
   // Indicate that the printer is paused
135
-  move_away_flag = true;
134
+  ++did_pause_print;
136 135
 
137 136
   // Pause the print job and timer
138 137
   #if ENABLED(SDSUPPORT)
139 138
     if (IS_SD_PRINTING) {
140 139
       card.pauseSDPrint();
141
-      sd_print_paused = true;
140
+      ++did_pause_print;
142 141
     }
143 142
   #endif
144 143
   print_job_timer.pause();
@@ -256,7 +255,7 @@ void wait_for_filament_reload(const int8_t max_beep_count/*=0*/) {
256 255
 void resume_print(const float &load_length/*=0*/, const float &initial_extrude_length/*=0*/, const int8_t max_beep_count/*=0*/) {
257 256
   bool nozzle_timed_out = false;
258 257
 
259
-  if (!move_away_flag) return;
258
+  if (!did_pause_print) return;
260 259
 
261 260
   // Re-enable the heaters if they timed out
262 261
   HOTEND_LOOP() {
@@ -350,14 +349,14 @@ void resume_print(const float &load_length/*=0*/, const float &initial_extrude_l
350 349
     SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME);
351 350
   #endif
352 351
 
352
+  --did_pause_print;
353
+
353 354
   #if ENABLED(SDSUPPORT)
354
-    if (sd_print_paused) {
355
+    if (did_pause_print) {
355 356
       card.startFileprint();
356
-      sd_print_paused = false;
357
+      --did_pause_print;
357 358
     }
358 359
   #endif
359
-
360
-  move_away_flag = false;
361 360
 }
362 361
 
363 362
 #endif // ADVANCED_PAUSE_FEATURE || PARK_HEAD_ON_PAUSE

+ 1
- 1
Marlin/src/feature/pause.h Целия файл

@@ -30,7 +30,7 @@
30 30
 
31 31
 #include "../libs/nozzle.h"
32 32
 
33
-extern bool move_away_flag;
33
+extern bool did_pause_print;
34 34
 
35 35
 bool pause_print(const float &retract, const point_t &park_point, const float &unload_length=0,
36 36
                  const int8_t max_beep_count=0, const bool show_lcd=false

+ 2
- 2
Marlin/src/gcode/calibrate/G33.cpp Целия файл

@@ -491,7 +491,7 @@ void GcodeSuite::G33() {
491 491
 
492 492
   // Report settings
493 493
 
494
-  const char *checkingac = PSTR("Checking... AC"); // TODO: Make translatable string
494
+  PGM_P checkingac = PSTR("Checking... AC"); // TODO: Make translatable string
495 495
   serialprintPGM(checkingac);
496 496
   if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
497 497
   SERIAL_EOL();
@@ -673,7 +673,7 @@ void GcodeSuite::G33() {
673 673
       }
674 674
     }
675 675
     else {                                                       // dry run
676
-      const char *enddryrun = PSTR("End DRY-RUN");
676
+      PGM_P enddryrun = PSTR("End DRY-RUN");
677 677
       serialprintPGM(enddryrun);
678 678
       SERIAL_PROTOCOL_SP(35);
679 679
       SERIAL_PROTOCOLPGM("std dev:");

+ 40
- 38
Marlin/src/lcd/ultralcd.cpp Целия файл

@@ -164,6 +164,8 @@ uint16_t max_display_update_time = 0;
164 164
     extern bool powersupply_on;
165 165
   #endif
166 166
 
167
+  bool no_reentry = false;
168
+
167 169
   ////////////////////////////////////////////
168 170
   ///////////////// Menu Tree ////////////////
169 171
   ////////////////////////////////////////////
@@ -572,14 +574,13 @@ uint16_t max_display_update_time = 0;
572 574
   // done. ** This blocks the command queue! **
573 575
   //
574 576
   void _lcd_synchronize() {
575
-    static bool no_reentry = false;
576 577
     if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
577 578
     if (no_reentry) return;
578 579
     // Make this the current handler till all moves are done
579 580
     no_reentry = true;
580 581
     const screenFunc_t old_screen = currentScreen;
581 582
     lcd_goto_screen(_lcd_synchronize);
582
-    stepper.synchronize();
583
+    stepper.synchronize(); // idle() is called until moves complete
583 584
     no_reentry = false;
584 585
     lcd_goto_screen(old_screen);
585 586
   }
@@ -1741,6 +1742,20 @@ void kill_screen(const char* lcd_msg) {
1741 1742
     lcd_return_to_status();
1742 1743
   }
1743 1744
 
1745
+  #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE)
1746
+
1747
+    /**
1748
+     * If the queue is full, the command will fail, so we have to loop
1749
+     * with idle() to make sure the command has been enqueued.
1750
+     */
1751
+    void lcd_enqueue_command_sram(char * const cmd) {
1752
+      no_reentry = true;
1753
+      while (enqueue_and_echo_command(cmd)) idle();
1754
+      no_reentry = false;
1755
+    }
1756
+
1757
+  #endif
1758
+
1744 1759
   #if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
1745 1760
 
1746 1761
     void lcd_autostart_sd() {
@@ -1917,7 +1932,6 @@ void kill_screen(const char* lcd_msg) {
1917 1932
      * Step 5: Initiate a move to the next point
1918 1933
      */
1919 1934
     void _lcd_level_goto_next_point() {
1920
-      // Set the menu to display ahead of blocking call
1921 1935
       lcd_goto_screen(_lcd_level_bed_moving);
1922 1936
 
1923 1937
       // G29 Records Z, moves, and signals when it pauses
@@ -2065,10 +2079,10 @@ void kill_screen(const char* lcd_msg) {
2065 2079
       enqueue_and_echo_commands_P(PSTR("G28"));
2066 2080
       #if HAS_TEMP_BED
2067 2081
         sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp);
2068
-        enqueue_and_echo_command(UBL_LCD_GCODE);
2082
+        lcd_enqueue_command_sram(UBL_LCD_GCODE);
2069 2083
       #endif
2070 2084
       sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp);
2071
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2085
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2072 2086
       enqueue_and_echo_commands_P(PSTR("G29 P1"));
2073 2087
     }
2074 2088
 
@@ -2099,7 +2113,7 @@ void kill_screen(const char* lcd_msg) {
2099 2113
       const int ind = ubl_height_amount > 0 ? 9 : 10;
2100 2114
       strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -"));
2101 2115
       sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), abs(ubl_height_amount));
2102
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2116
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2103 2117
     }
2104 2118
 
2105 2119
     /**
@@ -2149,8 +2163,9 @@ void kill_screen(const char* lcd_msg) {
2149 2163
           0
2150 2164
         #endif
2151 2165
       ;
2152
-      sprintf_P(UBL_LCD_GCODE, PSTR("G28\nG26 C B%i H%i P"), temp, custom_hotend_temp);
2153
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2166
+      sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
2167
+      lcd_enqueue_command_sram("G28");
2168
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2154 2169
     }
2155 2170
 
2156 2171
     /**
@@ -2183,7 +2198,7 @@ void kill_screen(const char* lcd_msg) {
2183 2198
     void _lcd_ubl_grid_level_cmd() {
2184 2199
       char UBL_LCD_GCODE[10];
2185 2200
       sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points);
2186
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2201
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2187 2202
     }
2188 2203
 
2189 2204
     /**
@@ -2224,16 +2239,7 @@ void kill_screen(const char* lcd_msg) {
2224 2239
     void _lcd_ubl_fillin_amount_cmd() {
2225 2240
       char UBL_LCD_GCODE[16];
2226 2241
       sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
2227
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2228
-    }
2229
-
2230
-    /**
2231
-     * UBL Smart Fill-in Command
2232
-     */
2233
-    void _lcd_ubl_smart_fillin_cmd() {
2234
-      char UBL_LCD_GCODE[12];
2235
-      sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 T0"));
2236
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2242
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2237 2243
     }
2238 2244
 
2239 2245
     /**
@@ -2250,7 +2256,7 @@ void kill_screen(const char* lcd_msg) {
2250 2256
       START_MENU();
2251 2257
       MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
2252 2258
       MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
2253
-      MENU_ITEM(function, MSG_UBL_SMART_FILLIN, _lcd_ubl_smart_fillin_cmd);
2259
+      MENU_ITEM(gcode, MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
2254 2260
       MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
2255 2261
       MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
2256 2262
       END_MENU();
@@ -2323,22 +2329,20 @@ void kill_screen(const char* lcd_msg) {
2323 2329
      * UBL Load Mesh Command
2324 2330
      */
2325 2331
     void _lcd_ubl_load_mesh_cmd() {
2326
-      char UBL_LCD_GCODE[25];
2332
+      char UBL_LCD_GCODE[10];
2327 2333
       sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot);
2328
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2329
-      sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_LOADED "."), ubl_storage_slot);
2330
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2334
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2335
+      enqueue_and_echo_commands_P(PSTR("M117 " MSG_MESH_LOADED "."));
2331 2336
     }
2332 2337
 
2333 2338
     /**
2334 2339
      * UBL Save Mesh Command
2335 2340
      */
2336 2341
     void _lcd_ubl_save_mesh_cmd() {
2337
-      char UBL_LCD_GCODE[25];
2342
+      char UBL_LCD_GCODE[10];
2338 2343
       sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot);
2339
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2340
-      sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_SAVED "."), ubl_storage_slot);
2341
-      enqueue_and_echo_command(UBL_LCD_GCODE);
2344
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2345
+      enqueue_and_echo_commands_P(PSTR("M117 " MSG_MESH_SAVED "."));
2342 2346
     }
2343 2347
 
2344 2348
     /**
@@ -2384,12 +2388,11 @@ void kill_screen(const char* lcd_msg) {
2384 2388
      * UBL LCD "radar" map point editing
2385 2389
      */
2386 2390
     void _lcd_ubl_map_lcd_edit_cmd() {
2387
-      char ubl_lcd_gcode [50], str[10], str2[10];
2388
-
2391
+      char UBL_LCD_GCODE[50], str[10], str2[10];
2389 2392
       dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
2390 2393
       dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
2391
-      snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
2392
-      enqueue_and_echo_command(ubl_lcd_gcode);
2394
+      snprintf_P(UBL_LCD_GCODE, sizeof(UBL_LCD_GCODE), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
2395
+      lcd_enqueue_command_sram(UBL_LCD_GCODE);
2393 2396
     }
2394 2397
 
2395 2398
     /**
@@ -2537,7 +2540,7 @@ void kill_screen(const char* lcd_msg) {
2537 2540
       START_MENU();
2538 2541
       MENU_BACK(MSG_UBL_LEVEL_BED);
2539 2542
       MENU_ITEM(gcode, "1 " MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
2540
-      MENU_ITEM(function, "2 " MSG_UBL_SMART_FILLIN, _lcd_ubl_smart_fillin_cmd);
2543
+      MENU_ITEM(gcode, "2 " MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
2541 2544
       MENU_ITEM(submenu, "3 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
2542 2545
       MENU_ITEM(gcode, "4 " MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
2543 2546
       MENU_ITEM(submenu, "5 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
@@ -2979,11 +2982,10 @@ void kill_screen(const char* lcd_msg) {
2979 2982
       #endif
2980 2983
 
2981 2984
       manual_move_to_current(axis);
2982
-
2983 2985
       lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2984 2986
     }
2985 2987
     encoderPosition = 0;
2986
-    if (lcdDrawUpdate && !processing_manual_move) {
2988
+    if (lcdDrawUpdate) {
2987 2989
       const float pos = current_position[axis]
2988 2990
         #if IS_KINEMATIC
2989 2991
           + manual_move_offset
@@ -3019,7 +3021,7 @@ void kill_screen(const char* lcd_msg) {
3019 3021
       }
3020 3022
       encoderPosition = 0;
3021 3023
     }
3022
-    if (lcdDrawUpdate && !processing_manual_move) {
3024
+    if (lcdDrawUpdate) {
3023 3025
       PGM_P pos_label;
3024 3026
       #if E_MANUAL == 1
3025 3027
         pos_label = PSTR(MSG_MOVE_E);
@@ -3283,7 +3285,7 @@ void kill_screen(const char* lcd_msg) {
3283 3285
           autotune_temp[e]
3284 3286
         #endif
3285 3287
       );
3286
-      enqueue_and_echo_command(cmd);
3288
+      lcd_enqueue_command_sram(cmd);
3287 3289
     }
3288 3290
 
3289 3291
   #endif // PID_AUTOTUNE_MENU
@@ -4719,7 +4721,7 @@ void lcd_update() {
4719 4721
     if (UBL_CONDITION && LCD_CLICKED) {
4720 4722
       if (!wait_for_unclick) {           // If not waiting for a debounce release:
4721 4723
         wait_for_unclick = true;         //  Set debounce flag to ignore continous clicks
4722
-        lcd_clicked = !wait_for_user;    //  Keep the click if not waiting for a user-click
4724
+        lcd_clicked = !wait_for_user && !no_reentry; // Flag the click if allowed
4723 4725
         wait_for_user = false;           //  Any click clears wait for user
4724 4726
         lcd_quick_feedback();            //  Always make a click sound
4725 4727
       }

Loading…
Отказ
Запис