diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 855c0823..a39339e4 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -121,6 +121,8 @@ #include #endif +#include "mmu.h" + #define VERSION_STRING "1.0.2" @@ -292,11 +294,13 @@ CardReader card; unsigned long PingTime = millis(); unsigned long NcTime; -union Data -{ -byte b[2]; -int value; -}; + +//used for PINDA temp calibration and pause print +#define DEFAULT_RETRACTION 1 +#define DEFAULT_RETRACTION_MM 4 //MM + +float default_retraction = DEFAULT_RETRACTION; + float homing_feedrate[] = HOMING_FEEDRATE; // Currently only the extruder axis may be switched to a relative mode. @@ -673,12 +677,12 @@ void crashdet_disable() void crashdet_stop_and_save_print() { - stop_and_save_print_to_ram(10, -DEFAULT_RETRACTION); //XY - no change, Z 10mm up, E -1mm retract + stop_and_save_print_to_ram(10, -default_retraction); //XY - no change, Z 10mm up, E -1mm retract } void crashdet_restore_print_and_continue() { - restore_print_from_ram_and_continue(DEFAULT_RETRACTION); //XYZ = orig, E +1mm unretract + restore_print_from_ram_and_continue(default_retraction); //XYZ = orig, E +1mm unretract // babystep_apply(); } @@ -3121,29 +3125,25 @@ void gcode_M600(bool automatic, float x_position, float y_position, float z_shif lcd_change_fil_state = 0; // Unload filament -#if defined (SNMM) || defined (SNMM_V2) - extr_unload(); //unload just current filament for multimaterial printers (used also in M702) -#else - unload_filament(); //unload filament for single material (used also in M702) -#endif + if (mmu_enabled) + extr_unload(); //unload just current filament for multimaterial printers (used also in M702) + else + unload_filament(); //unload filament for single material (used also in M702) //finish moves st_synchronize(); - -#if !defined(SNMM_V2) && !defined(SNMM) + if (!mmu_enabled) + { KEEPALIVE_STATE(PAUSED_FOR_USER); lcd_change_fil_state = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Was filament unload successful?"), false, true);////MSG_UNLOAD_SUCCESSFUL c=20 r=2 if (lcd_change_fil_state == 0) lcd_show_fullscreen_message_and_wait_P(_i("Please open idler and remove filament manually."));////MSG_CHECK_IDLER c=20 r=4 - lcd_update_enable(true); - -#endif + } -#ifdef SNMM_V2 - mmu_M600_load_filament(automatic); -#else - M600_load_filament(); -#endif + if (mmu_enabled) + mmu_M600_load_filament(automatic); + else + M600_load_filament(); if(!automatic) M600_check_state(); @@ -3191,70 +3191,70 @@ void gcode_M701() { printf_P(PSTR("gcode_M701 begin\n")); -#if defined (SNMM) || defined (SNMM_V2) - extr_adj(snmm_extruder);//loads current extruder -#else //defined (SNMM) || defined (SNMM_V2) - enable_z(); - custom_message = true; - custom_message_type = 2; + if (mmu_enabled) + extr_adj(snmm_extruder);//loads current extruder + else + { + enable_z(); + custom_message = true; + custom_message_type = 2; #ifdef FILAMENT_SENSOR - fsensor_oq_meassure_start(40); + fsensor_oq_meassure_start(40); #endif //FILAMENT_SENSOR - lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); - current_position[E_AXIS] += 40; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence - st_synchronize(); + lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); + current_position[E_AXIS] += 40; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence + st_synchronize(); - if (current_position[Z_AXIS] < 20) current_position[Z_AXIS] += 30; - current_position[E_AXIS] += 30; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence - st_synchronize(); - current_position[E_AXIS] += 25; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence - st_synchronize(); + if (current_position[Z_AXIS] < 20) current_position[Z_AXIS] += 30; + current_position[E_AXIS] += 30; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence + st_synchronize(); + current_position[E_AXIS] += 25; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence + st_synchronize(); -if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) - tone(BEEPER, 500); - delay_keep_alive(50); - noTone(BEEPER); + if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) tone(BEEPER, 500); + delay_keep_alive(50); + noTone(BEEPER); - if (!farm_mode && loading_flag) { - bool clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true); + if (!farm_mode && loading_flag) { + bool clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true); - while (!clean) { - lcd_update_enable(true); - lcd_update(2); - current_position[E_AXIS] += 25; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence - st_synchronize(); - clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true); + while (!clean) { + lcd_update_enable(true); + lcd_update(2); + current_position[E_AXIS] += 25; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence + st_synchronize(); + clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true); + + } } - - } - lcd_update_enable(true); - lcd_update(2); - lcd_setstatuspgm(_T(WELCOME_MSG)); - disable_z(); - loading_flag = false; - custom_message = false; - custom_message_type = 0; - -#ifdef FILAMENT_SENSOR - fsensor_oq_meassure_stop(); - - if (!fsensor_oq_result()) - { - bool disable = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Fil. sensor response is poor, disable it?"), false, true); lcd_update_enable(true); lcd_update(2); - if (disable) - fsensor_disable(); - } + lcd_setstatuspgm(_T(WELCOME_MSG)); + disable_z(); + loading_flag = false; + custom_message = false; + custom_message_type = 0; + +#ifdef FILAMENT_SENSOR + fsensor_oq_meassure_stop(); + + if (!fsensor_oq_result()) + { + bool disable = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Fil. sensor response is poor, disable it?"), false, true); + lcd_update_enable(true); + lcd_update(2); + if (disable) + fsensor_disable(); + } #endif //FILAMENT_SENSOR -#endif //defined (SNMM) || defined (SNMM_V2) + } } /** * @brief Get serial number from 32U2 processor @@ -4611,7 +4611,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) // SERIAL_ECHOLNPGM("Go home finished"); //unretract (after PINDA preheat retraction) if (degHotend(active_extruder) > EXTRUDE_MINTEMP && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) { - current_position[E_AXIS] += DEFAULT_RETRACTION; + current_position[E_AXIS] += default_retraction; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); } KEEPALIVE_STATE(NOT_BUSY); @@ -6460,11 +6460,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) #endif } -#ifdef SNMM_V2 - if (code_seen("AUTO")) { + if (mmu_enabled && code_seen("AUTO")) automatic = true; - } -#endif //SNMM_V2 gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late); @@ -6768,32 +6765,24 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; case 701: //M701: load filament { - #ifdef SNMM_V2 - if (code_seen('E')) - { + if (mmu_enabled && code_seen('E')) snmm_extruder = code_value(); - } - #endif - - gcode_M701(); } break; case 702: { -#if defined (SNMM) || defined (SNMM_V2) - if (code_seen('U')) { - extr_unload_used(); //unload all filaments which were used in current print + if (mmu_enabled) + { + if (code_seen('U')) + extr_unload_used(); //unload all filaments which were used in current print + else if (code_seen('C')) + extr_unload(); //unload just current filament + else + extr_unload_all(); //unload all filaments } - else if (code_seen('C')) { - extr_unload(); //unload just current filament - } - else { - extr_unload_all(); //unload all filaments - } -#else - unload_filament(); -#endif + else + unload_filament(); } break; @@ -6829,7 +6818,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) } snmm_filaments_used |= (1 << tmp_extruder); //for stop print -#if defined (SNMM_V2) +if (mmu_enabled) +{ printf_P(PSTR("T code: %d \n"), tmp_extruder); fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); @@ -6837,17 +6827,17 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) snmm_extruder = tmp_extruder; //filament change is finished - if (*(strchr_pointer + index) == '?') { // for single material usage with mmu + if (*(strchr_pointer + index) == '?')// for single material usage with mmu mmu_load_to_nozzle(); +} +else +{ +#ifdef SNMM - } -#elif defined(SNMM) - - - #ifdef LIN_ADVANCE + #ifdef LIN_ADVANCE if (snmm_extruder != tmp_extruder) clear_current_adv_vars(); //Check if the selected extruder is not the active one and reset LIN_ADVANCE variables if so. - #endif + #endif snmm_extruder = tmp_extruder; @@ -6889,7 +6879,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) } delay(100); -#else //SNMM and SNMM_V2 undefined: +#else //SNMM if (tmp_extruder >= EXTRUDERS) { SERIAL_ECHO_START; SERIAL_ECHOPGM("T"); @@ -6934,7 +6924,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) SERIAL_PROTOCOLLN((int)active_extruder); } -#endif +#endif //SNMM +} } } // end if(code_seen('T')) (end of T codes) @@ -7980,7 +7971,7 @@ void temp_compensation_start() { custom_message_state = PINDA_HEAT_T + 1; lcd_update(2); if (degHotend(active_extruder) > EXTRUDE_MINTEMP) { - current_position[E_AXIS] -= DEFAULT_RETRACTION; + current_position[E_AXIS] -= default_retraction; } plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); @@ -8119,7 +8110,7 @@ void long_pause() //long pause print pause_lastpos[E_AXIS] = current_position[E_AXIS]; //retract - current_position[E_AXIS] -= DEFAULT_RETRACTION; + current_position[E_AXIS] -= default_retraction; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); //lift z @@ -8218,7 +8209,7 @@ void uvlo_() current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], - current_position[E_AXIS] - DEFAULT_RETRACTION, + current_position[E_AXIS] - default_retraction, 95, active_extruder); st_synchronize(); @@ -8228,7 +8219,7 @@ void uvlo_() current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + UVLO_Z_AXIS_SHIFT + float((1024 - z_microsteps + 7) >> 4) / axis_steps_per_unit[Z_AXIS], - current_position[E_AXIS] - DEFAULT_RETRACTION, + current_position[E_AXIS] - default_retraction, 40, active_extruder); st_synchronize(); @@ -8238,7 +8229,7 @@ void uvlo_() current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + UVLO_Z_AXIS_SHIFT + float((1024 - z_microsteps + 7) >> 4) / axis_steps_per_unit[Z_AXIS], - current_position[E_AXIS] - DEFAULT_RETRACTION, + current_position[E_AXIS] - default_retraction, 40, active_extruder); st_synchronize(); disable_e0(); @@ -8432,7 +8423,7 @@ void recover_print(uint8_t automatic) { if(automatic == 0){ enquecommand_P(PSTR("G1 E5 F120")); //Extrude some filament to stabilize pessure } - enquecommand_P(PSTR("G1 E" STRINGIFY(-DEFAULT_RETRACTION)" F480")); + enquecommand_P(PSTR("G1 E" STRINGIFY(-default_retraction)" F480")); printf_P(_N("After waiting for temp:\nCurrent pos X_AXIS:%.3f\nCurrent pos Y_AXIS:%.3f\n"), current_position[X_AXIS], current_position[Y_AXIS]); @@ -8570,7 +8561,7 @@ void restore_print_from_eeprom() { strcpy_P(cmd, PSTR("G1 Z")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)))); enquecommand(cmd); // Unretract. - enquecommand_P(PSTR("G1 E" STRINGIFY(2*DEFAULT_RETRACTION)" F480")); + enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480")); // Set the feedrate saved at the power panic. sprintf_P(cmd, PSTR("G1 F%d"), feedrate_rec); enquecommand(cmd); @@ -8998,11 +8989,10 @@ void M600_check_state() { switch(lcd_change_fil_state){ // Filament failed to load so load it again case 2: - #ifdef SNMM_V2 - mmu_M600_load_filament(false); //nonautomatic load; change to "wrong filament loaded" option? - #else - M600_load_filament_movements(); - #endif + if (mmu_enabled) + mmu_M600_load_filament(false); //nonautomatic load; change to "wrong filament loaded" option? + else + M600_load_filament_movements(); break; // Filament loaded properly but color is not clear @@ -9103,63 +9093,61 @@ void M600_wait_for_user() { WRITE(BEEPER, LOW); } -void mmu_M600_load_filament(bool automatic) { +void mmu_M600_load_filament(bool automatic) +{ //load filament for mmu v2 -#ifdef SNMM_V2 - bool response = false; - bool yes = false; - if (!automatic) { - yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false); - if(yes) tmp_extruder = choose_extruder_menu(); - else tmp_extruder = snmm_extruder; - - } - else { - tmp_extruder = (tmp_extruder+1)%5; - } - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); - lcd_print(" "); - lcd_print(tmp_extruder + 1); - snmm_filaments_used |= (1 << tmp_extruder); //for stop print - printf_P(PSTR("T code: %d \n"), tmp_extruder); - fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); - - manage_response(); - snmm_extruder = tmp_extruder; //filament change is finished - - mmu_load_to_nozzle(); -#endif + bool response = false; + bool yes = false; + if (!automatic) + { + yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false); + if (yes) tmp_extruder = choose_extruder_menu(); + else tmp_extruder = snmm_extruder; + } + else + { + tmp_extruder = (tmp_extruder+1)%5; + } + lcd_update_enable(false); + lcd_clear(); + lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); + lcd_print(" "); + lcd_print(tmp_extruder + 1); + snmm_filaments_used |= (1 << tmp_extruder); //for stop print + printf_P(PSTR("T code: %d \n"), tmp_extruder); + fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); + manage_response(); + snmm_extruder = tmp_extruder; //filament change is finished + mmu_load_to_nozzle(); } -void M600_load_filament_movements() { +void M600_load_filament_movements() +{ #ifdef SNMM - display_loading(); - do { - current_position[E_AXIS] += 0.002; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); - delay_keep_alive(2); - } while (!lcd_clicked()); - - st_synchronize(); - current_position[E_AXIS] += bowden_length[snmm_extruder]; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000, active_extruder); - current_position[E_AXIS] += FIL_LOAD_LENGTH - 60; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1400, active_extruder); - current_position[E_AXIS] += 40; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); - current_position[E_AXIS] += 10; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); - + display_loading(); + do + { + current_position[E_AXIS] += 0.002; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); + delay_keep_alive(2); + } + while (!lcd_clicked()); + st_synchronize(); + current_position[E_AXIS] += bowden_length[snmm_extruder]; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000, active_extruder); + current_position[E_AXIS] += FIL_LOAD_LENGTH - 60; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1400, active_extruder); + current_position[E_AXIS] += 40; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); + current_position[E_AXIS] += 10; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); #else - current_position[E_AXIS]+= FILAMENTCHANGE_FIRSTFEED ; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED, active_extruder); + current_position[E_AXIS]+= FILAMENTCHANGE_FIRSTFEED ; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED, active_extruder); #endif - current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EXFEED, active_extruder); - - lcd_loading_filament(); + current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EXFEED, active_extruder); + lcd_loading_filament(); } void M600_load_filament() { diff --git a/Firmware/lcd.cpp b/Firmware/lcd.cpp index 806ef246..fa6556de 100644 --- a/Firmware/lcd.cpp +++ b/Firmware/lcd.cpp @@ -910,7 +910,7 @@ const uint8_t lcd_chardata_folder[8] PROGMEM = { B00000, B00000}; //thanks joris -const uint8_t lcd_chardata_feedrate[8] PROGMEM = { +/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = { B11100, B10000, B11000, @@ -918,7 +918,7 @@ const uint8_t lcd_chardata_feedrate[8] PROGMEM = { B00101, B00110, B00101, - B00000}; //thanks Sonny Mounicou + B00000};*/ //thanks Sonny Mounicou /*const uint8_t lcd_chardata_feedrate[8] PROGMEM = { B11100, @@ -940,7 +940,7 @@ const uint8_t lcd_chardata_feedrate[8] PROGMEM = { B01100, B10011};*/ -/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = { +const uint8_t lcd_chardata_feedrate[8] PROGMEM = { B00000, B00100, B10010, @@ -948,7 +948,7 @@ const uint8_t lcd_chardata_feedrate[8] PROGMEM = { B10010, B00100, B00000, - B00000};*/ + B00000}; const uint8_t lcd_chardata_clock[8] PROGMEM = { B00000, diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp new file mode 100644 index 00000000..2206e3dc --- /dev/null +++ b/Firmware/mmu.cpp @@ -0,0 +1,423 @@ +//mmu.cpp + +#include "mmu.h" +#include "planner.h" +#include "language.h" +#include "lcd.h" +#include "uart2.h" +#include "temperature.h" +#include "Configuration_prusa.h" + + +extern const char* lcd_display_message_fullscreen_P(const char *msg); +extern void lcd_return_to_status(); + +#ifdef SNMM_V2 +bool mmu_enabled = true; +#else //SNMM_V2 +bool mmu_enabled = false; +#endif //SNMM_V2 + +uint8_t snmm_extruder = 0; + +void extr_mov(float shift, float feed_rate) +{ //move extruder no matter what the current heater temperature is + set_extrude_min_temp(.0); + current_position[E_AXIS] += shift; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, active_extruder); + set_extrude_min_temp(EXTRUDE_MINTEMP); +} + + +void change_extr(int extr) { //switches multiplexer for extruders +#ifdef SNMM + st_synchronize(); + delay(100); + + disable_e0(); + disable_e1(); + disable_e2(); + + snmm_extruder = extr; + + pinMode(E_MUX0_PIN, OUTPUT); + pinMode(E_MUX1_PIN, OUTPUT); + + switch (extr) { + case 1: + WRITE(E_MUX0_PIN, HIGH); + WRITE(E_MUX1_PIN, LOW); + + break; + case 2: + WRITE(E_MUX0_PIN, LOW); + WRITE(E_MUX1_PIN, HIGH); + + break; + case 3: + WRITE(E_MUX0_PIN, HIGH); + WRITE(E_MUX1_PIN, HIGH); + + break; + default: + WRITE(E_MUX0_PIN, LOW); + WRITE(E_MUX1_PIN, LOW); + + break; + } + delay(100); +#endif +} + +int get_ext_nr() +{ //reads multiplexer input pins and return current extruder number (counted from 0) +#ifndef SNMM + return(snmm_extruder); //update needed +#else + return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN)); +#endif +} + + +void display_loading() +{ + switch (snmm_extruder) + { + case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break; + case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break; + case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break; + default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break; + } +} + +void extr_adj(int extruder) //loading filament for SNMM +{ +#ifndef SNMM + printf_P(PSTR("L%d \n"),extruder); + fprintf_P(uart2io, PSTR("L%d\n"), extruder); + + //show which filament is currently loaded + + lcd_update_enable(false); + lcd_clear(); + lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); + //if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd.setCursor(0, 1); + //else lcd.print(" "); + lcd_print(" "); + lcd_print(snmm_extruder + 1); + + // get response + manage_response(); + + lcd_update_enable(true); + + + //lcd_return_to_status(); +#else + + bool correct; + max_feedrate[E_AXIS] =80; + //max_feedrate[E_AXIS] = 50; + START: + lcd_clear(); + lcd_set_cursor(0, 0); + switch (extruder) { + case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break; + case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break; + case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break; + default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break; + } + KEEPALIVE_STATE(PAUSED_FOR_USER); + do{ + extr_mov(0.001,1000); + delay_keep_alive(2); + } while (!lcd_clicked()); + //delay_keep_alive(500); + KEEPALIVE_STATE(IN_HANDLER); + st_synchronize(); + //correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false); + //if (!correct) goto START; + //extr_mov(BOWDEN_LENGTH/2.f, 500); //dividing by 2 is there because of max. extrusion length limitation (x_max + y_max) + //extr_mov(BOWDEN_LENGTH/2.f, 500); + extr_mov(bowden_length[extruder], 500); + lcd_clear(); + lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); + if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd_set_cursor(0, 1); + else lcd_print(" "); + lcd_print(snmm_extruder + 1); + lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT)); + st_synchronize(); + max_feedrate[E_AXIS] = 50; + lcd_update_enable(true); + lcd_return_to_status(); + lcdDrawUpdate = 2; +#endif +} + + +void extr_unload() +{ //unload just current filament for multimaterial printers +#ifdef SNMM + float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT; + float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; + uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); +#endif + + if (degHotend0() > EXTRUDE_MINTEMP) + { +#ifndef SNMM + st_synchronize(); + + //show which filament is currently unloaded + lcd_update_enable(false); + lcd_clear(); + lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); + lcd_print(" "); + lcd_print(snmm_extruder + 1); + + current_position[E_AXIS] -= 80; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); + st_synchronize(); + printf_P(PSTR("U0\n")); + fprintf_P(uart2io, PSTR("U0\n")); + + // get response + manage_response(); + + lcd_update_enable(true); +#else //SNMM + + lcd_clear(); + lcd_display_message_fullscreen_P(PSTR("")); + max_feedrate[E_AXIS] = 50; + lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); + lcd_print(" "); + lcd_print(snmm_extruder + 1); + lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT)); + if (current_position[Z_AXIS] < 15) { + current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder); + } + + current_position[E_AXIS] += 10; //extrusion + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder); + st_current_set(2, E_MOTOR_HIGH_CURRENT); + if (current_temperature[0] < 230) { //PLA & all other filaments + current_position[E_AXIS] += 5.4; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder); + current_position[E_AXIS] += 3.2; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + current_position[E_AXIS] += 3; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder); + } + else { //ABS + current_position[E_AXIS] += 3.1; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder); + current_position[E_AXIS] += 3.1; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); + current_position[E_AXIS] += 4; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + /*current_position[X_AXIS] += 23; //delay + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay + current_position[X_AXIS] -= 23; //delay + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/ + delay_keep_alive(4700); + } + + max_feedrate[E_AXIS] = 80; + current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); + current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); + st_synchronize(); + //st_current_init(); + if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents + else st_current_set(2, tmp_motor_loud[2]); + lcd_update_enable(true); + lcd_return_to_status(); + max_feedrate[E_AXIS] = 50; +#endif //SNMM + } + else + { + lcd_clear(); + lcd_set_cursor(0, 0); + lcd_puts_P(_T(MSG_ERROR)); + lcd_set_cursor(0, 2); + lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); + delay(2000); + lcd_clear(); + } + //lcd_return_to_status(); +} + +//wrapper functions for loading filament +void extr_adj_0() +{ +#ifndef SNMM + enquecommand_P(PSTR("M701 E0")); +#else + change_extr(0); + extr_adj(0); +#endif +} + +void extr_adj_1() +{ +#ifndef SNMM + enquecommand_P(PSTR("M701 E1")); +#else + change_extr(1); + extr_adj(1); +#endif +} + +void extr_adj_2() +{ +#ifndef SNMM + enquecommand_P(PSTR("M701 E2")); +#else + change_extr(2); + extr_adj(2); +#endif +} + +void extr_adj_3() +{ +#ifndef SNMM + enquecommand_P(PSTR("M701 E3")); +#else + change_extr(3); + extr_adj(3); +#endif +} + +void extr_adj_4() +{ +#ifndef SNMM + enquecommand_P(PSTR("M701 E4")); +#else + change_extr(4); + extr_adj(4); +#endif +} + +void load_all() +{ +#ifndef SNMM + enquecommand_P(PSTR("M701 E0")); + enquecommand_P(PSTR("M701 E1")); + enquecommand_P(PSTR("M701 E2")); + enquecommand_P(PSTR("M701 E3")); + enquecommand_P(PSTR("M701 E4")); +#else + for (int i = 0; i < 4; i++) + { + change_extr(i); + extr_adj(i); + } +#endif +} + +//wrapper functions for changing extruders +void extr_change_0() +{ + change_extr(0); + lcd_return_to_status(); +} + +void extr_change_1() +{ + change_extr(1); + lcd_return_to_status(); +} + +void extr_change_2() +{ + change_extr(2); + lcd_return_to_status(); +} + +void extr_change_3() +{ + change_extr(3); + lcd_return_to_status(); +} + +//wrapper functions for unloading filament +void extr_unload_all() +{ + if (degHotend0() > EXTRUDE_MINTEMP) + { + for (int i = 0; i < 4; i++) + { + change_extr(i); + extr_unload(); + } + } + else + { + lcd_clear(); + lcd_set_cursor(0, 0); + lcd_puts_P(_T(MSG_ERROR)); + lcd_set_cursor(0, 2); + lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); + delay(2000); + lcd_clear(); + lcd_return_to_status(); + } +} + +//unloading just used filament (for snmm) +void extr_unload_used() +{ + if (degHotend0() > EXTRUDE_MINTEMP) { + for (int i = 0; i < 4; i++) { + if (snmm_filaments_used & (1 << i)) { + change_extr(i); + extr_unload(); + } + } + snmm_filaments_used = 0; + } + else { + lcd_clear(); + lcd_set_cursor(0, 0); + lcd_puts_P(_T(MSG_ERROR)); + lcd_set_cursor(0, 2); + lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); + delay(2000); + lcd_clear(); + lcd_return_to_status(); + } +} + +void extr_unload_0() +{ + change_extr(0); + extr_unload(); +} + +void extr_unload_1() +{ + change_extr(1); + extr_unload(); +} + +void extr_unload_2() +{ + change_extr(2); + extr_unload(); +} + +void extr_unload_3() +{ + change_extr(3); + extr_unload(); +} + +void extr_unload_4() +{ + change_extr(4); + extr_unload(); +} diff --git a/Firmware/mmu.h b/Firmware/mmu.h new file mode 100644 index 00000000..b8a0a1c9 --- /dev/null +++ b/Firmware/mmu.h @@ -0,0 +1,30 @@ +//mmu.h + +#include + +extern bool mmu_enabled; +extern uint8_t snmm_extruder; + +extern void extr_mov(float shift, float feed_rate); +extern void change_extr(int extr); +extern int get_ext_nr(); +extern void display_loading(); +extern void extr_adj(int extruder); +extern void extr_unload(); +extern void extr_adj_0(); +extern void extr_adj_1(); +extern void extr_adj_2(); +extern void extr_adj_3(); +extern void extr_adj_4(); +extern void load_all(); +extern void extr_change_0(); +extern void extr_change_1(); +extern void extr_change_2(); +extern void extr_change_3(); +extern void extr_unload_all(); +extern void extr_unload_used(); +extern void extr_unload_0(); +extern void extr_unload_1(); +extern void extr_unload_2(); +extern void extr_unload_3(); +extern void extr_unload_4(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b9afa034..dd1e912d 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -33,10 +33,9 @@ #include "sound.h" -#ifdef SNMM_V2 #include "uart2.h" -#endif //SNMM_V2 +#include "mmu.h" extern int lcd_change_fil_state; extern bool fans_check_enabled; @@ -73,9 +72,6 @@ extern void crashdet_disable(); #endif //TMC2130 -#if defined (SNMM) || defined (SNMM_V2) -uint8_t snmm_extruder = 0; -#endif #ifdef SDCARD_SORT_ALPHA bool presort_flag = false; @@ -165,16 +161,8 @@ static void lcd_colorprint_change(); static int get_ext_nr(); #endif //SNMM #if defined (SNMM) || defined(SNMM_V2) -static void extr_adj_0(); -static void extr_adj_1(); -static void extr_adj_2(); -static void extr_adj_3(); static void fil_load_menu(); static void fil_unload_menu(); -static void extr_unload_0(); -static void extr_unload_1(); -static void extr_unload_2(); -static void extr_unload_3(); #endif // SNMM || SNMM_V2 static void lcd_disable_farm_mode(); static void lcd_set_fan_check(); @@ -1112,11 +1100,11 @@ void lcd_commands() if (axis_relative_modes[3] == false) { enquecommand_P(PSTR("M83")); // set extruder to relative mode - enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION))); //unretract + enquecommand_P(PSTR("G1 E" STRINGIFY(default_retraction))); //unretract enquecommand_P(PSTR("M82")); // set extruder to absolute mode } else { - enquecommand_P(PSTR("G1 E" STRINGIFY(DEFAULT_RETRACTION))); //unretract + enquecommand_P(PSTR("G1 E" STRINGIFY(default_retraction))); //unretract } lcd_commands_step = 1; @@ -1431,9 +1419,8 @@ void lcd_commands() enquecommand_P(PSTR("M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP))); enquecommand_P(PSTR("M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP))); enquecommand_P(_T(MSG_M117_V2_CALIBRATION)); -#ifdef SNMM_V2 - enquecommand_P(PSTR("T?")); -#endif //SNMM_V2 + if (mmu_enabled) + enquecommand_P(PSTR("T?")); enquecommand_P(PSTR("G28")); enquecommand_P(PSTR("G92 E0.0")); lcd_commands_step = 8; @@ -1625,11 +1612,10 @@ void lcd_commands() { lcd_timeoutToStatus.start(); enquecommand_P(PSTR("M107")); //turn off printer fan - #ifdef SNMM_V2 - enquecommand_P(PSTR("M702 C")); - #else //SNMM_V2 - enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); - #endif //SNMM_V2 + if (mmu_enabled) + enquecommand_P(PSTR("M702 C")); + else + enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); enquecommand_P(PSTR("M104 S0")); // turn off temperature enquecommand_P(PSTR("M140 S0")); // turn off heatbed enquecommand_P(PSTR("G1 Z10 F1300.000")); @@ -1701,11 +1687,10 @@ void lcd_commands() enquecommand_P(PSTR("G1 X50 Y" STRINGIFY(Y_MAX_POS) " E0 F7000")); #endif lcd_ignore_click(false); - #if defined (SNMM) || defined (SNMM_V2) - lcd_commands_step = 8; - #else - lcd_commands_step = 3; - #endif + if (mmu_enabled) + lcd_commands_step = 8; + else + lcd_commands_step = 3; } if (lcd_commands_step == 5 && !blocks_queued()) { @@ -1722,25 +1707,25 @@ void lcd_commands() lcd_setstatuspgm(_T(MSG_PRINT_ABORTED)); cancel_heatup = true; setTargetBed(0); - #if !(defined (SNMM) || defined (SNMM_V2)) - setAllTargetHotends(0); - #endif + if (mmu_enabled) + setAllTargetHotends(0); manage_heater(); custom_message = true; custom_message_type = 2; lcd_commands_step = 5; } - if (lcd_commands_step == 7 && !blocks_queued()) { - #ifdef SNMM_V2 - enquecommand_P(PSTR("M702 C")); //current - #else //SNMM_V2 - switch(snmm_stop_print_menu()) { + if (lcd_commands_step == 7 && !blocks_queued()) + { + if (mmu_enabled) + enquecommand_P(PSTR("M702 C")); //current + else + switch(snmm_stop_print_menu()) + { case 0: enquecommand_P(PSTR("M702")); break;//all case 1: enquecommand_P(PSTR("M702 U")); break; //used case 2: enquecommand_P(PSTR("M702 C")); break; //current default: enquecommand_P(PSTR("M702")); break; - } - #endif //SNMM_V2 + } lcd_commands_step = 3; } if (lcd_commands_step == 8 && !blocks_queued()) { //step 8 is here for delay (going to next step after execution of all gcodes from step 4) @@ -1851,7 +1836,7 @@ static float count_e(float layer_heigth, float extrusion_width, float extrusion_ return extr; } -static void lcd_return_to_status() +void lcd_return_to_status() { lcd_refresh(); // to maybe revive the LCD if static electricity killed it. menu_goto(lcd_status_screen, 0, false, true); @@ -3277,8 +3262,14 @@ const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines) // Disable update of the screen by the usual lcd_update(0) routine. lcd_update_enable(false); lcd_clear(); +// uint8_t nlines; return lcd_display_message_fullscreen_nonBlocking_P(msg, nlines); } +const char* lcd_display_message_fullscreen_P(const char *msg) +{ + uint8_t nlines; + return lcd_display_message_fullscreen_P(msg, nlines); +} /** @@ -4307,27 +4298,29 @@ void lcd_toshiba_flash_air_compatibility_toggle() eeprom_update_byte((uint8_t*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY, card.ToshibaFlashAir_isEnabled()); } -void lcd_v2_calibration() { -#ifdef SNMM_V2 - lcd_commands_type = LCD_COMMAND_V2_CAL; -#else //SNMM_V2 - bool loaded = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is PLA filament loaded?"), false, true);////MSG_PLA_FILAMENT_LOADED c=20 r=2 - if (loaded) { +void lcd_v2_calibration() +{ + if (mmu_enabled) lcd_commands_type = LCD_COMMAND_V2_CAL; - } - else { - lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 - for (int i = 0; i < 20; i++) { //wait max. 2s - delay_keep_alive(100); - if (lcd_clicked()) { - while (lcd_clicked()); - delay(10); - while (lcd_clicked()); - break; + else + { + bool loaded = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is PLA filament loaded?"), false, true);////MSG_PLA_FILAMENT_LOADED c=20 r=2 + if (loaded) { + lcd_commands_type = LCD_COMMAND_V2_CAL; + } + else { + lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 + for (int i = 0; i < 20; i++) { //wait max. 2s + delay_keep_alive(100); + if (lcd_clicked()) { + while (lcd_clicked()); + delay(10); + while (lcd_clicked()); + break; + } } } } -#endif //SNMM_V2 lcd_return_to_status(); lcd_update_enable(true); } @@ -4933,13 +4926,9 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be } -char choose_extruder_menu() { - -#ifdef SNMM_V2 - int items_no = 5; -#else - int items_no = 4; -#endif +char choose_extruder_menu() +{ + int items_no = mmu_enabled?5:4; int first = 0; int enc_dif = 0; char cursor_pos = 1; @@ -5128,387 +5117,6 @@ static void lcd_disable_farm_mode() } - -#if defined (SNMM) || defined(SNMM_V2) - -static void extr_mov(float shift, float feed_rate) { //move extruder no matter what the current heater temperature is - set_extrude_min_temp(.0); - current_position[E_AXIS] += shift; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, active_extruder); - set_extrude_min_temp(EXTRUDE_MINTEMP); -} - - -void change_extr(int extr) { //switches multiplexer for extruders -#ifndef SNMM_V2 - st_synchronize(); - delay(100); - - disable_e0(); - disable_e1(); - disable_e2(); - - snmm_extruder = extr; - - pinMode(E_MUX0_PIN, OUTPUT); - pinMode(E_MUX1_PIN, OUTPUT); - - switch (extr) { - case 1: - WRITE(E_MUX0_PIN, HIGH); - WRITE(E_MUX1_PIN, LOW); - - break; - case 2: - WRITE(E_MUX0_PIN, LOW); - WRITE(E_MUX1_PIN, HIGH); - - break; - case 3: - WRITE(E_MUX0_PIN, HIGH); - WRITE(E_MUX1_PIN, HIGH); - - break; - default: - WRITE(E_MUX0_PIN, LOW); - WRITE(E_MUX1_PIN, LOW); - - break; - } - delay(100); -#endif -} - -#ifdef SNMM -static int get_ext_nr() { //reads multiplexer input pins and return current extruder number (counted from 0) -#ifdef SNMM_V2 - return(snmm_extruder); //update needed -#else - return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN)); -#endif -} -#endif //SNMM - - -void display_loading() { - switch (snmm_extruder) { - case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break; - case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break; - case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break; - default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break; - } -} - -void extr_adj(int extruder) //loading filament for SNMM -{ - -#ifdef SNMM_V2 - printf_P(PSTR("L%d \n"),extruder); - fprintf_P(uart2io, PSTR("L%d\n"), extruder); - - //show which filament is currently loaded - - - - - - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); - //if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd.setCursor(0, 1); - //else lcd.print(" "); - lcd_print(" "); - lcd_print(snmm_extruder + 1); - - // get response - manage_response(); - - lcd_update_enable(true); - - - //lcd_return_to_status(); -#else - - bool correct; - max_feedrate[E_AXIS] =80; - //max_feedrate[E_AXIS] = 50; - START: - lcd_clear(); - lcd_set_cursor(0, 0); - switch (extruder) { - case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break; - case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break; - case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break; - default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break; - } - KEEPALIVE_STATE(PAUSED_FOR_USER); - do{ - extr_mov(0.001,1000); - delay_keep_alive(2); - } while (!lcd_clicked()); - //delay_keep_alive(500); - KEEPALIVE_STATE(IN_HANDLER); - st_synchronize(); - //correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false); - //if (!correct) goto START; - //extr_mov(BOWDEN_LENGTH/2.f, 500); //dividing by 2 is there because of max. extrusion length limitation (x_max + y_max) - //extr_mov(BOWDEN_LENGTH/2.f, 500); - extr_mov(bowden_length[extruder], 500); - lcd_clear(); - lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); - if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd_set_cursor(0, 1); - else lcd_print(" "); - lcd_print(snmm_extruder + 1); - lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT)); - st_synchronize(); - max_feedrate[E_AXIS] = 50; - lcd_update_enable(true); - lcd_return_to_status(); - lcdDrawUpdate = 2; -#endif -} - - -void extr_unload() { //unload just current filament for multimaterial printers - #ifndef SNMM_V2 - float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT; - float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; - uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); - #endif - - if (degHotend0() > EXTRUDE_MINTEMP) { - #ifdef SNMM_V2 - st_synchronize(); - - //show which filament is currently unloaded - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); - lcd_print(" "); - lcd_print(snmm_extruder + 1); - - current_position[E_AXIS] -= 80; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); - st_synchronize(); - printf_P(PSTR("U0\n")); - fprintf_P(uart2io, PSTR("U0\n")); - - // get response - manage_response(); - - lcd_update_enable(true); - #else //SNMM_V2 - - lcd_clear(); - lcd_display_message_fullscreen_P(PSTR("")); - max_feedrate[E_AXIS] = 50; - lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT)); - lcd_print(" "); - lcd_print(snmm_extruder + 1); - lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT)); - if (current_position[Z_AXIS] < 15) { - current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder); - } - - current_position[E_AXIS] += 10; //extrusion - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder); - st_current_set(2, E_MOTOR_HIGH_CURRENT); - if (current_temperature[0] < 230) { //PLA & all other filaments - current_position[E_AXIS] += 5.4; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder); - current_position[E_AXIS] += 3.2; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); - current_position[E_AXIS] += 3; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder); - } - else { //ABS - current_position[E_AXIS] += 3.1; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder); - current_position[E_AXIS] += 3.1; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); - current_position[E_AXIS] += 4; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); - /*current_position[X_AXIS] += 23; //delay - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay - current_position[X_AXIS] -= 23; //delay - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/ - delay_keep_alive(4700); - } - - max_feedrate[E_AXIS] = 80; - current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); - current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); - st_synchronize(); - //st_current_init(); - if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents - else st_current_set(2, tmp_motor_loud[2]); - lcd_update_enable(true); - lcd_return_to_status(); - max_feedrate[E_AXIS] = 50; - #endif //SNMM_V2 - } - else { - - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - - delay(2000); - lcd_clear(); - } - //lcd_return_to_status(); -} - -//wrapper functions for loading filament -static void extr_adj_0(){ - #ifdef SNMM_V2 - enquecommand_P(PSTR("M701 E0")); - #else - change_extr(0); - extr_adj(0); - #endif -} -static void extr_adj_1() { - #ifdef SNMM_V2 - enquecommand_P(PSTR("M701 E1")); - #else - change_extr(1); - extr_adj(1); - #endif -} -static void extr_adj_2() { - #ifdef SNMM_V2 - enquecommand_P(PSTR("M701 E2")); - #else - change_extr(2); - extr_adj(2); - #endif -} -static void extr_adj_3() { - #ifdef SNMM_V2 - enquecommand_P(PSTR("M701 E3")); - #else - change_extr(3); - extr_adj(3); - #endif -} -static void extr_adj_4() { - #ifdef SNMM_V2 - enquecommand_P(PSTR("M701 E4")); - #else - change_extr(4); - extr_adj(4); - #endif -} - -static void load_all() { - #ifdef SNMM_V2 - enquecommand_P(PSTR("M701 E0")); - enquecommand_P(PSTR("M701 E1")); - enquecommand_P(PSTR("M701 E2")); - enquecommand_P(PSTR("M701 E3")); - enquecommand_P(PSTR("M701 E4")); - #else - for (int i = 0; i < 4; i++) { - - - - change_extr(i); - extr_adj(i); - - } - #endif -} - -//wrapper functions for changing extruders -static void extr_change_0() { - change_extr(0); - lcd_return_to_status(); -} -static void extr_change_1() { - change_extr(1); - lcd_return_to_status(); -} -static void extr_change_2() { - change_extr(2); - lcd_return_to_status(); -} -static void extr_change_3() { - change_extr(3); - lcd_return_to_status(); -} - -//wrapper functions for unloading filament -void extr_unload_all() { - if (degHotend0() > EXTRUDE_MINTEMP) { - for (int i = 0; i < 4; i++) { - change_extr(i); - extr_unload(); - } - } - else { - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - delay(2000); - lcd_clear(); - lcd_return_to_status(); - } -} - -//unloading just used filament (for snmm) -void extr_unload_used() { - if (degHotend0() > EXTRUDE_MINTEMP) { - for (int i = 0; i < 4; i++) { - if (snmm_filaments_used & (1 << i)) { - change_extr(i); - extr_unload(); - } - } - snmm_filaments_used = 0; - } - else { - lcd_clear(); - lcd_set_cursor(0, 0); - lcd_puts_P(_T(MSG_ERROR)); - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_PREHEAT_NOZZLE)); - delay(2000); - lcd_clear(); - lcd_return_to_status(); - } -} - - - -static void extr_unload_0() { - change_extr(0); - extr_unload(); -} -static void extr_unload_1() { - change_extr(1); - extr_unload(); -} -static void extr_unload_2() { - change_extr(2); - extr_unload(); -} -static void extr_unload_3() { - change_extr(3); - extr_unload(); -} -static void extr_unload_4() { - change_extr(4); - extr_unload(); -} - static void fil_load_menu() { MENU_BEGIN(); @@ -5519,9 +5127,8 @@ static void fil_load_menu() MENU_ITEM_FUNCTION_P(_i("Load filament 3"), extr_adj_2);////MSG_LOAD_FILAMENT_3 c=17 r=0 MENU_ITEM_FUNCTION_P(_i("Load filament 4"), extr_adj_3);////MSG_LOAD_FILAMENT_4 c=17 r=0 -#ifdef SNMM_V2 - MENU_ITEM_FUNCTION_P(_i("Load filament 5"), extr_adj_4); -#endif + if (mmu_enabled) + MENU_ITEM_FUNCTION_P(_i("Load filament 5"), extr_adj_4); MENU_END(); } @@ -5536,9 +5143,8 @@ static void fil_unload_menu() MENU_ITEM_FUNCTION_P(_i("Unload filament 3"), extr_unload_2);////MSG_UNLOAD_FILAMENT_3 c=17 r=0 MENU_ITEM_FUNCTION_P(_i("Unload filament 4"), extr_unload_3);////MSG_UNLOAD_FILAMENT_4 c=17 r=0 -#ifdef SNMM_V2 - MENU_ITEM_FUNCTION_P(_i("Unload filament 5"), extr_unload_4);////MSG_UNLOAD_FILAMENT_4 c=17 r=0 -#endif + if (mmu_enabled) + MENU_ITEM_FUNCTION_P(_i("Unload filament 5"), extr_unload_4);////MSG_UNLOAD_FILAMENT_4 c=17 r=0 MENU_END(); } @@ -5554,10 +5160,10 @@ static void change_extr_menu(){ MENU_END(); } -#endif //unload filament for single material printer (used in M702 gcode) -void unload_filament() { +void unload_filament() +{ custom_message = true; custom_message_type = 2; lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT)); @@ -5976,25 +5582,27 @@ static void lcd_main_menu() } else { - #if defined (SNMM) || defined (SNMM_V2) - MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), fil_load_menu); - #ifdef SNMM_V2 - MENU_ITEM_GCODE_P(_T(MSG_UNLOAD_FILAMENT), PSTR("M702 C")); - #else - MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), fil_unload_menu); - MENU_ITEM_SUBMENU_P(_i("Change extruder"), change_extr_menu);////MSG_CHANGE_EXTR c=20 r=1 - #endif - - #else - #ifdef FILAMENT_SENSOR - if ( ((fsensor_autoload_enabled == true) && (fsensor_enabled == true))) - MENU_ITEM_SUBMENU_P(_i("AutoLoad filament"), lcd_menu_AutoLoadFilament);////MSG_AUTOLOAD_FILAMENT c=17 r=0 + if (mmu_enabled) + { + MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), fil_load_menu); + if (mmu_enabled) + MENU_ITEM_GCODE_P(_T(MSG_UNLOAD_FILAMENT), PSTR("M702 C")); + else + { + MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), fil_unload_menu); + MENU_ITEM_SUBMENU_P(_i("Change extruder"), change_extr_menu);////MSG_CHANGE_EXTR c=20 r=1 + } + } else - #endif //FILAMENT_SENSOR - MENU_ITEM_FUNCTION_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament); - MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament); - #endif - + { +#ifdef FILAMENT_SENSOR + if ( ((fsensor_autoload_enabled == true) && (fsensor_enabled == true))) + MENU_ITEM_SUBMENU_P(_i("AutoLoad filament"), lcd_menu_AutoLoadFilament);////MSG_AUTOLOAD_FILAMENT c=17 r=0 + else +#endif //FILAMENT_SENSOR + MENU_ITEM_FUNCTION_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament); + MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament); + } MENU_ITEM_SUBMENU_P(_T(MSG_SETTINGS), lcd_settings_menu); if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_MENU_CALIBRATION), lcd_calibration_menu); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index df887456..77da5933 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -128,9 +128,8 @@ extern union MenuData menuData; void lcd_menu_statistics(); - extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines); - inline const char* lcd_display_message_fullscreen_P(const char *msg) - { uint8_t nlines; return lcd_display_message_fullscreen_P(msg, nlines); } +extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines); +extern const char* lcd_display_message_fullscreen_P(const char *msg); extern void lcd_wait_for_click(); extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); @@ -186,10 +185,7 @@ extern union MenuData menuData; #endif extern int8_t SilentModeMenu; -#if defined (SNMM) || defined (SNMM_V2) - extern uint8_t snmm_extruder; -#endif // defined (SNMM) || defined (SNMM_V2) - + extern bool cancel_heatup; extern bool isPrintPaused; diff --git a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h index 6ca8b213..9783e9f6 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h @@ -414,11 +414,6 @@ THERMISTORS SETTINGS #define DEFAULT_PID_TEMP 210 -#ifdef SNMM -#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print -#else -#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print -#endif #define END_FILE_SECTION 20000 //number of bytes from end of file used for checking if file is complete diff --git a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h index d6352ae5..3ac39750 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h @@ -414,11 +414,6 @@ THERMISTORS SETTINGS #define DEFAULT_PID_TEMP 210 -#ifdef SNMM -#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print -#else -#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print -#endif #define END_FILE_SECTION 20000 //number of bytes from end of file used for checking if file is complete diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index 309ad57a..304cde4b 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -476,11 +476,6 @@ #define MIN_PRINT_FAN_SPEED 75 -#ifdef SNMM -#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print -#else -#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print -#endif #define M600_TIMEOUT 600 //seconds diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index ad9d4a5b..9fccbfc2 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -477,11 +477,6 @@ #define MIN_PRINT_FAN_SPEED 75 -#ifdef SNMM -#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print -#else -#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print -#endif #define M600_TIMEOUT 600 //seconds diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 06fe8cbd..dbce6a96 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -594,11 +594,6 @@ #define MIN_PRINT_FAN_SPEED 75 -#if defined (SNMM) || defined (SNMM_V2) -#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print -#else -#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print -#endif // How much shall the print head be lifted on power panic? // Ideally the Z axis will reach a zero phase of the stepper driver on power outage. To simplify this, diff --git a/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h index ed6d0c3d..d572c7b4 100644 --- a/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-MMU-EINSy10a-E3Dv6full.h @@ -595,11 +595,6 @@ #define MIN_PRINT_FAN_SPEED 75 -#if defined (SNMM) || defined (SNMM_V2) -#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print -#else -#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print -#endif // How much shall the print head be lifted on power panic? // Ideally the Z axis will reach a zero phase of the stepper driver on power outage. To simplify this,