From e80af4650396bdb6bed1b0aa127cadc63fcdad55 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 31 Oct 2018 21:48:05 +0100 Subject: [PATCH] load to nozzle and Tx and Tc codes: intial version --- Firmware/Marlin_main.cpp | 64 +++++++++++++++++++++++++--------------- Firmware/mmu.cpp | 2 ++ Firmware/mmu.h | 2 ++ Firmware/ultralcd.cpp | 58 ++++++++++++++++++++++++++++++------ Firmware/ultralcd.h | 3 ++ 5 files changed, 96 insertions(+), 33 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index da18ee3d6..571051072 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3021,6 +3021,8 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float } + + void gcode_M701() { printf_P(PSTR("gcode_M701 begin\n")); @@ -3057,18 +3059,7 @@ void gcode_M701() noTone(BEEPER); 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); - - } - + lcd_load_filament_color_check(); } lcd_update_enable(true); lcd_update(2); @@ -6753,17 +6744,23 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) break; case 702: //! M702 [U C] - { - if (mmu_enabled) - { - if (code_seen('U')) - extr_unload_used(); //! if "U" unload all filaments which were used in current print - else if (code_seen('C')) - extr_unload(); //! if "C" unload just current filament - else - extr_unload_all(); //! otherwise unload all filaments - } +#ifdef SNMM + if (code_seen('U')) + extr_unload_used(); //! if "U" unload all filaments which were used in current print + else if (code_seen('C')) + extr_unload(); //! if "C" unload just current filament else - unload_filament(); + extr_unload_all(); //! otherwise unload all filaments +#else + if (code_seen('C')) { + if(mmu_enabled) extr_unload(); //! if "C" unload current filament; if mmu is not present no action is performed + } + else { + if(mmu_enabled) extr_unload(); //! unload current filament + else unload_filament(); + } + +#endif //SNMM } break; @@ -6779,7 +6776,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) // printf_P(_N("END M-CODE=%u\n"), mcode_in_progress); mcode_in_progress = 0; } - } // end if(code_seen('M')) (end of M codes) + } + // end if(code_seen('M')) (end of M codes) //! T - select extruder in case of multi extruder printer //! select filament in case of MMU_V2 //! if extruder is "?", open menu to let the user select extruder/filament @@ -6793,9 +6791,27 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) st_synchronize(); for (index = 1; *(strchr_pointer + index) == ' ' || *(strchr_pointer + index) == '\t'; index++); - if ((*(strchr_pointer + index) < '0' || *(strchr_pointer + index) > '4') && *(strchr_pointer + index) != '?') { + *(strchr_pointer + index) = tolower(*(strchr_pointer + index)); + + if ((*(strchr_pointer + index) < '0' || *(strchr_pointer + index) > '4') && *(strchr_pointer + index) != '?' && *(strchr_pointer + index) != 'x' && *(strchr_pointer + index) != 'c') { SERIAL_ECHOLNPGM("Invalid T code."); } + else if (*(strchr_pointer + index) == 'x'){ //load to bondtech gears; if mmu is not present do nothing + if (mmu_enabled) + { + tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT)); + mmu_command(MMU_CMD_T0 + tmp_extruder); + manage_response(true, true); + } + } + else if (*(strchr_pointer + index) == 'c') { //load to from bondtech gears to nozzle (nozzle should be preheated) + if (mmu_enabled) + { + mmu_command(MMU_CMD_C0); + mmu_extruder = tmp_extruder; //filament change is finished + mmu_load_to_nozzle(); + } + } else { if (*(strchr_pointer + index) == '?') { diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 30de0c513..082ecbe8b 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -940,6 +940,7 @@ void extr_change_3() lcd_return_to_status(); } +#ifdef SNMM //wrapper functions for unloading filament void extr_unload_all() { @@ -987,6 +988,7 @@ void extr_unload_used() lcd_return_to_status(); } } +#endif //SNMM void extr_unload_0() { diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 7ca5e25a1..53b5f5478 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -79,8 +79,10 @@ extern void extr_change_0(); extern void extr_change_1(); extern void extr_change_2(); extern void extr_change_3(); +#ifdef SNMM extern void extr_unload_all(); extern void extr_unload_used(); +#endif //SNMM extern void extr_unload_0(); extern void extr_unload_1(); extern void extr_unload_2(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 74145f564..a6243b701 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2426,6 +2426,19 @@ void lcd_alright() { } +void lcd_load_filament_color_check() +{ + 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); + } +} + #ifdef FILAMENT_SENSOR static void lcd_menu_AutoLoadFilament() { @@ -2472,6 +2485,32 @@ static void lcd_LoadFilament() } } +static void lcd_mmu_load_to_nozzle() +{ + if (degHotend0() > EXTRUDE_MINTEMP) + { + tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT)); + mmu_command(MMU_CMD_T0 + tmp_extruder); + manage_response(true, true); + mmu_command(MMU_CMD_C0); + mmu_extruder = tmp_extruder; //filament change is finished + mmu_load_to_nozzle(); + lcd_load_filament_color_check(); + lcd_return_to_status(); + } + 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(); + } +} + //! @brief Show filament used a print time //! //! If printing current print statistics are shown @@ -5189,8 +5228,6 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite } } -//#endif - char reset_menu() { #ifdef SNMM int items_no = 5; @@ -5288,6 +5325,8 @@ static void lcd_disable_farm_mode() } + + static void fil_load_menu() { MENU_BEGIN(); @@ -5317,6 +5356,7 @@ static void mmu_fil_eject_menu() MENU_END(); } +#ifdef SNMM static void fil_unload_menu() { MENU_BEGIN(); @@ -5332,6 +5372,7 @@ static void fil_unload_menu() MENU_END(); } +#endif //SNMM static void change_extr_menu(){ MENU_BEGIN(); @@ -5777,17 +5818,16 @@ static void lcd_main_menu() if (mmu_enabled) { MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), fil_load_menu); + MENU_ITEM_FUNCTION_P(_i("Load to nozzle"), lcd_mmu_load_to_nozzle); MENU_ITEM_SUBMENU_P(_i("Eject filament"), mmu_fil_eject_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 - } + MENU_ITEM_GCODE_P(_T(MSG_UNLOAD_FILAMENT), PSTR("M702 C")); } else { +#ifdef SNMM + 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 #ifdef FILAMENT_SENSOR if ((fsensor_autoload_enabled == true) && (fsensor_enabled == true) && (mmu_enabled == false)) MENU_ITEM_SUBMENU_P(_i("AutoLoad filament"), lcd_menu_AutoLoadFilament);////MSG_AUTOLOAD_FILAMENT c=17 r=0 diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index d2d4d0a26..5cd615781 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -38,6 +38,7 @@ void lcd_print_stop(); void prusa_statistics(int _message, uint8_t _col_nr = 0); void lcd_confirm_print(); unsigned char lcd_choose_color(); +void lcd_load_filament_color_check(); //void lcd_mylang(); extern bool lcd_selftest(); @@ -126,8 +127,10 @@ void lcd_commands(); void change_extr(int extr); void extr_adj(int extruder); +#ifdef SNMM void extr_unload_all(); void extr_unload_used(); +#endif //SNMM void extr_unload(); void unload_filament();