Selaa lähdekoodia

Move SD_REPRINT_LAST_SELECTED_FILE to ultralcd.cpp

Scott Lahteine 7 vuotta sitten
vanhempi
commit
8949c8c0a5
3 muutettua tiedostoa jossa 45 lisäystä ja 33 poistoa
  1. 40
    15
      Marlin/src/lcd/ultralcd.cpp
  2. 4
    0
      Marlin/src/lcd/ultralcd.h
  3. 1
    18
      Marlin/src/sd/cardreader.cpp

+ 40
- 15
Marlin/src/lcd/ultralcd.cpp Näytä tiedosto

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)
3778
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
3779
+        static millis_t assume_print_finished = 0;
3757
         if (ELAPSED(millis(), assume_print_finished)) { // if the printer has been busy printing, lcd_sdcard_menu() should not
3780
         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
3781
           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.
3782
+          encoderPosition = last_sdfile_encoderPosition;      // encoderPosition to the last selected item.
3760
           assume_print_finished = millis() + 5000;
3783
           assume_print_finished = millis() + 5000;
3761
         }
3784
         }
3762
-        saved_encoderPosition = encoderPosition;
3763
-        defer_return_to_status = true;
3785
+        last_sdfile_encoderPosition = encoderPosition;   // needed as a workaround for the 5s timer
3786
+        //defer_return_to_status = true;           // already done in lcd_reselect_last_file
3764
       #endif
3787
       #endif
3765
 
3788
 
3766
       const uint16_t fileCnt = card.getnrfilenames();
3789
       const uint16_t fileCnt = card.getnrfilenames();
4414
 
4437
 
4415
     void menu_action_sdfile(const char* filename, char* longFilename) {
4438
     void menu_action_sdfile(const char* filename, char* longFilename) {
4416
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4439
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
4417
-        saved_encoderPosition = encoderPosition;  // Save which file was selected for later use
4440
+        last_sdfile_encoderPosition = encoderPosition;  // Save which file was selected for later use
4418
       #endif
4441
       #endif
4419
       UNUSED(longFilename);
4442
       UNUSED(longFilename);
4420
       card.openAndPrintFile(filename);
4443
       card.openAndPrintFile(filename);
4722
     // then we want to use 1/2 of the time only.
4745
     // then we want to use 1/2 of the time only.
4723
     uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
4746
     uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
4724
 
4747
 
4725
-    #if ENABLED(DOGLCD)
4726
-      if ((lcdDrawUpdate || drawing_screen) && (!bbr2 || (bbr2 > max_display_update_time)
4727
-      #if ENABLED(SDSUPPORT)
4728
-        || (currentScreen == lcd_sdcard_menu)
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))
4729
       #endif
4758
       #endif
4730
-      ))
4731
-    #else
4732
-      if (lcdDrawUpdate && (!bbr2 || (bbr2 > max_display_update_time)))
4733
-    #endif
4734
-    {
4759
+    ) {
4735
       #if ENABLED(DOGLCD)
4760
       #if ENABLED(DOGLCD)
4736
         if (!drawing_screen)
4761
         if (!drawing_screen)
4737
       #endif
4762
       #endif

+ 4
- 0
Marlin/src/lcd/ultralcd.h Näytä tiedosto

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 Näytä tiedosto

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
 }

Loading…
Peruuta
Tallenna