From df9f063f99fb1450adc5b645900899d2ee5ca6ad Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 3 May 2017 16:55:13 +0200 Subject: [PATCH] snmm: removed detection if print was terminated by reset/blackout; initial version of stop print for snmm --- Firmware/Marlin_main.cpp | 67 ++------------------ Firmware/ultralcd.cpp | 130 ++++++++++++++++++++++----------------- Firmware/ultralcd.h | 1 + 3 files changed, 77 insertions(+), 121 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0d3efd881..795c1299b 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1161,11 +1161,12 @@ void setup() // 1) Set a high power mode. eeprom_write_byte((uint8_t*)EEPROM_SILENT, 0); } - +#ifdef SNMM if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM int _z = BOWDEN_LENGTH; for(int i = 0; i<4; i++) EEPROM_save_B(EEPROM_BOWDEN_LENGTH + i * 2, &_z); } +#endif // In the future, somewhere here would one compare the current firmware version against the firmware version stored in the EEPROM. // If they differ, an update procedure may need to be performed. At the end of this block, the current firmware version @@ -2061,68 +2062,8 @@ void process_commands() } else if(code_seen("FR")) { // Factory full reset - factory_reset(0,true); - - }else if(code_seen("Y")) { //filaments adjustment at the beginning of print (for SNMM) - #ifdef SNMM - int extr; - SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); //is silent mode or loud mode set - lcd_implementation_clear(); - lcd_display_message_fullscreen_P(MSG_FIL_ADJUSTING); - current_position[Z_AXIS] = 100; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); - digipot_current(2, E_MOTOR_HIGH_CURRENT); - for (extr = 1; extr < 4; extr++) { //we dont know which filament is in nozzle, but we want to load filament0, so all other filaments must unloaded - change_extr(extr); - ramming(); - } - change_extr(0); - current_position[E_AXIS] += FIL_LOAD_LENGTH; //loading filament0 into the nozzle - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); - st_synchronize(); - - for (extr = 1; extr < 4; extr++) { - digipot_current(2, E_MOTOR_LOW_CURRENT); //set lower current for extruder motors - change_extr(extr); - current_position[E_AXIS] += (FIL_LOAD_LENGTH + 3 * FIL_RETURN_LENGTH); //adjusting filaments - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 5000, active_extruder); - st_synchronize(); - digipot_current(2, tmp_motor_loud[2]); //set back to normal operation currents - current_position[E_AXIS] -= FIL_RETURN_LENGTH; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); - st_synchronize(); - } - - change_extr(0); - current_position[E_AXIS] += 25; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder); - digipot_current(2, E_MOTOR_HIGH_CURRENT); - ramming(); - if (SilentMode == 1) digipot_current(2, tmp_motor[2]); //set back to normal operation currents - else digipot_current(2, tmp_motor_loud[2]); - st_synchronize(); - lcd_show_fullscreen_message_and_wait_P(MSG_CONFIRM_NOZZLE_CLEAN_FIL_ADJ); - lcd_implementation_clear(); - lcd_printPGM(MSG_PLEASE_WAIT); - current_position[Z_AXIS] = 0; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); - st_synchronize(); - lcd_update_enable(true); - - #endif - } - else if (code_seen("SetF")) { -#ifdef SNMM - bool not_finished = (eeprom_read_byte((unsigned char*)EEPROM_PRINT_FLAG) != PRINT_FINISHED); - eeprom_update_byte((unsigned char*)EEPROM_PRINT_FLAG, PRINT_STARTED); - if (not_finished) enquecommand_front_P(PSTR("PRUSA Y")); -#endif - } - else if (code_seen("ResF")) { -#ifdef SNMM - eeprom_update_byte((unsigned char*)EEPROM_PRINT_FLAG, PRINT_FINISHED); -#endif - } + factory_reset(0,true); + } //else if (code_seen('Cal')) { // lcd_calibration(); // } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d0d544fb2..4c907c7be 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -515,6 +515,43 @@ static void lcd_status_screen() #ifdef ULTIPANEL +void unload_fil() { + char cmd1[10]; + float unload_l = ((BOWDEN_LENGTH + 60 + FIL_LOAD_LENGTH) / 2); + + sprintf_P(cmd1, PSTR("M106 S%d"), fanSpeedBckp); + enquecommand(cmd1); + strcpy(cmd1, "G1 Z"); + strcat(cmd1, ftostr32(pause_lastpos[Z_AXIS])); + enquecommand(cmd1); + + enquecommand_P(PSTR("M907 E700")); //set extruder current higher + enquecommand_P(PSTR("M203 E50")); //set max. feedrate + st_synchronize(); + if (current_temperature[0] < 230) { + // PLA + enquecommand_P(PSTR("G1 E5.4 F2800.000000")); + enquecommand_P(PSTR("G1 E3.2 F3000.000000")); + enquecommand_P(PSTR("G1 E3 F3400.000000")); + st_synchronize(); + } + else { + // ABS + enquecommand_P(PSTR("G1 E3.1 F2000.000000")); + enquecommand_P(PSTR("G1 E3.1 F2500.000000")); + enquecommand_P(PSTR("G1 E4 F3000.000000")); + st_synchronize(); + } + enquecommand_P(PSTR("M203 E80")); //set max. feedrate + enquecommand_P(PSTR("M907 E550")); //set extruder current + st_synchronize(); + strcpy(cmd1, "G1 E-"); + strcat(cmd1, ftostr32(unload_l)); + enquecommand(cmd1); + enquecommand(cmd1); + st_synchronize(); +} + void lcd_commands() { char cmd1[25]; @@ -593,6 +630,7 @@ void lcd_commands() if (lcd_commands_type == LCD_COMMAND_STOP_PRINT) /// stop print { + uint8_t stopped_extruder; if (lcd_commands_step == 0) { @@ -624,9 +662,6 @@ void lcd_commands() { // M84: Disable steppers. enquecommand_P(PSTR("M84")); -#ifdef SNMM - enquecommand_P(PSTR("PRUSA ResF")); //resets flag at the end of the print (used for SNMM) -#endif autotempShutdown(); lcd_commands_step = 2; } @@ -675,62 +710,41 @@ void lcd_commands() lcd_commands_step = 5; } if (lcd_commands_step == 7 && !blocks_queued()) { - /*ramming(); - st_synchronize(); - change_extr(0);*/ - st_synchronize(); - enquecommand_P(PSTR("M907 E700")); //set extruder current higher - enquecommand_P(PSTR("M203 E50")); - st_synchronize(); - if (current_temperature[0] < 230) { - // PLA - - //enquecommand_P(PSTR("G1 E-8 F2100.000000")); - //enquecommand_P(PSTR("G1 E8 F2100.000000")); - enquecommand_P(PSTR("G1 E5.4 F2800.000000")); - enquecommand_P(PSTR("G1 E3.2 F3000.000000")); - enquecommand_P(PSTR("G1 E3 F3400.000000")); - enquecommand_P(PSTR("M203 E80")); - st_synchronize(); - enquecommand_P(PSTR("G1 E-82 F9500.000000")); - enquecommand_P(PSTR("M203 E50")); - enquecommand_P(PSTR("G1 E-20 F1200.000000")); - enquecommand_P(PSTR("G1 E5 F400.000000")); - enquecommand_P(PSTR("G1 E5 F600.000000")); - st_synchronize(); - enquecommand_P(PSTR("G1 E-10 F600.000000")); - enquecommand_P(PSTR("G1 E+10 F600.000000")); - enquecommand_P(PSTR("G1 E-10 F800.000000")); - enquecommand_P(PSTR("G1 E+10 F800.000000")); - enquecommand_P(PSTR("G1 E-10 F800.000000")); - st_synchronize(); - }else { - // ABS - - //enquecommand_P(PSTR("G1 E-8 F2100.000000")); - //enquecommand_P(PSTR("G1 E8 F2100.000000")); - enquecommand_P(PSTR("G1 E3.1 F2000.000000")); - enquecommand_P(PSTR("G1 E3.1 F2500.000000")); - enquecommand_P(PSTR("G1 E4 F3000.000000")); - st_synchronize(); - enquecommand_P(PSTR("G4 P4700")); - enquecommand_P(PSTR("M203 E80")); - enquecommand_P(PSTR("G1 E-92 F9900.000000")); - enquecommand_P(PSTR("M203 E50")); - enquecommand_P(PSTR("G1 E-5 F800.000000")); - enquecommand_P(PSTR("G1 E5 F400.000000")); - st_synchronize(); - enquecommand_P(PSTR("G1 E-5 F600.000000")); - enquecommand_P(PSTR("G1 E5 F600.000000")); - enquecommand_P(PSTR("G1 E-5 F600.000000")); - enquecommand_P(PSTR("G1 E5 F600.000000")); - enquecommand_P(PSTR("G1 E5 F600.000000")); - st_synchronize(); + MYSERIAL.print("7"); + stopped_extruder = snmm_extruder; + unload_fil(); + lcd_commands_step = 8; + } + if (lcd_commands_step == 8 && !blocks_queued()) { + MYSERIAL.print("8"); + if (stopped_extruder != 0) { + change_extr(0); + unload_fil(); + } + lcd_commands_step = 9; + } + if (lcd_commands_step == 9 && !blocks_queued()) { + MYSERIAL.print("9"); + if (stopped_extruder != 1) { + change_extr(1); + unload_fil(); + } + lcd_commands_step = 10; + } + if (lcd_commands_step == 10 && !blocks_queued()) { + MYSERIAL.print("10"); + if (stopped_extruder != 2) { + change_extr(2); + unload_fil(); + } + lcd_commands_step = 11; + } + if (lcd_commands_step == 11 && !blocks_queued()) { + MYSERIAL.print("11"); + if (stopped_extruder != 3) { + change_extr(3); + unload_fil(); } - enquecommand_P(PSTR("T0")); - enquecommand_P(PSTR("M907 E550")); //set extruder current to 500 - //digipot_init(); - lcd_commands_step = 3; } } diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index bba3f7d1a..1d2edc475 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -221,6 +221,7 @@ static void extr_unload_1(); static void extr_unload_2(); static void extr_unload_3(); static void lcd_disable_farm_mode(); +static void extr_unload_all(); void stack_error(); static void lcd_ping_allert();