|
@@ -3745,22 +3745,45 @@ 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
|
3778
|
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
|
|
3779
|
+ static millis_t assume_print_finished = 0;
|
3757
|
3780
|
if (ELAPSED(millis(), assume_print_finished)) { // if the printer has been busy printing, lcd_sdcard_menu() should not
|
3758
|
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
|
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
|
3787
|
#endif
|
3765
|
3788
|
|
3766
|
3789
|
const uint16_t fileCnt = card.getnrfilenames();
|
|
@@ -4414,7 +4437,7 @@ void kill_screen(const char* lcd_msg) {
|
4414
|
4437
|
|
4415
|
4438
|
void menu_action_sdfile(const char* filename, char* longFilename) {
|
4416
|
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
|
4441
|
#endif
|
4419
|
4442
|
UNUSED(longFilename);
|
4420
|
4443
|
card.openAndPrintFile(filename);
|
|
@@ -4722,16 +4745,18 @@ void lcd_update() {
|
4722
|
4745
|
// then we want to use 1/2 of the time only.
|
4723
|
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
|
4758
|
#endif
|
4730
|
|
- ))
|
4731
|
|
- #else
|
4732
|
|
- if (lcdDrawUpdate && (!bbr2 || (bbr2 > max_display_update_time)))
|
4733
|
|
- #endif
|
4734
|
|
- {
|
|
4759
|
+ ) {
|
4735
|
4760
|
#if ENABLED(DOGLCD)
|
4736
|
4761
|
if (!drawing_screen)
|
4737
|
4762
|
#endif
|