Przeglądaj źródła

Merge pull request #8113 from thinkyhead/bf2_fixup_sd_reprint

[2.0.x] Cleanup after SD Print Again, whitespace, tabs
Scott Lahteine 7 lat temu
rodzic
commit
c94dce6b32
No account linked to committer's email address

+ 29
- 25
Marlin/src/lcd/ultralcd.cpp Wyświetl plik

3745
      * "Print from SD" submenu
3745
      * "Print from SD" submenu
3746
      *
3746
      *
3747
      */
3747
      */
3748
+
3748
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3749
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3749
-      uint32_t saved_encoderPosition = 0;
3750
-      static millis_t assume_print_finished = 0;
3750
+      uint32_t last_sdfile_encoderPosition = 0xFFFF;
3751
+
3752
+      void lcd_reselect_last_file() {
3753
+        if (last_sdfile_encoderPosition == 0xFFFF) return;
3754
+        #if ENABLED(DOGLCD)
3755
+          // Some of this is a hack to force the screen update to work.
3756
+          // TODO: Fix the real issue that causes this!
3757
+          lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
3758
+          _lcd_synchronize();
3759
+          safe_delay(50);
3760
+          _lcd_synchronize();
3761
+          lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
3762
+          drawing_screen = screen_changed = true;
3763
+        #endif
3764
+
3765
+        lcd_goto_screen(lcd_sdcard_menu, last_sdfile_encoderPosition);
3766
+        defer_return_to_status = true;
3767
+        last_sdfile_encoderPosition == 0xFFFF;
3768
+
3769
+        #if ENABLED(DOGLCD)
3770
+          lcd_update();
3771
+        #endif
3772
+      }
3751
     #endif
3773
     #endif
3752
 
3774
 
3753
     void lcd_sdcard_menu() {
3775
     void lcd_sdcard_menu() {
3754
       ENCODER_DIRECTION_MENUS();
3776
       ENCODER_DIRECTION_MENUS();
3755
 
3777
 
3756
-      #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3757
-        if (ELAPSED(millis(), assume_print_finished)) { // if the printer has been busy printing, lcd_sdcard_menu() should not
3758
-          lcdDrawUpdate = LCDVIEW_REDRAW_NOW;           // have been active for 5 seconds.  In this case, restore the previous
3759
-          encoderPosition = saved_encoderPosition;      // encoderPosition to the last selected item.
3760
-          assume_print_finished = millis() + 5000;
3761
-        }
3762
-        saved_encoderPosition = encoderPosition;
3763
-        defer_return_to_status = true;
3764
-      #endif
3765
-
3766
       const uint16_t fileCnt = card.getnrfilenames();
3778
       const uint16_t fileCnt = card.getnrfilenames();
3767
       START_MENU();
3779
       START_MENU();
3768
       MENU_BACK(MSG_MAIN);
3780
       MENU_BACK(MSG_MAIN);
4414
 
4426
 
4415
     void menu_action_sdfile(const char* filename, char* longFilename) {
4427
     void menu_action_sdfile(const char* filename, char* longFilename) {
4416
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4428
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4417
-        saved_encoderPosition = encoderPosition;  // Save which file was selected for later use
4429
+        last_sdfile_encoderPosition = encoderPosition;  // Save which file was selected for later use
4418
       #endif
4430
       #endif
4419
       UNUSED(longFilename);
4431
       UNUSED(longFilename);
4420
       card.openAndPrintFile(filename);
4432
       card.openAndPrintFile(filename);
4723
     uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
4735
     uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
4724
 
4736
 
4725
     #if ENABLED(DOGLCD)
4737
     #if ENABLED(DOGLCD)
4726
-      if ((lcdDrawUpdate || drawing_screen) && (!bbr2 || (bbr2 > max_display_update_time)
4727
-      #if ENABLED(SDSUPPORT)
4728
-        || (currentScreen == lcd_sdcard_menu)
4729
-      #endif
4730
-      ))
4738
+      #define IS_DRAWING drawing_screen
4731
     #else
4739
     #else
4732
-      if (lcdDrawUpdate && (!bbr2 || (bbr2 > max_display_update_time)))
4740
+      #define IS_DRAWING false
4733
     #endif
4741
     #endif
4734
-    {
4742
+
4743
+    if ((lcdDrawUpdate || IS_DRAWING) && (!bbr2 || bbr2 > max_display_update_time)) {
4735
       #if ENABLED(DOGLCD)
4744
       #if ENABLED(DOGLCD)
4736
         if (!drawing_screen)
4745
         if (!drawing_screen)
4737
       #endif
4746
       #endif
4781
 
4790
 
4782
       // Return to Status Screen after a timeout
4791
       // Return to Status Screen after a timeout
4783
       if (currentScreen == lcd_status_screen || defer_return_to_status)
4792
       if (currentScreen == lcd_status_screen || defer_return_to_status)
4784
-        #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4785
-          if (currentScreen != lcd_sdcard_menu)                // lcd_sdcard_menu() does not time out if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4786
-            return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;  // When the printer finishes a file, it will wait with the file selected for
4787
-        #else                                                  // a re-print.
4788
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
4793
         return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
4789
-        #endif
4790
       else if (ELAPSED(ms, return_to_status_ms))
4794
       else if (ELAPSED(ms, return_to_status_ms))
4791
         lcd_return_to_status();
4795
         lcd_return_to_status();
4792
 
4796
 

+ 4
- 0
Marlin/src/lcd/ultralcd.h Wyświetl plik

223
   #define BUZZ(d,f) lcd_buzz(d, f)
223
   #define BUZZ(d,f) lcd_buzz(d, f)
224
 #endif
224
 #endif
225
 
225
 
226
+#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
227
+  void lcd_reselect_last_file();
228
+#endif
229
+
226
 #endif // ULTRALCD_H
230
 #endif // ULTRALCD_H

+ 1
- 18
Marlin/src/sd/cardreader.cpp Wyświetl plik

892
   ;
892
   ;
893
 }
893
 }
894
 
894
 
895
-#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
896
-  typedef void (*screenFunc_t)();
897
-  extern void lcd_sdcard_menu();
898
-  extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0);
899
-  extern uint32_t saved_encoderPosition;
900
-  extern bool screen_changed, drawing_screen, defer_return_to_status;
901
-  void _lcd_synchronize();  // Not declared in any LCD header file.  Probably, that should be changed.
902
-#endif
903
-
904
 void CardReader::printingHasFinished() {
895
 void CardReader::printingHasFinished() {
905
   stepper.synchronize();
896
   stepper.synchronize();
906
   file.close();
897
   file.close();
922
     #endif
913
     #endif
923
 
914
 
924
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
915
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
925
-      lcdDrawUpdate  = LCDVIEW_CALL_REDRAW_NEXT;
926
-      _lcd_synchronize();
927
-      safe_delay(50);
928
-      _lcd_synchronize();
929
-      lcdDrawUpdate  = LCDVIEW_CALL_REDRAW_NEXT;
930
-      drawing_screen = screen_changed = true;
931
-      lcd_goto_screen(lcd_sdcard_menu, saved_encoderPosition);
932
-      defer_return_to_status = true;
933
-      lcd_update();
916
+      lcd_reselect_last_file();
934
     #endif
917
     #endif
935
   }
918
   }
936
 }
919
 }

Ładowanie…
Anuluj
Zapisz