Browse Source

Merge pull request #8160 from thinkyhead/bf1_fixup_sd_reprint

[1.1.x] Simplify SD_REPRINT_LAST_SELECTED_FILE
Scott Lahteine 7 years ago
parent
commit
d9cb7be444
No account linked to committer's email address
1 changed files with 26 additions and 38 deletions
  1. 26
    38
      Marlin/ultralcd.cpp

+ 26
- 38
Marlin/ultralcd.cpp View File

2910
               max = soft_endstop_max[Z_AXIS];
2910
               max = soft_endstop_max[Z_AXIS];
2911
             #endif
2911
             #endif
2912
             break;
2912
             break;
2913
+          default: break;
2913
         }
2914
         }
2914
       #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
2915
       #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
2915
 
2916
 
3757
      */
3758
      */
3758
 
3759
 
3759
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
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
       void lcd_reselect_last_file() {
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
         lcd_goto_screen(lcd_sdcard_menu, last_sdfile_encoderPosition);
3776
         lcd_goto_screen(lcd_sdcard_menu, last_sdfile_encoderPosition);
3772
         defer_return_to_status = true;
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
     #endif
3784
     #endif
3776
 
3785
 
3777
     void lcd_sdcard_menu() {
3786
     void lcd_sdcard_menu() {
3778
       ENCODER_DIRECTION_MENUS();
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
       const uint16_t fileCnt = card.getnrfilenames();
3789
       const uint16_t fileCnt = card.getnrfilenames();
3792
       START_MENU();
3790
       START_MENU();
3793
       MENU_BACK(MSG_MAIN);
3791
       MENU_BACK(MSG_MAIN);
4745
     // then we want to use 1/2 of the time only.
4743
     // then we want to use 1/2 of the time only.
4746
     uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
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
       #if ENABLED(DOGLCD)
4753
       #if ENABLED(DOGLCD)
4761
         if (!drawing_screen)
4754
         if (!drawing_screen)
4762
       #endif
4755
       #endif
4806
 
4799
 
4807
       // Return to Status Screen after a timeout
4800
       // Return to Status Screen after a timeout
4808
       if (currentScreen == lcd_status_screen || defer_return_to_status)
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
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
4802
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
4814
-        #endif
4815
       else if (ELAPSED(ms, return_to_status_ms))
4803
       else if (ELAPSED(ms, return_to_status_ms))
4816
         lcd_return_to_status();
4804
         lcd_return_to_status();
4817
 
4805
 

Loading…
Cancel
Save