diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index de59e34a7..ba2fedde1 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/Max7219_Debug_LEDs.cpp b/Marlin/Max7219_Debug_LEDs.cpp index d6110053f..2eb8773fd 100644 --- a/Marlin/Max7219_Debug_LEDs.cpp +++ b/Marlin/Max7219_Debug_LEDs.cpp @@ -39,12 +39,14 @@ * void Max7219_init(); * void Max7219_PutByte(uint8_t data); * void Max7219(uint8_t reg, uint8_t data); - * void Max7219_LED_On(uint8_t row, uint8_t col); - * void Max7219_LED_Off(uint8_t row, uint8_t col); - * void Max7219_LED_Toggle(uint8_t row, uint8_t col); + * void Max7219_LED_On(uint8_t col, uint8_t row); + * void Max7219_LED_Off(uint8_t col, uint8_t row); + * void Max7219_LED_Toggle(uint8_t col, uint8_t row); * void Max7219_Clear_Row(uint8_t row); * void Max7219_Clear_Column(uint8_t col); * void Max7219_Set_Row(uint8_t row, uint8_t val); + * void Max7219_Set_2_Rows(uint8_t row, uint16_t val); + * void Max7219_Set_4_Rows(uint8_t row, uint32_t val); * void Max7219_Set_Column(uint8_t col, uint8_t val); * void Max7219_idle_tasks(); */ @@ -53,184 +55,340 @@ #if ENABLED(MAX7219_DEBUG) - #include "Marlin.h" - #include "planner.h" - #include "stepper.h" - #include "Max7219_Debug_LEDs.h" +#include "Max7219_Debug_LEDs.h" - static uint8_t LEDs[8] = { 0 }; +#include "planner.h" +#include "stepper.h" +#include "Marlin.h" - void Max7219_PutByte(uint8_t data) { - for (uint8_t i = 8; i--;) { +static uint8_t LEDs[8] = { 0 }; + +void Max7219_PutByte(uint8_t data) { + CRITICAL_SECTION_START + for (uint8_t i = 8; i--;) { + #ifdef CPU_32_BIT // The 32-bit processors are so fast, a small delay in the code is needed + delayMicroseconds(5); // to let the signal wires stabilize. + WRITE(MAX7219_CLK_PIN, LOW); // tick + delayMicroseconds(5); + WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit + delayMicroseconds(5); + WRITE(MAX7219_CLK_PIN, HIGH); // tock + delayMicroseconds(5); + #else WRITE(MAX7219_CLK_PIN, LOW); // tick WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit WRITE(MAX7219_CLK_PIN, HIGH); // tock - data <<= 1; - } - } + #endif - void Max7219(const uint8_t reg, const uint8_t data) { - WRITE(MAX7219_LOAD_PIN, LOW); // begin - Max7219_PutByte(reg); // specify register - Max7219_PutByte(data); // put data - WRITE(MAX7219_LOAD_PIN, LOW); // and tell the chip to load the data - WRITE(MAX7219_LOAD_PIN, HIGH); + data <<= 1; } + CRITICAL_SECTION_END +} - void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) { - if (row > 7 || col > 7) return; - if (TEST(LEDs[row], col) == on) return; // if LED is already on/off, leave alone - if (on) SBI(LEDs[row], col); else CBI(LEDs[row], col); - Max7219(8 - row, LEDs[row]); +void Max7219(const uint8_t reg, const uint8_t data) { + #ifdef CPU_32_BIT + delayMicroseconds(5); + #endif + CRITICAL_SECTION_START + WRITE(MAX7219_LOAD_PIN, LOW); // begin + #ifdef CPU_32_BIT // The 32-bit processors are so fast, a small delay in the code is needed + delayMicroseconds(5); // to let the signal wires stabilize. + #endif + Max7219_PutByte(reg); // specify register + #ifdef CPU_32_BIT + delayMicroseconds(5); + #endif + Max7219_PutByte(data); // put data + #ifdef CPU_32_BIT + delayMicroseconds(5); + #endif + WRITE(MAX7219_LOAD_PIN, LOW); // and tell the chip to load the data + #ifdef CPU_32_BIT + delayMicroseconds(5); + #endif + WRITE(MAX7219_LOAD_PIN, HIGH); + CRITICAL_SECTION_END + #ifdef CPU_32_BIT + delayMicroseconds(5); + #endif +} + +void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) { + if (row > 7 || col > 7) { + int r,c; + r = row; + c = col; + SERIAL_ECHOPAIR("??? Max7219_LED_Set(",r); + SERIAL_ECHOPAIR(",",c); + SERIAL_ECHO(")\n"); + return; } + if (TEST(LEDs[row], col) == on) return; // if LED is already on/off, leave alone + if (on) SBI(LEDs[row], col); else CBI(LEDs[row], col); + Max7219(8 - row, LEDs[row]); +} - void Max7219_LED_On(const uint8_t row, const uint8_t col) { - Max7219_LED_Set(row, col, true); +void Max7219_LED_On(const uint8_t col, const uint8_t row) { + if (row > 7 || col > 7) { + int r,c; + r = row; + c = col; + SERIAL_ECHOPAIR("??? Max7219_LED_On(",c); + SERIAL_ECHOPAIR(",",r); + SERIAL_ECHO(")\n"); + return; } + Max7219_LED_Set(col, row, true); +} - void Max7219_LED_Off(const uint8_t row, const uint8_t col) { - Max7219_LED_Set(row, col, false); +void Max7219_LED_Off(const uint8_t col, const uint8_t row) { + if (row > 7 || col > 7) { + int r,c; + r = row; + c = col; + SERIAL_ECHOPAIR("??? Max7219_LED_Off(",r); + SERIAL_ECHOPAIR(",",c); + SERIAL_ECHO(")\n"); + return; } + Max7219_LED_Set(col, row, false); +} - void Max7219_LED_Toggle(const uint8_t row, const uint8_t col) { - if (row > 7 || col > 7) return; - if (TEST(LEDs[row], col)) - Max7219_LED_Off(row, col); +void Max7219_LED_Toggle(const uint8_t col, const uint8_t row) { + if (row > 7 || col > 7) { + int r,c; + r = row; + c = col; + SERIAL_ECHOPAIR("??? Max7219_LED_Toggle(",r); + SERIAL_ECHOPAIR(",",c); + SERIAL_ECHO(")\n"); + return; + } + if (TEST(LEDs[row], col)) + Max7219_LED_Off(col, row); + else + Max7219_LED_On(col, row); +} + +void Max7219_Clear_Column(const uint8_t col) { + if (col > 7) { + int c; + c = col; + SERIAL_ECHOPAIR("??? Max7219_Clear_Column(",c); + SERIAL_ECHO(")\n"); + return; + } + LEDs[col] = 0; + Max7219(8 - col, LEDs[col]); +} + +void Max7219_Clear_Row(const uint8_t row) { + if (row > 7) { + int r; + r = row; + SERIAL_ECHOPAIR("??? Max7219_Clear_Row(",r); + SERIAL_ECHO(")\n"); + return; + } + for (uint8_t c = 0; c <= 7; c++) + Max7219_LED_Off(c, row); +} + +void Max7219_Set_Row(const uint8_t row, const uint8_t val) { + if (row > 7 || val>255) { + int r, v; + r = row; + v = val; + SERIAL_ECHOPAIR("??? Max7219_Set_Row(",r); + SERIAL_ECHOPAIR(",",v); + SERIAL_ECHO(")\n"); + return; + } + for (uint8_t b = 0; b <= 7; b++) + if (TEST(val, b)) + Max7219_LED_On(7 - b, row); else - Max7219_LED_On(row, col); + Max7219_LED_Off(7 - b, row); +} + +void Max7219_Set_2_Rows(const uint8_t row, const uint16_t val) { + if (row > 6 || val>65535) { + int r, v; + r = row; + v = val; + SERIAL_ECHOPAIR("??? Max7219_Set_2_Rows(",r); + SERIAL_ECHOPAIR(",",v); + SERIAL_ECHO(")\n"); + return; + } + Max7219_Set_Row(row+1, (val & 0xff00) >> 8 ); + Max7219_Set_Row(row+0, (val & 0xff)); +} + +void Max7219_Set_4_Rows(const uint8_t row, const uint32_t val) { + if (row > 4 ) { + int r; + long v; + r = row; + v = val; + SERIAL_ECHOPAIR("??? Max7219_Set_4_Rows(",r); + SERIAL_ECHOPAIR(",",v); + SERIAL_ECHO(")\n"); + return; + } + Max7219_Set_Row(row+3, (val & 0xff000000) >> 24); + Max7219_Set_Row(row+2, (val & 0xff0000) >> 16); + Max7219_Set_Row(row+1, (val & 0xff00) >> 8); + Max7219_Set_Row(row+0, (val & 0xff)); +} + +void Max7219_Set_Column(const uint8_t col, const uint8_t val) { + if (val > 255 || col > 7) { + int v,c; + v = val; + c = col; + SERIAL_ECHOPAIR("??? Max7219_Column(",c); + SERIAL_ECHOPAIR(",",v); + SERIAL_ECHO(")\n"); + return; + } + LEDs[col] = val; + Max7219(8 - col, LEDs[col]); +} + +void Max7219_init() { + uint8_t i, x, y; + + SET_OUTPUT(MAX7219_DIN_PIN); + SET_OUTPUT(MAX7219_CLK_PIN); + + OUT_WRITE(MAX7219_LOAD_PIN, HIGH); + delay(1); + + //initiation of the max 7219 + Max7219(max7219_reg_scanLimit, 0x07); + Max7219(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits) + Max7219(max7219_reg_shutdown, 0x01); // not in shutdown mode + Max7219(max7219_reg_displayTest, 0x00); // no display test + Max7219(max7219_reg_intensity, 0x01 & 0x0F); // the first 0x0F is the value you can set + // range: 0x00 to 0x0F + for (i = 0; i <= 7; i++) { // empty registers, turn all LEDs off + LEDs[i] = 0x00; + Max7219(i + 1, 0); } - void Max7219_Clear_Column(const uint8_t col) { - if (col > 7) return; - LEDs[col] = 0; - Max7219(8 - col, LEDs[col]); - } - - void Max7219_Clear_Row(const uint8_t row) { - if (row > 7) return; - for (uint8_t c = 0; c <= 7; c++) - Max7219_LED_Off(c, row); - } - - void Max7219_Set_Row(const uint8_t row, const uint8_t val) { - if (row > 7) return; - for (uint8_t b = 0; b <= 7; b++) - if (TEST(val, b)) - Max7219_LED_On(7 - b, row); - else - Max7219_LED_Off(7 - b, row); - } - - void Max7219_Set_Column(const uint8_t col, const uint8_t val) { - if (col > 7) return; - LEDs[col] = val; - Max7219(8 - col, LEDs[col]); - } - - void Max7219_init() { - uint8_t i, x, y; - - SET_OUTPUT(MAX7219_DIN_PIN); - SET_OUTPUT(MAX7219_CLK_PIN); - - OUT_WRITE(MAX7219_LOAD_PIN, HIGH); - - //initiation of the max 7219 - Max7219(max7219_reg_scanLimit, 0x07); - Max7219(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits) - Max7219(max7219_reg_shutdown, 0x01); // not in shutdown mode - Max7219(max7219_reg_displayTest, 0x00); // no display test - Max7219(max7219_reg_intensity, 0x01 & 0x0F); // the first 0x0F is the value you can set - // range: 0x00 to 0x0F - for (i = 0; i <= 7; i++) { // empty registers, turn all LEDs off - LEDs[i] = 0x00; - Max7219(i + 1, 0); + for (x = 0; x <= 7; x++) // Do an aesthetically pleasing pattern to fully test + for (y = 0; y <= 7; y++) { // the Max7219 module and LEDs. First, turn them + Max7219_LED_On(x, y); // all on. + delay(3); } - for (x = 0; x <= 7; x++) // Do an aesthetically pleasing pattern to fully test - for (y = 0; y <= 7; y++) { // the Max7219 module and LEDs. First, turn them - Max7219_LED_On(x, y); // all on. - delay(3); - } + for (x = 0; x <= 7; x++) // Now, turn them all off. + for (y = 0; y <= 7; y++) { + Max7219_LED_Off(x, y); + delay(3); // delay() is OK here. Max7219_init() is only called from + } // setup() and nothing is running yet. - for (x = 0; x <= 7; x++) // Now, turn them all off. - for (y = 0; y <= 7; y++) { - Max7219_LED_Off(x, y); - delay(3); // delay() is OK here. Max7219_init() is only called from - } // setup() and nothing is running yet. + delay(150); - delay(150); + for (x = 8; x--;) // Now, do the same thing from the opposite direction + for (y = 0; y <= 7; y++) { + Max7219_LED_On(x, y); + delay(2); + } - for (x = 8; x--;) // Now, do the same thing from the opposite direction - for (y = 0; y <= 7; y++) { - Max7219_LED_On(x, y); - delay(2); - } - - for (x = 8; x--;) - for (y = 0; y <= 7; y++) { - Max7219_LED_Off(x, y); - delay(2); - } - } + for (x = 8; x--;) + for (y = 0; y <= 7; y++) { + Max7219_LED_Off(x, y); + delay(2); + } +} /** - * These are sample debug features to demonstrate the usage of the 8x8 LED Matrix for debug purposes. - * There is very little CPU burden added to the system by displaying information within the idle() - * task. - * - * But with that said, if your debugging can be facilitated by making calls into the library from - * other places in the code, feel free to do it. The CPU burden for a few calls to toggle an LED - * or clear a row is not very significant. - */ - void Max7219_idle_tasks() { - #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE) - static int debug_cnt = 0; - if (debug_cnt++ > 100) { +* These are sample debug features to demonstrate the usage of the 8x8 LED Matrix for debug purposes. +* There is very little CPU burden added to the system by displaying information within the idle() +* task. +* +* But with that said, if your debugging can be facilitated by making calls into the library from +* other places in the code, feel free to do it. The CPU burden for a few calls to toggle an LED +* or clear a row is not very significant. +*/ +void Max7219_idle_tasks() { +#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE + CRITICAL_SECTION_START + #if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_QUEUE + uint8_t head; + head = planner.block_buffer_head; + #endif + #if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE + uint8_t tail; + tail = planner.block_buffer_tail; + #endif + CRITICAL_SECTION_END +#endif + + #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE) + static millis_t next_blink = 0; + + if (ELAPSED(millis(), next_blink)) { Max7219_LED_Toggle(7, 7); - debug_cnt = 0; - } - #endif + next_blink = millis() + 750; + } + #endif - #ifdef MAX7219_DEBUG_STEPPER_HEAD - Max7219_Clear_Row(MAX7219_DEBUG_STEPPER_HEAD); - Max7219_Clear_Row(MAX7219_DEBUG_STEPPER_HEAD + 1); - if ( planner.block_buffer_head < 8) - Max7219_LED_On( planner.block_buffer_head, MAX7219_DEBUG_STEPPER_HEAD); + #ifdef MAX7219_DEBUG_STEPPER_HEAD + static int16_t last_head_cnt=0; + if (last_head_cnt != head) { + if ( last_head_cnt < 8) + Max7219_LED_Off( last_head_cnt, MAX7219_DEBUG_STEPPER_HEAD); else - Max7219_LED_On( planner.block_buffer_head-8, MAX7219_DEBUG_STEPPER_HEAD+1); - #endif + Max7219_LED_Off( last_head_cnt-8, MAX7219_DEBUG_STEPPER_HEAD+1); - #ifdef MAX7219_DEBUG_STEPPER_TAIL - Max7219_Clear_Row(MAX7219_DEBUG_STEPPER_TAIL); - Max7219_Clear_Row(MAX7219_DEBUG_STEPPER_TAIL + 1); - if ( planner.block_buffer_tail < 8) - Max7219_LED_On( planner.block_buffer_tail, MAX7219_DEBUG_STEPPER_TAIL ); + last_head_cnt = head; + if ( head < 8) + Max7219_LED_On(head, MAX7219_DEBUG_STEPPER_HEAD); else - Max7219_LED_On( planner.block_buffer_tail-8, MAX7219_DEBUG_STEPPER_TAIL+1 ); - #endif + Max7219_LED_On(head-8, MAX7219_DEBUG_STEPPER_HEAD+1); + } + #endif - #ifdef MAX7219_DEBUG_STEPPER_QUEUE - static int16_t last_depth = 0; - int16_t current_depth = planner.block_buffer_head - planner.block_buffer_tail; - if (current_depth != last_depth) { // usually, no update will be needed. - if (current_depth < 0) current_depth += BLOCK_BUFFER_SIZE; - NOMORE(current_depth, BLOCK_BUFFER_SIZE); - NOMORE(current_depth, 16); // if the BLOCK_BUFFER_SIZE is greater than 16, two lines - // of LEDs is enough to see if the buffer is draining + #ifdef MAX7219_DEBUG_STEPPER_TAIL + static int16_t last_tail_cnt=0; + if (last_tail_cnt != tail) { + if ( last_tail_cnt < 8) + Max7219_LED_Off( last_tail_cnt, MAX7219_DEBUG_STEPPER_TAIL); + else + Max7219_LED_Off( last_tail_cnt-8, MAX7219_DEBUG_STEPPER_TAIL+1); - const uint8_t st = min(current_depth, last_depth), - en = max(current_depth, last_depth); - if (current_depth < last_depth) - for (uint8_t i = st; i <= en; i++) // clear the highest order LEDs - Max7219_LED_Off(i >> 1, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1)); - else - for (uint8_t i = st; i <= en; i++) // set the highest order LEDs - Max7219_LED_On(i >> 1, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1)); + last_tail_cnt = tail; + if ( tail < 8) + Max7219_LED_On(tail, MAX7219_DEBUG_STEPPER_TAIL); + else + Max7219_LED_On(tail-8, MAX7219_DEBUG_STEPPER_TAIL+1); + } + #endif - last_depth = current_depth; - } - #endif - } + #ifdef MAX7219_DEBUG_STEPPER_QUEUE + static int16_t last_depth = 0; + int16_t current_depth = head - tail; + if (current_depth != last_depth) { // usually, no update will be needed. + if (current_depth < 0) current_depth += BLOCK_BUFFER_SIZE; + NOMORE(current_depth, BLOCK_BUFFER_SIZE); + NOMORE(current_depth, 16); // if the BLOCK_BUFFER_SIZE is greater than 16, two lines + // of LEDs is enough to see if the buffer is draining + + const uint8_t st = min(current_depth, last_depth), + en = max(current_depth, last_depth); + if (current_depth < last_depth) + for (uint8_t i = st; i <= en; i++) // clear the highest order LEDs + Max7219_LED_Off(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1)); + else + for (uint8_t i = st; i <= en; i++) // set the LEDs to current depth + Max7219_LED_On(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1)); + + last_depth = current_depth; + } + #endif +} #endif // MAX7219_DEBUG diff --git a/Marlin/Max7219_Debug_LEDs.h b/Marlin/Max7219_Debug_LEDs.h index 71a5124e3..3beccb0ea 100644 --- a/Marlin/Max7219_Debug_LEDs.h +++ b/Marlin/Max7219_Debug_LEDs.h @@ -40,12 +40,14 @@ * void Max7219_PutByte(uint8_t data); * void Max7219(uint8_t reg, uint8_t data); * void Max7219_LED_Set(uint8_t row, uint8_t col, bool on); - * void Max7219_LED_On(uint8_t row, uint8_t col); - * void Max7219_LED_Off(uint8_t row, uint8_t col); + * void Max7219_LED_On(uint8_t col, uint8_t row); + * void Max7219_LED_Off(uint8_t col, uint8_t row); * void Max7219_LED_Toggle(uint8_t row, uint8_t col); * void Max7219_Clear_Row(uint8_t row); * void Max7219_Clear_Column(uint8_t col); * void Max7219_Set_Row(uint8_t row, uint8_t val); + * void Max7219_Set_2_Rows(uint8_t row, uint16_t val); + * void Max7219_Set_4_Rows(uint8_t row, uint32_t val); * void Max7219_Set_Column(uint8_t col, uint8_t val); * void Max7219_idle_tasks(); */ @@ -53,36 +55,36 @@ #ifndef __MAX7219_DEBUG_LEDS_H__ #define __MAX7219_DEBUG_LEDS_H__ - // - // define max7219 registers - // - #define max7219_reg_noop 0x00 - #define max7219_reg_digit0 0x01 - #define max7219_reg_digit1 0x02 - #define max7219_reg_digit2 0x03 - #define max7219_reg_digit3 0x04 - #define max7219_reg_digit4 0x05 - #define max7219_reg_digit5 0x06 - #define max7219_reg_digit6 0x07 - #define max7219_reg_digit7 0x08 +// +// define max7219 registers +// +#define max7219_reg_noop 0x00 +#define max7219_reg_digit0 0x01 +#define max7219_reg_digit1 0x02 +#define max7219_reg_digit2 0x03 +#define max7219_reg_digit3 0x04 +#define max7219_reg_digit4 0x05 +#define max7219_reg_digit5 0x06 +#define max7219_reg_digit6 0x07 +#define max7219_reg_digit7 0x08 - #define max7219_reg_intensity 0x0A - #define max7219_reg_displayTest 0x0F - #define max7219_reg_decodeMode 0x09 - #define max7219_reg_scanLimit 0x0B - #define max7219_reg_shutdown 0x0C +#define max7219_reg_intensity 0x0A +#define max7219_reg_displayTest 0x0F +#define max7219_reg_decodeMode 0x09 +#define max7219_reg_scanLimit 0x0B +#define max7219_reg_shutdown 0x0C - void Max7219_init(); - void Max7219_PutByte(uint8_t data); - void Max7219(const uint8_t reg, const uint8_t data); - void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on); - void Max7219_LED_On(const uint8_t row, const uint8_t col); - void Max7219_LED_Off(const uint8_t row, const uint8_t col); - void Max7219_LED_Toggle(const uint8_t row, const uint8_t col); - void Max7219_Clear_Row(const uint8_t row); - void Max7219_Clear_Column(const uint8_t col); - void Max7219_Set_Row(const uint8_t row, const uint8_t val); - void Max7219_Set_Column(const uint8_t col, const uint8_t val); - void Max7219_idle_tasks(); +void Max7219_init(); +void Max7219_PutByte(uint8_t data); +void Max7219(const uint8_t reg, const uint8_t data); +void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on); +void Max7219_LED_On(const uint8_t row, const uint8_t col); +void Max7219_LED_Off(const uint8_t row, const uint8_t col); +void Max7219_LED_Toggle(const uint8_t row, const uint8_t col); +void Max7219_Clear_Row(const uint8_t row); +void Max7219_Clear_Column(const uint8_t col); +void Max7219_Set_Row(const uint8_t row, const uint8_t val); +void Max7219_Set_Column(const uint8_t col, const uint8_t val); +void Max7219_idle_tasks(); #endif // __MAX7219_DEBUG_LEDS_H__ diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 89147d97b..7e5f93e36 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -860,6 +860,15 @@ void CardReader::updir() { #endif // SDCARD_SORT_ALPHA +#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) + typedef void (*screenFunc_t)(); + extern void lcd_sdcard_menu(); + extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0); + extern uint32_t saved_encoderPosition; + extern bool screen_changed, drawing_screen, defer_return_to_status; + void _lcd_synchronize(); // Not declared in any LCD header file. Probably, that should be changed. +#endif + void CardReader::printingHasFinished() { stepper.synchronize(); file.close(); @@ -879,6 +888,18 @@ void CardReader::printingHasFinished() { #if ENABLED(SDCARD_SORT_ALPHA) presort(); #endif + + #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; + _lcd_synchronize(); + safe_delay(50); + _lcd_synchronize(); + lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; + drawing_screen = screen_changed = true; + lcd_goto_screen(lcd_sdcard_menu, saved_encoderPosition); + defer_return_to_status = true; + lcd_update(); + #endif } } diff --git a/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h b/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h index 3db33f142..59034b6cf 100644 --- a/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Anet/A6/Configuration_adv.h b/Marlin/example_configurations/Anet/A6/Configuration_adv.h index e627be39f..3dce38be0 100644 --- a/Marlin/example_configurations/Anet/A6/Configuration_adv.h +++ b/Marlin/example_configurations/Anet/A6/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Anet/A8/Configuration_adv.h b/Marlin/example_configurations/Anet/A8/Configuration_adv.h index f366e7f3d..bf2c3f54e 100644 --- a/Marlin/example_configurations/Anet/A8/Configuration_adv.h +++ b/Marlin/example_configurations/Anet/A8/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h b/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h index b3bcd8d59..827854065 100644 --- a/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/BQ/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/BQ/Hephestos_2/Configuration_adv.h index af14b5d7b..952181514 100644 --- a/Marlin/example_configurations/BQ/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/BQ/Hephestos_2/Configuration_adv.h @@ -545,11 +545,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h b/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h index b3bcd8d59..827854065 100644 --- a/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 1350274cc..318d6d2cc 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h b/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h index cb8f69205..a28ee2c10 100755 --- a/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h +++ b/Marlin/example_configurations/Creality/CR-10/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 473d6b31b..baa0e8f45 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Folger Tech/i3-2020/Configuration.h b/Marlin/example_configurations/FolgerTech/i3-2020/Configuration.h similarity index 100% rename from Marlin/example_configurations/Folger Tech/i3-2020/Configuration.h rename to Marlin/example_configurations/FolgerTech/i3-2020/Configuration.h diff --git a/Marlin/example_configurations/Folger Tech/i3-2020/Configuration_adv.h b/Marlin/example_configurations/FolgerTech/i3-2020/Configuration_adv.h similarity index 98% rename from Marlin/example_configurations/Folger Tech/i3-2020/Configuration_adv.h rename to Marlin/example_configurations/FolgerTech/i3-2020/Configuration_adv.h index a86b4b7b5..aae5f2d0c 100644 --- a/Marlin/example_configurations/Folger Tech/i3-2020/Configuration_adv.h +++ b/Marlin/example_configurations/FolgerTech/i3-2020/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h b/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h index c0da4ae3d..ba1911e48 100644 --- a/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h +++ b/Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Malyan/M150/Configuration_adv.h b/Marlin/example_configurations/Malyan/M150/Configuration_adv.h index 67069d68e..f6df3eba4 100644 --- a/Marlin/example_configurations/Malyan/M150/Configuration_adv.h +++ b/Marlin/example_configurations/Malyan/M150/Configuration_adv.h @@ -545,11 +545,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Micromake/C1/enhanced/Configuration_adv.h b/Marlin/example_configurations/Micromake/C1/enhanced/Configuration_adv.h index f76bb1929..80b0eac8c 100644 --- a/Marlin/example_configurations/Micromake/C1/enhanced/Configuration_adv.h +++ b/Marlin/example_configurations/Micromake/C1/enhanced/Configuration_adv.h @@ -549,11 +549,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index b9d74506e..be1a798ae 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 29182135e..4754cd7d9 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Sanguinololu/Configuration_adv.h b/Marlin/example_configurations/Sanguinololu/Configuration_adv.h index 972e943b8..9b20855c1 100644 --- a/Marlin/example_configurations/Sanguinololu/Configuration_adv.h +++ b/Marlin/example_configurations/Sanguinololu/Configuration_adv.h @@ -537,11 +537,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h index 3d76835cf..43692a67a 100644 --- a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h +++ b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Velleman/K8200/Configuration_adv.h b/Marlin/example_configurations/Velleman/K8200/Configuration_adv.h index 8e79c96ff..35f414677 100644 --- a/Marlin/example_configurations/Velleman/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/Velleman/K8200/Configuration_adv.h @@ -556,11 +556,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h b/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h index c0aa1dcab..b09abfcd3 100644 --- a/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/Velleman/K8400/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h index df790f785..4c87c1f7c 100644 --- a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h @@ -550,11 +550,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h index 7c03d45a4..f3f818de6 100644 --- a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h @@ -550,11 +550,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 7c03d45a4..f3f818de6 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -550,11 +550,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 7c03d45a4..f3f818de6 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -550,11 +550,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index 3c25d3f3d..63bdb6063 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -555,11 +555,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index cfb5017c2..a1fab153c 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -550,11 +550,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h b/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h index 794ea0b22..ff1b945dd 100644 --- a/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h +++ b/Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 102f29339..845e4230b 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index a33b57da7..b4840a707 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/example_configurations/wt150/Configuration_adv.h b/Marlin/example_configurations/wt150/Configuration_adv.h index 67fd9dd30..c82c79acc 100644 --- a/Marlin/example_configurations/wt150/Configuration_adv.h +++ b/Marlin/example_configurations/wt150/Configuration_adv.h @@ -548,11 +548,22 @@ // Enable this option to scroll long filenames in the SD card menu //#define SCROLL_LONG_FILENAMES - // This option allows you to abort SD printing when any endstop is triggered. - // This feature must be enabled with "M540 S1" or from the LCD menu. - // To have any effect, endstops must be enabled during SD printing. + /** + * This option allows you to abort SD printing when any endstop is triggered. + * This feature must be enabled with "M540 S1" or from the LCD menu. + * To have any effect, endstops must be enabled during SD printing. + */ //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + /** + * This option allows you to easily reprint the same SD Card file as + * was last printed. At the end of a print, the LCD Menu will jump + * straight to the file previously selected. A single click of the encoder + * wheel will restart the print. Another file or LCD option can be + * selected by using the encoder wheel to navigate through the menu structure. + */ + //#define SD_REPRINT_LAST_SELECTED_FILE + #endif // SDSUPPORT /** diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 6653d312d..eebd522b9 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -3752,9 +3752,24 @@ void kill_screen(const char* lcd_msg) { * "Print from SD" submenu * */ + #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) + uint32_t saved_encoderPosition = 0; + static millis_t assume_print_finished = 0; + #endif + void lcd_sdcard_menu() { ENCODER_DIRECTION_MENUS(); - if (!lcdDrawUpdate && !lcd_clicked) return; // nothing to do (so don't thrash the SD card) + + #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) + if (ELAPSED(millis(), assume_print_finished)) { // if the printer has been busy printing, lcd_sdcard_menu() should not + lcdDrawUpdate = LCDVIEW_REDRAW_NOW; // have been active for 5 seconds. In this case, restore the previous + encoderPosition = saved_encoderPosition; // encoderPosition to the last selected item. + assume_print_finished = millis() + 5000; + } + saved_encoderPosition = encoderPosition; + defer_return_to_status = true; + #endif + const uint16_t fileCnt = card.getnrfilenames(); START_MENU(); MENU_BACK(MSG_MAIN); @@ -4403,6 +4418,9 @@ void kill_screen(const char* lcd_msg) { #if ENABLED(SDSUPPORT) void menu_action_sdfile(const char* filename, char* longFilename) { + #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) + saved_encoderPosition = encoderPosition; // Save which file was selected for later use + #endif UNUSED(longFilename); card.openAndPrintFile(filename); lcd_return_to_status(); @@ -4710,7 +4728,11 @@ void lcd_update() { uint16_t bbr2 = planner.block_buffer_runtime() >> 1; #if ENABLED(DOGLCD) - if ((lcdDrawUpdate || drawing_screen) && (!bbr2 || (bbr2 > max_display_update_time))) + if ((lcdDrawUpdate || drawing_screen) && (!bbr2 || (bbr2 > max_display_update_time) + #if ENABLED(SDSUPPORT) + || (currentScreen == lcd_sdcard_menu) + #endif + )) #else if (lcdDrawUpdate && (!bbr2 || (bbr2 > max_display_update_time))) #endif @@ -4764,7 +4786,12 @@ void lcd_update() { // Return to Status Screen after a timeout if (currentScreen == lcd_status_screen || defer_return_to_status) + #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) + if (currentScreen != lcd_sdcard_menu) // lcd_sdcard_menu() does not time out if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) + return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; // When the printer finishes a file, it will wait with the file selected for + #else // a re-print. return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; + #endif else if (ELAPSED(ms, return_to_status_ms)) lcd_return_to_status();