|
@@ -3745,24 +3745,36 @@ void kill_screen(const char* lcd_msg) {
|
3745
|
3745
|
* "Print from SD" submenu
|
3746
|
3746
|
*
|
3747
|
3747
|
*/
|
|
3748
|
+
|
3748
|
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
|
3773
|
#endif
|
3752
|
3774
|
|
3753
|
3775
|
void lcd_sdcard_menu() {
|
3754
|
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
|
3778
|
const uint16_t fileCnt = card.getnrfilenames();
|
3767
|
3779
|
START_MENU();
|
3768
|
3780
|
MENU_BACK(MSG_MAIN);
|
|
@@ -4414,7 +4426,7 @@ void kill_screen(const char* lcd_msg) {
|
4414
|
4426
|
|
4415
|
4427
|
void menu_action_sdfile(const char* filename, char* longFilename) {
|
4416
|
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
|
4430
|
#endif
|
4419
|
4431
|
UNUSED(longFilename);
|
4420
|
4432
|
card.openAndPrintFile(filename);
|
|
@@ -4723,15 +4735,12 @@ void lcd_update() {
|
4723
|
4735
|
uint16_t bbr2 = planner.block_buffer_runtime() >> 1;
|
4724
|
4736
|
|
4725
|
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
|
4739
|
#else
|
4732
|
|
- if (lcdDrawUpdate && (!bbr2 || (bbr2 > max_display_update_time)))
|
|
4740
|
+ #define IS_DRAWING false
|
4733
|
4741
|
#endif
|
4734
|
|
- {
|
|
4742
|
+
|
|
4743
|
+ if ((lcdDrawUpdate || IS_DRAWING) && (!bbr2 || bbr2 > max_display_update_time)) {
|
4735
|
4744
|
#if ENABLED(DOGLCD)
|
4736
|
4745
|
if (!drawing_screen)
|
4737
|
4746
|
#endif
|
|
@@ -4781,12 +4790,7 @@ void lcd_update() {
|
4781
|
4790
|
|
4782
|
4791
|
// Return to Status Screen after a timeout
|
4783
|
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
|
4793
|
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
|
4789
|
|
- #endif
|
4790
|
4794
|
else if (ELAPSED(ms, return_to_status_ms))
|
4791
|
4795
|
lcd_return_to_status();
|
4792
|
4796
|
|