From 5d8eb84965f94c4e0e653dbaabdcb3bcd6f338af Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Thu, 6 Jun 2019 14:24:34 +0200 Subject: [PATCH 01/12] M0/M1/M117 fix: Move M0/M1 to the top of decoder. Move M0/M1 decoding before any other command. The M0/M1 message can contain arbitrary characters and so it also can contain substrings that other decoders trigger on, like the letter 'G'. Any such substring would cause misdecoding of the M0/M1 and unpredictable behavior in addition to not making the printer stop. M117 already received the same treatment in the past, so we take the same approach for M0/M1. --- Firmware/Marlin_main.cpp | 93 ++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f75b141ff..314514f0a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3432,6 +3432,52 @@ void process_commands() lcd_setstatus(strchr_pointer + 5); } + else if (code_seen("M0 ") || code_seen("M1 ")) { // M0 and M1 - (Un)conditional stop - Wait for user buttn press on LCD + + char *src = strchr_pointer + 2; + + codenum = 0; + + bool hasP = false, hasS = false; + if (code_seen('P')) { + codenum = code_value(); // milliseconds to wait + hasP = codenum > 0; + } + if (code_seen('S')) { + codenum = code_value() * 1000; // seconds to wait + hasS = codenum > 0; + } + starpos = strchr(src, '*'); + if (starpos != NULL) *(starpos) = '\0'; + while (*src == ' ') ++src; + if (!hasP && !hasS && *src != '\0') { + lcd_setstatus(src); + } else { + LCD_MESSAGERPGM(_i("Wait for user..."));////MSG_USERWAIT + } + + lcd_ignore_click(); //call lcd_ignore_click aslo for else ??? + st_synchronize(); + previous_millis_cmd = _millis(); + if (codenum > 0){ + codenum += _millis(); // keep track of when we started waiting + KEEPALIVE_STATE(PAUSED_FOR_USER); + while(_millis() < codenum && !lcd_clicked()){ + manage_heater(); + manage_inactivity(true); + lcd_update(0); + } + KEEPALIVE_STATE(IN_HANDLER); + lcd_ignore_click(false); + }else{ + marlin_wait_for_click(); + } + if (IS_SD_PRINTING) + LCD_MESSAGERPGM(_T(MSG_RESUMING_PRINT)); + else + LCD_MESSAGERPGM(_T(WELCOME_MSG)); + } + #ifdef TMC2130 else if (strncmp_P(CMDBUFFER_CURRENT_STRING, PSTR("CRASH_"), 6) == 0) { @@ -4968,53 +5014,6 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) switch(mcode_in_progress) { - case 0: // M0 - Unconditional stop - Wait for user button press on LCD - case 1: // M1 - Conditional stop - Wait for user button press on LCD - { - char *src = strchr_pointer + 2; - - codenum = 0; - - bool hasP = false, hasS = false; - if (code_seen('P')) { - codenum = code_value(); // milliseconds to wait - hasP = codenum > 0; - } - if (code_seen('S')) { - codenum = code_value() * 1000; // seconds to wait - hasS = codenum > 0; - } - starpos = strchr(src, '*'); - if (starpos != NULL) *(starpos) = '\0'; - while (*src == ' ') ++src; - if (!hasP && !hasS && *src != '\0') { - lcd_setstatus(src); - } else { - LCD_MESSAGERPGM(_i("Wait for user..."));////MSG_USERWAIT - } - - lcd_ignore_click(); //call lcd_ignore_click aslo for else ??? - st_synchronize(); - previous_millis_cmd = _millis(); - if (codenum > 0){ - codenum += _millis(); // keep track of when we started waiting - KEEPALIVE_STATE(PAUSED_FOR_USER); - while(_millis() < codenum && !lcd_clicked()){ - manage_heater(); - manage_inactivity(true); - lcd_update(0); - } - KEEPALIVE_STATE(IN_HANDLER); - lcd_ignore_click(false); - }else{ - marlin_wait_for_click(); - } - if (IS_SD_PRINTING) - LCD_MESSAGERPGM(_T(MSG_RESUMING_PRINT)); - else - LCD_MESSAGERPGM(_T(WELCOME_MSG)); - } - break; case 17: LCD_MESSAGERPGM(_i("No move."));////MSG_NO_MOVE enable_x(); From 5494f2394286a9b177a09da02e5957e3efdf8b8a Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Thu, 6 Jun 2019 14:25:06 +0200 Subject: [PATCH 02/12] M0/M1/M117 fix: Add new CUSTOM_MSG states. When the printer prints from a SD card, the display of progress messages and filename takes precedence over CUSTOM_MSG_TYPE_STATUS messages used by M0/M1/M117. Let's introduce two new CUSTOM_MSG states, one that overrides the SD status while waiting in M0/M1 (M0WAIT) and one that ensures the message will be displayed in at least one screen update (MSGUPD). --- Firmware/ultralcd.cpp | 3 +++ Firmware/ultralcd.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 3b2be088a..5d23acf64 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -794,7 +794,10 @@ void lcdui_print_status_line(void) { // Otherwise check for other special events switch (custom_message_type) { + case CUSTOM_MSG_TYPE_MSGUPD: + custom_message_type = CUSTOM_MSG_TYPE_STATUS; case CUSTOM_MSG_TYPE_STATUS: // Nothing special, print status message normally + case CUSTOM_MSG_TYPE_M0WAIT: lcd_print(lcd_status_message); break; case CUSTOM_MSG_TYPE_MESHBL: // If mesh bed leveling in progress, show the status diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 665c1233f..27b1c23ae 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -106,6 +106,8 @@ extern int8_t FSensorStateMenu; #define CUSTOM_MSG_TYPE_PIDCAL 3 // PID tuning in progress #define CUSTOM_MSG_TYPE_TEMCAL 4 // PINDA temp calibration #define CUSTOM_MSG_TYPE_TEMPRE 5 // Temp compensation preheat +#define CUSTOM_MSG_TYPE_M0WAIT 6 // M0/M1 Wait command working even from SD +#define CUSTOM_MSG_TYPE_MSGUPD 7 // Short message even while printing from SD extern unsigned int custom_message_type; extern unsigned int custom_message_state; From a4bc91ed2f1c8b79ca5e0cd6d629898d945fbd39 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Thu, 6 Jun 2019 14:25:36 +0200 Subject: [PATCH 03/12] M0/M1/M117 fix: Use CUSTOM_MSG states in M0/1/M117 Now that we have the new CUSTOM_MSG states, we can use them in the M0/M1 and M117 handlers to force the user message to be displayed even when the printer is printing from a SD card and displaying a file name. --- Firmware/Marlin_main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 314514f0a..586bdbe97 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3430,6 +3430,7 @@ void process_commands() if (starpos != NULL) *(starpos) = '\0'; lcd_setstatus(strchr_pointer + 5); + custom_message_type = CUSTOM_MSG_TYPE_MSGUPD; } else if (code_seen("M0 ") || code_seen("M1 ")) { // M0 and M1 - (Un)conditional stop - Wait for user buttn press on LCD @@ -3450,6 +3451,7 @@ void process_commands() starpos = strchr(src, '*'); if (starpos != NULL) *(starpos) = '\0'; while (*src == ' ') ++src; + custom_message_type = CUSTOM_MSG_TYPE_M0WAIT; if (!hasP && !hasS && *src != '\0') { lcd_setstatus(src); } else { @@ -3476,6 +3478,7 @@ void process_commands() LCD_MESSAGERPGM(_T(MSG_RESUMING_PRINT)); else LCD_MESSAGERPGM(_T(WELCOME_MSG)); + custom_message_type = CUSTOM_MSG_TYPE_MSGUPD; } #ifdef TMC2130 From 3668cdeb30eb95fb02f894decae2e1a95e399784 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Mon, 8 Feb 2021 17:27:32 +0100 Subject: [PATCH 04/12] Add Service prep. item into Factory reset upon request from our Service dept. - it is to do the same stuff like Shipping prep., but keep the printer's stats intact. Still, this has to be verified and may undergo some further changes. --- Firmware/Marlin_main.cpp | 191 +++++++++++++++++---------------------- Firmware/ultralcd.cpp | 6 +- 2 files changed, 84 insertions(+), 113 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6db1d2770..db3391244 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -711,124 +711,98 @@ void softReset() #endif +static void factory_reset_stats(){ + eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); + eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); + + eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0); + eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); + eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); + eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); + + eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); + + eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); + eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); + eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); +} + // Factory reset function // This function is used to erase parts or whole EEPROM memory which is used for storing calibration and and so on. // Level input parameter sets depth of reset -int er_progress = 0; static void factory_reset(char level) -{ +{ lcd_clear(); - switch (level) { - - // Level 0: Language reset - case 0: - Sound_MakeCustom(100,0,false); - lang_reset(); - break; - - //Level 1: Reset statistics - case 1: - Sound_MakeCustom(100,0,false); - eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); - eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); + Sound_MakeCustom(100,0,false); + switch (level) { - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0); - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); - eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); - eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); + case 0: // Level 0: Language reset + lang_reset(); + break; - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); + case 1: //Level 1: Reset statistics + factory_reset_stats(); + lcd_menu_statistics(); + break; - eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + case 2: // Level 2: Prepare for shipping + factory_reset_stats(); + // [[fallthrough]] // there is no break intentionally - - lcd_menu_statistics(); - - break; - - // Level 2: Prepare for shipping - case 2: - //lcd_puts_P(PSTR("Factory RESET")); - //lcd_puts_at_P(1,2,PSTR("Shipping prep")); - - // Force language selection at the next boot up. - lang_reset(); - // Force the "Follow calibration flow" message at the next boot up. - calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION); - eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard - farm_mode = false; - eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode); - - eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0); - eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); - - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0); - eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0); - eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0); - eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); - - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0); - - eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); - eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); - eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + case 4: // Level 4: Preparation after being serviced + // Force language selection at the next boot up. + lang_reset(); + // Force the "Follow calibration flow" message at the next boot up. + calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION); + eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard + farm_mode = false; + eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode); #ifdef FILAMENT_SENSOR - fsensor_enable(); - fsensor_autoload_set(true); + fsensor_enable(); + fsensor_autoload_set(true); #endif //FILAMENT_SENSOR - Sound_MakeCustom(100,0,false); - //_delay_ms(2000); - break; + break; - // Level 3: erase everything, whole EEPROM will be set to 0xFF + case 3:{ // Level 3: erase everything, whole EEPROM will be set to 0xFF + lcd_puts_P(PSTR("Factory RESET")); + lcd_puts_at_P(1, 2, PSTR("ERASING all data")); + uint16_t er_progress = 0; + lcd_set_cursor(3, 3); + lcd_space(6); + lcd_set_cursor(3, 3); + lcd_print(er_progress); - case 3: - lcd_puts_P(PSTR("Factory RESET")); - lcd_puts_at_P(1, 2, PSTR("ERASING all data")); - - Sound_MakeCustom(100,0,false); - er_progress = 0; - lcd_puts_at_P(3, 3, PSTR(" ")); - lcd_set_cursor(3, 3); - lcd_print(er_progress); - - // Erase EEPROM - for (int i = 0; i < 4096; i++) { - eeprom_update_byte((uint8_t*)i, 0xFF); - - if (i % 41 == 0) { - er_progress++; - lcd_puts_at_P(3, 3, PSTR(" ")); - lcd_set_cursor(3, 3); - lcd_print(er_progress); - lcd_puts_P(PSTR("%")); - } + // Erase EEPROM + for (uint16_t i = 0; i < 4096; i++) { + eeprom_update_byte((uint8_t*)i, 0xFF); + if (i % 41 == 0) { + er_progress++; + lcd_set_cursor(3, 3); + lcd_space(6); + lcd_set_cursor(3, 3); + lcd_print(er_progress); + lcd_puts_P(PSTR("%")); } - softReset(); + + } + softReset(); + }break; - break; - case 4: - bowden_menu(); - break; - - default: - break; - } - - +#ifdef SNMM + case 5: + bowden_menu(); + break; +#endif + default: + break; + } } extern "C" { @@ -859,30 +833,27 @@ void factory_reset() { lcd_clear(); - lcd_puts_P(PSTR("Factory RESET")); - SET_OUTPUT(BEEPER); - if(eSoundMode!=e_SOUND_MODE_SILENT) - WRITE(BEEPER, HIGH); + if(eSoundMode!=e_SOUND_MODE_SILENT) + WRITE(BEEPER, HIGH); while (!READ(BTN_ENC)); WRITE(BEEPER, LOW); - - _delay_ms(2000); char level = reset_menu(); factory_reset(level); switch (level) { - case 0: _delay_ms(0); break; - case 1: _delay_ms(0); break; - case 2: _delay_ms(0); break; - case 3: _delay_ms(0); break; + case 0: + case 1: + case 2: + case 3: + case 4: _delay_ms(0); break; } } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d3686509a..96e494abc 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6087,15 +6087,15 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite char reset_menu() { const uint8_t items_no = #ifdef SNMM - 5; + 6; #else - 4; + 5; #endif static int8_t first = 0; int8_t enc_dif = 0; char cursor_pos = 0; - const char *const item[items_no] PROGMEM = {PSTR("Language"), PSTR("Statistics"), PSTR("Shipping prep"), PSTR("All Data") + const char *const item[items_no] PROGMEM = {PSTR("Language"), PSTR("Statistics"), PSTR("Shipping prep"), PSTR("All Data"), PSTR("Service prep") #ifdef SNMM , PSTR("Bowden length") #endif From fc270a356a4ee430656b0db12cf909a196db7839 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 15 Feb 2021 12:50:40 +0100 Subject: [PATCH 05/12] Fix indentations --- Firmware/ultralcd.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 016acd616..a99e11301 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -114,14 +114,14 @@ extern int8_t FSensorStateMenu; enum class CustomMsg : uint_least8_t { - Status, //!< status message from lcd_status_message variable - MeshBedLeveling, //!< Mesh bed leveling in progress - FilamentLoading, //!< Loading filament in progress - PidCal, //!< PID tuning in progress - TempCal, //!< PINDA temperature calibration - TempCompPreheat, //!< Temperature compensation preheat - M0Wait, //!< M0/M1 Wait command working even from SD - MsgUpdate, //!< Short message even while printing from SD + Status, //!< status message from lcd_status_message variable + MeshBedLeveling, //!< Mesh bed leveling in progress + FilamentLoading, //!< Loading filament in progress + PidCal, //!< PID tuning in progress + TempCal, //!< PINDA temperature calibration + TempCompPreheat, //!< Temperature compensation preheat + M0Wait, //!< M0/M1 Wait command working even from SD + MsgUpdate, //!< Short message even while printing from SD }; extern CustomMsg custom_message_type; From 9071a9f8fd2350eb3ac1fd8ab1a66fdd7df68d44 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 15 Feb 2021 12:51:12 +0100 Subject: [PATCH 06/12] Gcode `M1` must have a string while `M0` it is optional As the `M0/M1` moved to the beginning of the parser - parser would not be able to "find" `M1nn` command if the query was `M1` instead of `M1 ` - to be able to "stop/halt" without sending a string and display default message use gcode `M0` - as there are no `M0nn` gcodes the parser can query `M0` without additional space needed as in `M1 ` --- Firmware/Marlin_main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 316a79c51..d6602ef87 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3833,16 +3833,16 @@ void process_commands() #### Usage M0 [P] [string] - M1 [P] [S] [string] + M1 [P] [S] [string] #### Parameters - `P` - Expire time, in milliseconds - `S` - Expire time, in seconds - - `string` - An optional message to display on the LCD + - `string` - Must for M1 and optional for M0 message to display on the LCD */ - else if (code_seen_P(PSTR("M0 ")) || code_seen_P(PSTR("M1 "))) { // M0 and M1 - (Un)conditional stop - Wait for user button press on LCD + else if (code_seen_P(PSTR("M0")) || code_seen_P(PSTR("M1 "))) { // M0 and M1 - (Un)conditional stop - Wait for user button press on LCD char *src = strchr_pointer + 2; From 583993b7e2ebf8c85a157fddb81248fc75efaf67 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 15 Feb 2021 15:25:04 +0100 Subject: [PATCH 07/12] Back to "Status" after gcode `M0/M1` --- Firmware/Marlin_main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4f83109fd..d99486baf 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3882,10 +3882,9 @@ void process_commands() marlin_wait_for_click(); } if (IS_SD_PRINTING) - LCD_MESSAGERPGM(_T(MSG_RESUMING_PRINT)); + custom_message_type = CustomMsg::Status; else LCD_MESSAGERPGM(_T(WELCOME_MSG)); - custom_message_type = CustomMsg::MsgUpdate; } #ifdef TMC2130 From d6c6517fcd3884bd15e4f1b0e9b6bbc4633076db Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Tue, 16 Feb 2021 07:27:46 +0100 Subject: [PATCH 08/12] Back to Status after Resuming --- Firmware/ultralcd.cpp | 6 +++++- Firmware/ultralcd.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 03446fc3e..bee49f444 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -899,6 +899,9 @@ void lcdui_print_status_line(void) lcd_print(' '); } break; + case CustomMsg::Resuming: //Resuming + lcd_puts_at_P(0, 3, _T(MSG_RESUMING_PRINT)); + break; } } @@ -6537,12 +6540,13 @@ void lcd_resume_print() lcd_setstatuspgm(_T(MSG_FINISHING_MOVEMENTS)); st_synchronize(); - lcd_setstatuspgm(_T(MSG_RESUMING_PRINT)); ////MSG_RESUMING_PRINT c=20 + custom_message_type = CustomMsg::Resuming; isPrintPaused = false; restore_print_from_ram_and_continue(default_retraction); pause_time += (_millis() - start_pause_print); //accumulate time when print is paused for correct statistics calculation refresh_cmd_timeout(); SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUMED); //resume octoprint + custom_message_type = CustomMsg::Status; } static void change_sheet() diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index a99e11301..ac8178cbc 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -122,6 +122,7 @@ enum class CustomMsg : uint_least8_t TempCompPreheat, //!< Temperature compensation preheat M0Wait, //!< M0/M1 Wait command working even from SD MsgUpdate, //!< Short message even while printing from SD + Resuming, //!< Resuming message }; extern CustomMsg custom_message_type; From 66ea1bdfba6396bd6d0dc2db5bc23ffab63cb56f Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Tue, 16 Feb 2021 12:31:23 +0100 Subject: [PATCH 09/12] Indentations --- Firmware/Marlin_main.cpp | 151 +++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 70 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d99486baf..6b4e9da06 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3799,92 +3799,103 @@ void process_commands() float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; int8_t SilentMode; #endif - /*! - - --------------------------------------------------------------------------------- - ### M117 - Display Message M117: Display Message - This causes the given message to be shown in the status line on an attached LCD. - It is processed early as to allow printing messages that contain G, M, N or T. - - --------------------------------------------------------------------------------- - ### Special internal commands - These are used by internal functions to process certain actions in the right order. Some of these are also usable by the user. - They are processed early as the commands are complex (strings). - These are only available on the MK3(S) as these require TMC2130 drivers: - - CRASH DETECTED - - CRASH RECOVER - - CRASH_CANCEL - - TMC_SET_WAVE - - TMC_SET_STEP - - TMC_SET_CHOP - */ - if (code_seen_P(PSTR("M117"))) { //moved to highest priority place to be able to to print strings which includes "G", "PRUSA" and "^" - starpos = (strchr(strchr_pointer + 5, '*')); - if (starpos != NULL) - *(starpos) = '\0'; - lcd_setstatus(strchr_pointer + 5); - custom_message_type = CustomMsg::MsgUpdate; - } + /*! + + --------------------------------------------------------------------------------- + ### M117 - Display Message M117: Display Message + This causes the given message to be shown in the status line on an attached LCD. + It is processed early as to allow printing messages that contain G, M, N or T. + + --------------------------------------------------------------------------------- + ### Special internal commands + These are used by internal functions to process certain actions in the right order. Some of these are also usable by the user. + They are processed early as the commands are complex (strings). + These are only available on the MK3(S) as these require TMC2130 drivers: + - CRASH DETECTED + - CRASH RECOVER + - CRASH_CANCEL + - TMC_SET_WAVE + - TMC_SET_STEP + - TMC_SET_CHOP + */ + if (code_seen_P(PSTR("M117"))) //moved to highest priority place to be able to to print strings which includes "G", "PRUSA" and "^" + { + starpos = (strchr(strchr_pointer + 5, '*')); + if (starpos != NULL) + *(starpos) = '\0'; + lcd_setstatus(strchr_pointer + 5); + custom_message_type = CustomMsg::MsgUpdate; + } /*! - ### M0, M1 - Stop the printer M0: Stop or Unconditional stop - #### Usage + ### M0, M1 - Stop the printer M0: Stop or Unconditional stop + #### Usage M0 [P] [string] M1 [P] [S] [string] - #### Parameters + #### Parameters - `P` - Expire time, in milliseconds - `S` - Expire time, in seconds - `string` - Must for M1 and optional for M0 message to display on the LCD */ - else if (code_seen_P(PSTR("M0")) || code_seen_P(PSTR("M1 "))) { // M0 and M1 - (Un)conditional stop - Wait for user button press on LCD + else if (code_seen_P(PSTR("M0")) || code_seen_P(PSTR("M1 "))) // M0 and M1 - (Un)conditional stop - Wait for user button press on LCD + { - char *src = strchr_pointer + 2; + char *src = strchr_pointer + 2; - codenum = 0; + codenum = 0; - bool hasP = false, hasS = false; - if (code_seen('P')) { - codenum = code_value(); // milliseconds to wait - hasP = codenum > 0; - } - if (code_seen('S')) { - codenum = code_value() * 1000; // seconds to wait - hasS = codenum > 0; - } - starpos = strchr(src, '*'); - if (starpos != NULL) *(starpos) = '\0'; - while (*src == ' ') ++src; - custom_message_type = CustomMsg::M0Wait; - if (!hasP && !hasS && *src != '\0') { - lcd_setstatus(src); - } else { - LCD_MESSAGERPGM(_i("Wait for user..."));////MSG_USERWAIT - } - - lcd_ignore_click(); //call lcd_ignore_click aslo for else ??? - st_synchronize(); - previous_millis_cmd = _millis(); - if (codenum > 0){ - codenum += _millis(); // keep track of when we started waiting - KEEPALIVE_STATE(PAUSED_FOR_USER); - while(_millis() < codenum && !lcd_clicked()){ - manage_heater(); - manage_inactivity(true); - lcd_update(0); + bool hasP = false, hasS = false; + if (code_seen('P')) + { + codenum = code_value(); // milliseconds to wait + hasP = codenum > 0; } - KEEPALIVE_STATE(IN_HANDLER); - lcd_ignore_click(false); - }else{ - marlin_wait_for_click(); - } - if (IS_SD_PRINTING) - custom_message_type = CustomMsg::Status; - else - LCD_MESSAGERPGM(_T(WELCOME_MSG)); + if (code_seen('S')) + { + codenum = code_value() * 1000; // seconds to wait + hasS = codenum > 0; + } + starpos = strchr(src, '*'); + if (starpos != NULL) *(starpos) = '\0'; + while (*src == ' ') ++src; + custom_message_type = CustomMsg::M0Wait; + if (!hasP && !hasS && *src != '\0') + { + lcd_setstatus(src); + } + else + { + LCD_MESSAGERPGM(_i("Wait for user..."));////MSG_USERWAIT + } + + lcd_ignore_click(); //call lcd_ignore_click aslo for else ??? + st_synchronize(); + previous_millis_cmd = _millis(); + if (codenum > 0) + { + codenum += _millis(); // keep track of when we started waiting + KEEPALIVE_STATE(PAUSED_FOR_USER); + while(_millis() < codenum && !lcd_clicked()) + { + manage_heater(); + manage_inactivity(true); + lcd_update(0); + } + KEEPALIVE_STATE(IN_HANDLER); + lcd_ignore_click(false); + } + else + { + marlin_wait_for_click(); + } + if (IS_SD_PRINTING) + custom_message_type = CustomMsg::Status; + else + LCD_MESSAGERPGM(_T(WELCOME_MSG)); } #ifdef TMC2130 From dbb0269bd4f832117c6248eb514f2cfbdd1b8122 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 17 Feb 2021 08:27:49 +0100 Subject: [PATCH 10/12] Make indentation consistent with surrounding code in factory_reset() --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index db3391244..537c55cb2 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -737,7 +737,7 @@ static void factory_reset_stats(){ static void factory_reset(char level) { lcd_clear(); - Sound_MakeCustom(100,0,false); + Sound_MakeCustom(100,0,false); switch (level) { case 0: // Level 0: Language reset From 75a385d6148eacf63091325c66bc019ba73262da Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 18 Feb 2021 09:10:28 +0100 Subject: [PATCH 11/12] Indentations --- Firmware/Marlin_main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6b4e9da06..a8e988c32 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8162,9 +8162,9 @@ Sigma_Exit: /*! ### M25 - Pause SD print M25: Pause SD print */ - case 25: - case 601: - { + case 25: + case 601: + { if (!isPrintPaused) { st_synchronize(); @@ -8172,8 +8172,8 @@ Sigma_Exit: cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore lcd_pause_print(); } - } - break; + } + break; /*! ### M602 - Resume print M602: Resume print From 291ee8e46dbf96b0e914946f351b7f05f57c5652 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 18 Feb 2021 09:53:14 +0100 Subject: [PATCH 12/12] Indentations --- Firmware/Marlin_main.cpp | 55 +++----- Firmware/ultralcd.cpp | 273 ++++++++++++++++++--------------------- 2 files changed, 144 insertions(+), 184 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a8e988c32..d968d6850 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3841,55 +3841,41 @@ void process_commands() - `string` - Must for M1 and optional for M0 message to display on the LCD */ - else if (code_seen_P(PSTR("M0")) || code_seen_P(PSTR("M1 "))) // M0 and M1 - (Un)conditional stop - Wait for user button press on LCD - { - + else if (code_seen_P(PSTR("M0")) || code_seen_P(PSTR("M1 "))) {// M0 and M1 - (Un)conditional stop - Wait for user button press on LCD char *src = strchr_pointer + 2; - codenum = 0; - bool hasP = false, hasS = false; - if (code_seen('P')) - { + if (code_seen('P')) { codenum = code_value(); // milliseconds to wait hasP = codenum > 0; } - if (code_seen('S')) - { + if (code_seen('S')) { codenum = code_value() * 1000; // seconds to wait hasS = codenum > 0; } starpos = strchr(src, '*'); if (starpos != NULL) *(starpos) = '\0'; while (*src == ' ') ++src; - custom_message_type = CustomMsg::M0Wait; - if (!hasP && !hasS && *src != '\0') - { + custom_message_type = CustomMsg::M0Wait; + if (!hasP && !hasS && *src != '\0') { lcd_setstatus(src); - } - else - { + } else { LCD_MESSAGERPGM(_i("Wait for user..."));////MSG_USERWAIT } - lcd_ignore_click(); //call lcd_ignore_click aslo for else ??? st_synchronize(); previous_millis_cmd = _millis(); - if (codenum > 0) - { + if (codenum > 0) { codenum += _millis(); // keep track of when we started waiting KEEPALIVE_STATE(PAUSED_FOR_USER); - while(_millis() < codenum && !lcd_clicked()) - { + while(_millis() < codenum && !lcd_clicked()) { manage_heater(); manage_inactivity(true); lcd_update(0); } KEEPALIVE_STATE(IN_HANDLER); lcd_ignore_click(false); - } - else - { + } else { marlin_wait_for_click(); } if (IS_SD_PRINTING) @@ -8165,8 +8151,7 @@ Sigma_Exit: case 25: case 601: { - if (!isPrintPaused) - { + if (!isPrintPaused) { st_synchronize(); ClearToSend(); //send OK even before the command finishes executing because we want to make sure it is not skipped because of cmdqueue_pop_front(); cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore @@ -8176,21 +8161,21 @@ Sigma_Exit: break; /*! - ### M602 - Resume print M602: Resume print + ### M602 - Resume print M602: Resume print */ - case 602: { - if (isPrintPaused) - lcd_resume_print(); - } - break; + case 602: { + if (isPrintPaused) + lcd_resume_print(); + } + break; /*! ### M603 - Stop print M603: Stop print */ - case 603: { - lcd_print_stop(); - } - break; + case 603: { + lcd_print_stop(); + } + break; #ifdef PINDA_THERMISTOR /*! diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index bee49f444..f5071152a 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -752,163 +752,138 @@ void lcdui_print_time(void) lcd_space(8 - chars); } -//Print status line on status screen +//! @Brief Print status line on status screen void lcdui_print_status_line(void) { - if (IS_SD_PRINTING) - { - if (strcmp(longFilenameOLD, (card.longFilename[0] ? card.longFilename : card.filename)) != 0) - { - memset(longFilenameOLD, '\0', strlen(longFilenameOLD)); - sprintf_P(longFilenameOLD, PSTR("%s"), (card.longFilename[0] ? card.longFilename : card.filename)); - scrollstuff = 0; - } - } + if (IS_SD_PRINTING) { + if (strcmp(longFilenameOLD, (card.longFilename[0] ? card.longFilename : card.filename)) != 0) { + memset(longFilenameOLD, '\0', strlen(longFilenameOLD)); + sprintf_P(longFilenameOLD, PSTR("%s"), (card.longFilename[0] ? card.longFilename : card.filename)); + scrollstuff = 0; + } + } - if (heating_status) - { // If heating flag, show progress of heating - heating_status_counter++; - if (heating_status_counter > 13) - { - heating_status_counter = 0; - } - lcd_set_cursor(7, 3); - lcd_space(13); + if (heating_status) { // If heating flag, show progress of heating + heating_status_counter++; + if (heating_status_counter > 13) { + heating_status_counter = 0; + } + lcd_set_cursor(7, 3); + lcd_space(13); - for (unsigned int dots = 0; dots < heating_status_counter; dots++) - { - lcd_putc_at(7 + dots, 3, '.'); - } - switch (heating_status) - { - case 1: - lcd_puts_at_P(0, 3, _T(MSG_HEATING)); - break; - case 2: - lcd_puts_at_P(0, 3, _T(MSG_HEATING_COMPLETE)); - heating_status = 0; - heating_status_counter = 0; - break; - case 3: - lcd_puts_at_P(0, 3, _T(MSG_BED_HEATING)); - break; - case 4: - lcd_puts_at_P(0, 3, _T(MSG_BED_DONE)); - heating_status = 0; - heating_status_counter = 0; - break; - default: - break; - } - } - else if ((IS_SD_PRINTING) && (custom_message_type == CustomMsg::Status)) - { // If printing from SD, show what we are printing - if(strlen(longFilenameOLD) > LCD_WIDTH) - { - int inters = 0; - int gh = scrollstuff; - while (((gh - scrollstuff) < LCD_WIDTH) && (inters == 0)) - { - if (longFilenameOLD[gh] == '\0') - { - lcd_set_cursor(gh - scrollstuff, 3); - lcd_print(longFilenameOLD[gh - 1]); - scrollstuff = 0; - gh = scrollstuff; - inters = 1; - } - else - { - lcd_set_cursor(gh - scrollstuff, 3); - lcd_print(longFilenameOLD[gh - 1]); - gh++; - } - } - scrollstuff++; - } - else - { - lcd_printf_P(PSTR("%-20s"), longFilenameOLD); - } - } - else - { // Otherwise check for other special events - switch (custom_message_type) - { - case CustomMsg::MsgUpdate: //Short message even while printing from SD - case CustomMsg::Status: // Nothing special, print status message normally - case CustomMsg::M0Wait: // M0/M1 Wait command working even from SD - lcd_print(lcd_status_message); - break; - case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status - if (custom_message_state > 10) - { - lcd_set_cursor(0, 3); - lcd_space(20); - lcd_puts_at_P(0, 3, _T(MSG_CALIBRATE_Z_AUTO)); - lcd_puts_P(PSTR(" : ")); - lcd_print(custom_message_state-10); - } - else - { - if (custom_message_state == 3) - { - lcd_puts_P(_T(WELCOME_MSG)); - lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsg::Status; - } - if (custom_message_state > 3 && custom_message_state <= 10 ) - { - lcd_set_cursor(0, 3); - lcd_space(19); - lcd_puts_at_P(0, 3, _i("Calibration done"));////MSG_HOMEYZ_DONE - custom_message_state--; - } - } - break; - case CustomMsg::FilamentLoading: // If loading filament, print status - lcd_print(lcd_status_message); - break; - case CustomMsg::PidCal: // PID tuning in progress - lcd_print(lcd_status_message); - if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) - { - lcd_set_cursor(10, 3); - lcd_print(itostr3(pid_cycle)); - lcd_print('/'); - lcd_print(itostr3left(pid_number_of_cycles)); - } - break; - case CustomMsg::TempCal: // PINDA temp calibration in progress - { - char statusLine[LCD_WIDTH + 1]; - sprintf_P(statusLine, PSTR("%-20S"), _T(MSG_TEMP_CALIBRATION)); - char progress[4]; - sprintf_P(progress, PSTR("%d/6"), custom_message_state); - memcpy(statusLine + 12, progress, sizeof(progress) - 1); - lcd_set_cursor(0, 3); - lcd_print(statusLine); - } - break; - case CustomMsg::TempCompPreheat: // temp compensation preheat - lcd_puts_at_P(0, 3, _i("PINDA Heating"));////MSG_PINDA_PREHEAT c=20 r=1 - if (custom_message_state <= PINDA_HEAT_T) - { - lcd_puts_P(PSTR(": ")); - lcd_print(custom_message_state); //seconds - lcd_print(' '); - } - break; + for (unsigned int dots = 0; dots < heating_status_counter; dots++) { + lcd_putc_at(7 + dots, 3, '.'); + } + switch (heating_status) { + case 1: + lcd_puts_at_P(0, 3, _T(MSG_HEATING)); + break; + case 2: + lcd_puts_at_P(0, 3, _T(MSG_HEATING_COMPLETE)); + heating_status = 0; + heating_status_counter = 0; + break; + case 3: + lcd_puts_at_P(0, 3, _T(MSG_BED_HEATING)); + break; + case 4: + lcd_puts_at_P(0, 3, _T(MSG_BED_DONE)); + heating_status = 0; + heating_status_counter = 0; + break; + default: + break; + } + } + else if ((IS_SD_PRINTING) && (custom_message_type == CustomMsg::Status)) { // If printing from SD, show what we are printing + if(strlen(longFilenameOLD) > LCD_WIDTH) { + int inters = 0; + int gh = scrollstuff; + while (((gh - scrollstuff) < LCD_WIDTH) && (inters == 0)) { + if (longFilenameOLD[gh] == '\0') { + lcd_set_cursor(gh - scrollstuff, 3); + lcd_print(longFilenameOLD[gh - 1]); + scrollstuff = 0; + gh = scrollstuff; + inters = 1; + } else { + lcd_set_cursor(gh - scrollstuff, 3); + lcd_print(longFilenameOLD[gh - 1]); + gh++; + } + } + scrollstuff++; + } else { + lcd_printf_P(PSTR("%-20s"), longFilenameOLD); + } + } else { // Otherwise check for other special events + switch (custom_message_type) { + case CustomMsg::MsgUpdate: //Short message even while printing from SD + case CustomMsg::Status: // Nothing special, print status message normally + case CustomMsg::M0Wait: // M0/M1 Wait command working even from SD + lcd_print(lcd_status_message); + break; + case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status + if (custom_message_state > 10) { + lcd_set_cursor(0, 3); + lcd_space(20); + lcd_puts_at_P(0, 3, _T(MSG_CALIBRATE_Z_AUTO)); + lcd_puts_P(PSTR(" : ")); + lcd_print(custom_message_state-10); + } else { + if (custom_message_state == 3) + { + lcd_puts_P(_T(WELCOME_MSG)); + lcd_setstatuspgm(_T(WELCOME_MSG)); + custom_message_type = CustomMsg::Status; + } + if (custom_message_state > 3 && custom_message_state <= 10 ) { + lcd_set_cursor(0, 3); + lcd_space(19); + lcd_puts_at_P(0, 3, _i("Calibration done"));////MSG_HOMEYZ_DONE + custom_message_state--; + } + } + break; + case CustomMsg::FilamentLoading: // If loading filament, print status + lcd_print(lcd_status_message); + break; + case CustomMsg::PidCal: // PID tuning in progress + lcd_print(lcd_status_message); + if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) { + lcd_set_cursor(10, 3); + lcd_print(itostr3(pid_cycle)); + lcd_print('/'); + lcd_print(itostr3left(pid_number_of_cycles)); + } + break; + case CustomMsg::TempCal: // PINDA temp calibration in progress + char statusLine[LCD_WIDTH + 1]; + sprintf_P(statusLine, PSTR("%-20S"), _T(MSG_TEMP_CALIBRATION)); + char progress[4]; + sprintf_P(progress, PSTR("%d/6"), custom_message_state); + memcpy(statusLine + 12, progress, sizeof(progress) - 1); + lcd_set_cursor(0, 3); + lcd_print(statusLine); + break; + case CustomMsg::TempCompPreheat: // temp compensation preheat + lcd_puts_at_P(0, 3, _i("PINDA Heating"));////MSG_PINDA_PREHEAT c=20 r=1 + if (custom_message_state <= PINDA_HEAT_T) { + lcd_puts_P(PSTR(": ")); + lcd_print(custom_message_state); //seconds + lcd_print(' '); + } + break; case CustomMsg::Resuming: //Resuming lcd_puts_at_P(0, 3, _T(MSG_RESUMING_PRINT)); break; - } - } - + } + } + // Fill the rest of line to have nice and clean output - for(int fillspace = 0; fillspace < 20; fillspace++) - if ((lcd_status_message[fillspace] <= 31 )) - lcd_print(' '); + for(int fillspace = 0; fillspace < 20; fillspace++) + if ((lcd_status_message[fillspace] <= 31 )) + lcd_print(' '); } //! @brief Show Status Screen