Przeglądaj źródła

Merge pull request #8160 from thinkyhead/bf1_fixup_sd_reprint

[1.1.x] Simplify SD_REPRINT_LAST_SELECTED_FILE
Scott Lahteine 7 lat temu
rodzic
commit
d9cb7be444
No account linked to committer's email address
1 zmienionych plików z 26 dodań i 38 usunięć
  1. 26
    38
      Marlin/ultralcd.cpp

+ 26
- 38
Marlin/ultralcd.cpp Wyświetl plik

@@ -2910,6 +2910,7 @@ void kill_screen(const char* lcd_msg) {
2910 2910
               max = soft_endstop_max[Z_AXIS];
2911 2911
             #endif
2912 2912
             break;
2913
+          default: break;
2913 2914
         }
2914 2915
       #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
2915 2916
 
@@ -3757,37 +3758,34 @@ void kill_screen(const char* lcd_msg) {
3757 3758
      */
3758 3759
 
3759 3760
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3760
-      uint32_t last_sdfile_encoderPosition = 0;
3761
+      uint32_t last_sdfile_encoderPosition = 0xFFFF;
3761 3762
 
3762 3763
       void lcd_reselect_last_file() {
3763
-        // Some of this is a hack to force the screen update to work.
3764
-        // TODO: Fix the real issue that causes this!
3765
-        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
3766
-        _lcd_synchronize();
3767
-        safe_delay(50);
3768
-        _lcd_synchronize();
3769
-        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
3770
-        drawing_screen = screen_changed = true;
3764
+        if (last_sdfile_encoderPosition == 0xFFFF) return;
3765
+        #if ENABLED(DOGLCD)
3766
+          // Some of this is a hack to force the screen update to work.
3767
+          // TODO: Fix the real issue that causes this!
3768
+          lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
3769
+          _lcd_synchronize();
3770
+          safe_delay(50);
3771
+          _lcd_synchronize();
3772
+          lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
3773
+          drawing_screen = screen_changed = true;
3774
+        #endif
3775
+
3771 3776
         lcd_goto_screen(lcd_sdcard_menu, last_sdfile_encoderPosition);
3772 3777
         defer_return_to_status = true;
3773
-        lcd_update();
3778
+        last_sdfile_encoderPosition = 0xFFFF;
3779
+
3780
+        #if ENABLED(DOGLCD)
3781
+          lcd_update();
3782
+        #endif
3774 3783
       }
3775 3784
     #endif
3776 3785
 
3777 3786
     void lcd_sdcard_menu() {
3778 3787
       ENCODER_DIRECTION_MENUS();
3779 3788
 
3780
-      #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3781
-        static millis_t assume_print_finished = 0;
3782
-        if (ELAPSED(millis(), assume_print_finished)) { // if the printer has been busy printing, lcd_sdcard_menu() should not
3783
-          lcdDrawUpdate = LCDVIEW_REDRAW_NOW;           // have been active for 5 seconds.  In this case, restore the previous
3784
-          encoderPosition = last_sdfile_encoderPosition;      // encoderPosition to the last selected item.
3785
-          assume_print_finished = millis() + 5000;
3786
-        }
3787
-        last_sdfile_encoderPosition = encoderPosition;   // needed as a workaround for the 5s timer
3788
-        //defer_return_to_status = true;           // already done in lcd_reselect_last_file
3789
-      #endif
3790
-
3791 3789
       const uint16_t fileCnt = card.getnrfilenames();
3792 3790
       START_MENU();
3793 3791
       MENU_BACK(MSG_MAIN);
@@ -4745,18 +4743,13 @@ void lcd_update() {
4745 4743
     // then we want to use 1/2 of the time only.
4746 4744
     uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
4747 4745
 
4748
-    if (
4749
-      #if ENABLED(DOGLCD)
4750
-        (lcdDrawUpdate || drawing_screen) && (
4751
-          !bbr2 || (bbr2 > max_display_update_time)
4752
-          #if ENABLED(SDSUPPORT)
4753
-            || currentScreen == lcd_sdcard_menu
4754
-          #endif
4755
-        )
4756
-      #else
4757
-        lcdDrawUpdate && (!bbr2 || (bbr2 > max_display_update_time))
4758
-      #endif
4759
-    ) {
4746
+    #if ENABLED(DOGLCD)
4747
+      #define IS_DRAWING drawing_screen
4748
+    #else
4749
+      #define IS_DRAWING false
4750
+    #endif
4751
+
4752
+    if ((lcdDrawUpdate || IS_DRAWING) && (!bbr2 || bbr2 > max_display_update_time)) {
4760 4753
       #if ENABLED(DOGLCD)
4761 4754
         if (!drawing_screen)
4762 4755
       #endif
@@ -4806,12 +4799,7 @@ void lcd_update() {
4806 4799
 
4807 4800
       // Return to Status Screen after a timeout
4808 4801
       if (currentScreen == lcd_status_screen || defer_return_to_status)
4809
-        #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4810
-          if (currentScreen != lcd_sdcard_menu)                // lcd_sdcard_menu() does not time out if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4811
-            return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;  // When the printer finishes a file, it will wait with the file selected for 
4812
-        #else                                                  // a re-print.
4813 4802
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
4814
-        #endif
4815 4803
       else if (ELAPSED(ms, return_to_status_ms))
4816 4804
         lcd_return_to_status();
4817 4805
 

Ładowanie…
Anuluj
Zapisz