diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index cdde3e351..2db85d01a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3770,31 +3770,90 @@ 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; + } + + /*! + ### M0, M1 - Stop the printer M0: Stop or Unconditional stop + #### Usage + + M0 [P] [string] + M1 [P] [S] [string] + + #### Parameters - --------------------------------------------------------------------------------- - ### 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); - } + - `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 + 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; + 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 else if (strncmp_P(CMDBUFFER_CURRENT_STRING, PSTR("CRASH_"), 6) == 0) @@ -5653,60 +5712,10 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) switch(mcode_in_progress) { - /*! - ### M0, M1 - Stop the printer M0: Stop or Unconditional stop - */ - 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; - /*! ### M17 - Enable all axes M17: Enable/Power all stepper motors */ + case 17: LCD_MESSAGERPGM(_i("No move."));////MSG_NO_MOVE enable_x(); @@ -8110,35 +8119,34 @@ Sigma_Exit: /*! ### M25 - Pause SD print M25: Pause SD print */ - case 25: - case 601: - { - if (!isPrintPaused) - { + case 25: + case 601: + { + 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 lcd_pause_print(); } - } - break; + } + 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 d5c026cbe..5b7b8f59d 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -752,158 +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; + case CustomMsg::Resuming: //Resuming + lcd_puts_at_P(0, 3, _T(MSG_RESUMING_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::Status: // Nothing special, print status message normally - 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; - } - } - // 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 @@ -6535,12 +6515,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 62aed6dff..ac8178cbc 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -114,12 +114,15 @@ 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 + 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 + Resuming, //!< Resuming message }; extern CustomMsg custom_message_type;