Ver código fonte

Merge pull request #8114 from thinkyhead/bf1_print_sd_file_again

[1.1.x] Cleanup for SD Print Again
Scott Lahteine 7 anos atrás
pai
commit
25e86a520d
Nenhuma conta vinculada ao e-mail do autor do commit
3 arquivos alterados com 29 adições e 27 exclusões
  1. 1
    18
      Marlin/cardreader.cpp
  2. 24
    9
      Marlin/ultralcd.cpp
  3. 4
    0
      Marlin/ultralcd.h

+ 1
- 18
Marlin/cardreader.cpp Ver arquivo

@@ -860,15 +860,6 @@ void CardReader::updir() {
860 860
 
861 861
 #endif // SDCARD_SORT_ALPHA
862 862
 
863
-#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
864
-  typedef void (*screenFunc_t)();
865
-  extern void lcd_sdcard_menu();
866
-  extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0);
867
-  extern uint32_t saved_encoderPosition;
868
-  extern bool screen_changed, drawing_screen, defer_return_to_status;
869
-  void _lcd_synchronize();  // Not declared in any LCD header file.  Probably, that should be changed.
870
-#endif
871
-
872 863
 void CardReader::printingHasFinished() {
873 864
   stepper.synchronize();
874 865
   file.close();
@@ -890,15 +881,7 @@ void CardReader::printingHasFinished() {
890 881
     #endif
891 882
 
892 883
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
893
-      lcdDrawUpdate  = LCDVIEW_CALL_REDRAW_NEXT;
894
-      _lcd_synchronize();
895
-      safe_delay(50);
896
-      _lcd_synchronize();
897
-      lcdDrawUpdate  = LCDVIEW_CALL_REDRAW_NEXT;
898
-      drawing_screen = screen_changed = true;
899
-      lcd_goto_screen(lcd_sdcard_menu, saved_encoderPosition);
900
-      defer_return_to_status = true;
901
-      lcd_update();
884
+      lcd_reselect_last_file();
902 885
     #endif
903 886
   }
904 887
 }

+ 24
- 9
Marlin/ultralcd.cpp Ver arquivo

@@ -3755,24 +3755,39 @@ void kill_screen(const char* lcd_msg) {
3755 3755
      * "Print from SD" submenu
3756 3756
      *
3757 3757
      */
3758
+
3758 3759
     #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3759
-      uint32_t saved_encoderPosition = 0;
3760
-      static millis_t assume_print_finished = 0;
3760
+      uint32_t last_sdfile_encoderPosition = 0;
3761
+
3762
+      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;
3771
+        lcd_goto_screen(lcd_sdcard_menu, last_sdfile_encoderPosition);
3772
+        defer_return_to_status = true;
3773
+        lcd_update();
3774
+      }
3761 3775
     #endif
3762 3776
 
3763 3777
     void lcd_sdcard_menu() {
3764 3778
       ENCODER_DIRECTION_MENUS();
3765
-  
3779
+
3766 3780
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3767
-        if (ELAPSED(millis(), assume_print_finished)) { // if the printer has been busy printing, lcd_sdcard_menu() should not 
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
3768 3783
           lcdDrawUpdate = LCDVIEW_REDRAW_NOW;           // have been active for 5 seconds.  In this case, restore the previous
3769
-          encoderPosition = saved_encoderPosition;      // encoderPosition to the last selected item.
3784
+          encoderPosition = last_sdfile_encoderPosition;      // encoderPosition to the last selected item.
3770 3785
           assume_print_finished = millis() + 5000;
3771 3786
         }
3772
-        saved_encoderPosition = encoderPosition;
3773
-        defer_return_to_status = true;
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
3774 3789
       #endif
3775
-      
3790
+
3776 3791
       const uint16_t fileCnt = card.getnrfilenames();
3777 3792
       START_MENU();
3778 3793
       MENU_BACK(MSG_MAIN);
@@ -4422,7 +4437,7 @@ void kill_screen(const char* lcd_msg) {
4422 4437
 
4423 4438
     void menu_action_sdfile(const char* filename, char* longFilename) {
4424 4439
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4425
-        saved_encoderPosition = encoderPosition;  // Save which file was selected for later use
4440
+        last_sdfile_encoderPosition = encoderPosition;  // Save which file was selected for later use
4426 4441
       #endif
4427 4442
       UNUSED(longFilename);
4428 4443
       card.openAndPrintFile(filename);

+ 4
- 0
Marlin/ultralcd.h Ver arquivo

@@ -205,4 +205,8 @@ void lcd_reset_status();
205 205
   float lcd_probe_pt(const float &lx, const float &ly);
206 206
 #endif
207 207
 
208
+#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
209
+  void lcd_reselect_last_file();
210
+#endif
211
+
208 212
 #endif // ULTRALCD_H

Carregando…
Cancelar
Salvar