|
@@ -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);
|