Browse Source

Merge pull request #1021 from XPila/MK3-new_lang

MM support and 3.4 RC1 finalization
XPila 6 years ago
parent
commit
cb379707af
6 changed files with 247 additions and 193 deletions
  1. 5 9
      Firmware/Marlin.h
  2. 17 176
      Firmware/Marlin_main.cpp
  3. 2 0
      Firmware/lcd.cpp
  4. 198 7
      Firmware/mmu.cpp
  5. 13 0
      Firmware/mmu.h
  6. 12 1
      Firmware/ultralcd.cpp

+ 5 - 9
Firmware/Marlin.h

@@ -359,11 +359,11 @@ extern bool mmu_print_saved;
 
 //estimated time to end of the print
 extern uint8_t print_percent_done_normal;
-extern uint16_t print_time_remaining_normal;
+extern uint32_t print_time_remaining_normal;
 extern uint8_t print_percent_done_silent;
-extern uint16_t print_time_remaining_silent;
-#define PRINT_TIME_REMAINING_INIT 65535
-#define PRINT_PERCENT_DONE_INIT 255
+extern uint32_t print_time_remaining_silent;
+#define PRINT_TIME_REMAINING_INIT 0xffffffff
+#define PRINT_PERCENT_DONE_INIT   0xff
 #define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == 4) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved)
 
 extern void calculate_extruder_multipliers();
@@ -467,12 +467,8 @@ void gcode_M701();
 
 void proc_commands();
 
-void manage_response(bool move_axes, bool turn_off_nozzle);
-bool mmu_get_response(bool timeout);
-void mmu_not_responding();
-void mmu_load_to_nozzle();
+
 void M600_load_filament();
-void mmu_M600_load_filament(bool automatic);
 void M600_load_filament_movements();
 void M600_wait_for_user();
 void M600_check_state();

+ 17 - 176
Firmware/Marlin_main.cpp

@@ -336,8 +336,8 @@ float pause_lastpos[4];
 unsigned long pause_time = 0;
 unsigned long start_pause_print = millis();
 unsigned long t_fan_rising_edge = millis();
-static LongTimer safetyTimer;
-static LongTimer crashDetTimer;
+LongTimer safetyTimer;
+LongTimer crashDetTimer;
 
 //unsigned long load_filament_time;
 
@@ -475,9 +475,9 @@ bool mmu_print_saved = false;
 
 // storing estimated time to end of print counted by slicer
 uint8_t print_percent_done_normal = PRINT_PERCENT_DONE_INIT;
-uint16_t print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes
+uint32_t print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes
 uint8_t print_percent_done_silent = PRINT_PERCENT_DONE_INIT;
-uint16_t print_time_remaining_silent = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes
+uint32_t print_time_remaining_silent = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes
 
 //===========================================================================
 //=============================Private Variables=============================
@@ -508,7 +508,6 @@ unsigned long starttime=0;
 unsigned long stoptime=0;
 unsigned long _usb_timer = 0;
 
-static uint8_t tmp_extruder;
 
 bool extruder_under_pressure = true;
 
@@ -6336,21 +6335,14 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
 		//currently three different materials are needed (default, flex and PVA) 
 		//add storing this information for different load/unload profiles etc. in the future
 		//firmware does not wait for "ok" from mmu
-
-		uint8_t extruder;
-		uint8_t filament;
-
-		if(code_seen('E')) extruder = code_value();
-		if(code_seen('F')) filament = code_value();
-
-		printf_P(PSTR("Extruder: %d; "), extruder);
-		switch (filament) {
-			case FILAMENT_FLEX: printf_P(PSTR("Flex\n")); break;
-			case FILAMENT_PVA: printf_P(PSTR("PVA\n")); break;
-			default: printf_P(PSTR("Default\n")); break;
+		if (mmu_enabled)
+		{
+			uint8_t extruder;
+			uint8_t filament;
+			if(code_seen('E')) extruder = code_value();
+			if(code_seen('F')) filament = code_value();
+			mmu_set_filament_type(extruder, filament);
 		}
-		printf_P(PSTR("F%d%d\n"), extruder, filament);
-		mmu_printf_P(PSTR("F%d%d\n"), extruder, filament);
 	}
 	break;
 
@@ -8872,7 +8864,8 @@ uint16_t print_time_remaining() {
 	return print_t;
 }
 
-uint8_t print_percent_done() {
+uint8_t print_percent_done()
+{
 	//in case that we have information from M73 gcode return percentage counted by slicer, else return percentage counted as byte_printed/filesize
 	uint8_t percent_done = 0;
 	if (SilentModeMenu == SILENT_MODE_OFF && print_percent_done_normal <= 100) {
@@ -8887,135 +8880,17 @@ uint8_t print_percent_done() {
 	return percent_done;
 }
 
-static void print_time_remaining_init() {
+static void print_time_remaining_init()
+{
 	print_time_remaining_normal = PRINT_TIME_REMAINING_INIT;
 	print_time_remaining_silent = PRINT_TIME_REMAINING_INIT;
 	print_percent_done_normal = PRINT_PERCENT_DONE_INIT;
 	print_percent_done_silent = PRINT_PERCENT_DONE_INIT;
 }
 
-bool mmu_get_response(bool timeout) {
-	//waits for "ok" from mmu
-	//function returns true if "ok" was received
-	//if timeout is set to true function return false if there is no "ok" received before timeout
-	bool response = true;
-	LongTimer mmu_get_reponse_timeout;
-	KEEPALIVE_STATE(IN_PROCESS);
-	mmu_get_reponse_timeout.start();
-	while (mmu_rx_ok() <= 0)
-    {
-      delay_keep_alive(100);
-	  if (timeout && mmu_get_reponse_timeout.expired(5 * 60 * 1000ul)) { //5 minutes timeout
-			response = false;
-			break;
-	  }
-    }
-	return response;
-}
-
 
-void manage_response(bool move_axes, bool turn_off_nozzle) {
-	
-	bool response = false;
-	mmu_print_saved = false;
-	bool lcd_update_was_enabled = false;
-	float hotend_temp_bckp = degTargetHotend(active_extruder);
-	float z_position_bckp = current_position[Z_AXIS];
-	float x_position_bckp = current_position[X_AXIS];
-	float y_position_bckp = current_position[Y_AXIS];	
-	while(!response) {
-		  response = mmu_get_response(true); //wait for "ok" from mmu
-		  if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit
-			  if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater
-				  if (lcd_update_enabled) {
-					  lcd_update_was_enabled = true;
-					  lcd_update_enable(false);
-				  }
-				  st_synchronize();
-				  mmu_print_saved = true;
-				  
-				  hotend_temp_bckp = degTargetHotend(active_extruder);
-				  if (move_axes) {
-					  z_position_bckp = current_position[Z_AXIS];
-					  x_position_bckp = current_position[X_AXIS];
-					  y_position_bckp = current_position[Y_AXIS];
-				  
-					  //lift z
-					  current_position[Z_AXIS] += Z_PAUSE_LIFT;
-					  if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
-					  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
-					  st_synchronize();
-					  					  
-					  //Move XY to side
-					  current_position[X_AXIS] = X_PAUSE_POS;
-					  current_position[Y_AXIS] = Y_PAUSE_POS;
-					  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
-					  st_synchronize();
-				  }
-				  if (turn_off_nozzle) {
-					  //set nozzle target temperature to 0
-					  setAllTargetHotends(0);
-					  printf_P(PSTR("MMU not responding\n"));
-					  lcd_show_fullscreen_message_and_wait_P(_i("MMU needs user attention. Please press knob to resume nozzle target temperature."));
-					  setTargetHotend(hotend_temp_bckp, active_extruder);
-					  while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) {
-						  delay_keep_alive(1000);
-						  lcd_wait_for_heater();
-					  }
-				  }
-			  }
-			  lcd_display_message_fullscreen_P(_i("Check MMU. Fix the issue and then press button on MMU unit."));
-		  }
-		  else if (mmu_print_saved) {
-			  printf_P(PSTR("MMU start responding\n"));
-			  lcd_clear();
-			  lcd_display_message_fullscreen_P(_i("MMU OK. Resuming..."));
-			  if (move_axes) {
-				  current_position[X_AXIS] = x_position_bckp;
-				  current_position[Y_AXIS] = y_position_bckp;
-				  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
-				  st_synchronize();
-				  current_position[Z_AXIS] = z_position_bckp;
-				  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
-				  st_synchronize();
-			  }
-			  else {
-				  delay_keep_alive(1000); //delay just for showing MMU OK message for a while in case that there are no xyz movements
-			  }
-		  }
-	}
-	if (lcd_update_was_enabled) lcd_update_enable(true);
-}
-
-void mmu_load_to_nozzle() {
-	st_synchronize();
-	
-	bool saved_e_relative_mode = axis_relative_modes[E_AXIS];
-	if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true;
-	current_position[E_AXIS] += 7.2f;
-    float feedrate = 562;
-	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
-    st_synchronize();
-	current_position[E_AXIS] += 14.4f;
-	feedrate = 871;
-	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
-    st_synchronize();
-	current_position[E_AXIS] += 36.0f;
-	feedrate = 1393;
-	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
-    st_synchronize();
-	current_position[E_AXIS] += 14.4f;
-	feedrate = 871;
-	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
-    st_synchronize();
-	if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = false;
-}
-
-void mmu_switch_extruder(uint8_t extruder) {
-
-}
-
-void M600_check_state() {
+void M600_check_state()
+{
 		//Wait for user to check the state
 		lcd_change_fil_state = 0;
 		
@@ -9129,40 +9004,6 @@ void M600_wait_for_user() {
 		WRITE(BEEPER, LOW);
 }
 
-void mmu_M600_load_filament(bool automatic)
-{ 
-	//load filament for mmu 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 = mmu_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);
-		  mmu_printf_P(PSTR("T%d\n"), tmp_extruder);
-
-		  manage_response(false, true);
-    	  mmu_extruder = tmp_extruder; //filament change is finished
-
-		  mmu_load_to_nozzle();
-
-		  st_synchronize();
-		  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], 2, active_extruder);
-}
-
 void M600_load_filament_movements()
 {
 #ifdef SNMM

+ 2 - 0
Firmware/lcd.cpp

@@ -755,6 +755,7 @@ void lcd_update_enable(uint8_t enabled)
 	}
 }
 
+extern LongTimer safetyTimer;
 void lcd_buttons_update(void)
 {
 	static bool _lock = false;
@@ -770,6 +771,7 @@ void lcd_buttons_update(void)
 			lcd_timeoutToStatus.start();
 			if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
 				buttonBlanking.start();
+		        safetyTimer.start();
 				if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
 				{
 					longPressTimer.start();

+ 198 - 7
Firmware/mmu.cpp

@@ -10,18 +10,32 @@
 
 
 extern const char* lcd_display_message_fullscreen_P(const char *msg);
+extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
+extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
 extern void lcd_return_to_status();
+extern void lcd_wait_for_heater();
+extern char choose_extruder_menu();
+
+
+#define MMU_TODELAY 100
+#define MMU_TIMEOUT 10
+
+#define MMU_HWRESET
+#define MMU_RST_PIN 76
 
-#define MMU_TIMEOUT 100
 
 bool mmu_enabled = false;
 
 uint8_t mmu_extruder = 0;
 
+uint8_t tmp_extruder = 0;
+
 int8_t mmu_finda = -1;
 
 int16_t mmu_version = -1;
 
+int16_t mmu_build = -1;
+
 
 //clear rx buffer
 void mmu_clr_rx_buf(void)
@@ -62,6 +76,8 @@ int8_t mmu_rx_start(void)
 //initialize mmu_unit
 bool mmu_init(void)
 {
+	digitalWrite(MMU_RST_PIN, HIGH);
+	pinMode(MMU_RST_PIN, OUTPUT);              //setup reset pin
 	uart2_init();                              //init uart2
 	_delay_ms(10);                             //wait 10ms for sure
 	if (mmu_reset())                           //reset mmu
@@ -75,20 +91,27 @@ bool mmu_init(void)
 
 bool mmu_reset(void)
 {
+#ifdef MMU_HWRESET
+	digitalWrite(MMU_RST_PIN, LOW);
+	_delay_us(100);
+	digitalWrite(MMU_RST_PIN, HIGH);
+#else
     mmu_puts_P(PSTR("X0\n"));                  //send command
-	unsigned char timeout = 10;                //timeout = 10x100ms
+#endif
+	unsigned char timeout = MMU_TIMEOUT;       //timeout = 10x100ms
 	while ((mmu_rx_start() <= 0) && (--timeout))
-		delay_keep_alive(MMU_TIMEOUT);
+		delay_keep_alive(MMU_TODELAY);
 	mmu_enabled = timeout?true:false;
+	mmu_enabled = true;
 	return mmu_enabled;
 }
 
 int8_t mmu_read_finda(void)
 {
     mmu_puts_P(PSTR("P0\n"));
-	unsigned char timeout = 10;                //10x100ms
+	unsigned char timeout = MMU_TIMEOUT;       //10x100ms
 	while ((mmu_rx_ok() <= 0) && (--timeout))
-		delay_keep_alive(MMU_TIMEOUT);
+		delay_keep_alive(MMU_TODELAY);
 	mmu_finda = -1;
 	if (timeout)
 		fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda);
@@ -98,14 +121,182 @@ int8_t mmu_read_finda(void)
 int16_t mmu_read_version(void)
 {
     mmu_puts_P(PSTR("S1\n"));
-	unsigned char timeout = 10;                //10x100ms
+	unsigned char timeout = MMU_TIMEOUT;       //10x100ms
 	while ((mmu_rx_ok() <= 0) && (--timeout))
-		delay_keep_alive(MMU_TIMEOUT);
+		delay_keep_alive(MMU_TODELAY);
 	if (timeout)
 		fscanf_P(uart2io, PSTR("%u"), &mmu_version);
 	return mmu_version;
 }
 
+int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament)
+{
+	printf_P(PSTR("MMU <= 'F%d %d'\n"), extruder, filament);
+	mmu_printf_P(PSTR("F%d %d\n"), extruder, filament);
+	unsigned char timeout = MMU_TIMEOUT;       //10x100ms
+	while ((mmu_rx_ok() <= 0) && (--timeout))
+		delay_keep_alive(MMU_TODELAY);
+	return timeout?1:0;
+}
+
+bool mmu_get_response(bool timeout)
+{
+	printf_P(PSTR("mmu_get_response - begin\n"));
+	//waits for "ok" from mmu
+	//function returns true if "ok" was received
+	//if timeout is set to true function return false if there is no "ok" received before timeout
+	bool response = true;
+	LongTimer mmu_get_reponse_timeout;
+	KEEPALIVE_STATE(IN_PROCESS);
+	mmu_get_reponse_timeout.start();
+	while (mmu_rx_ok() <= 0)
+	{
+		delay_keep_alive(100);
+		if (timeout && mmu_get_reponse_timeout.expired(5 * 60 * 1000ul))
+		{ //5 minutes timeout
+			response = false;
+			break;
+		}
+	}
+	printf_P(PSTR("mmu_get_response - end %d\n"), response?1:0);
+	return response;
+}
+
+
+void manage_response(bool move_axes, bool turn_off_nozzle)
+{
+	bool response = false;
+	mmu_print_saved = false;
+	bool lcd_update_was_enabled = false;
+	float hotend_temp_bckp = degTargetHotend(active_extruder);
+	float z_position_bckp = current_position[Z_AXIS];
+	float x_position_bckp = current_position[X_AXIS];
+	float y_position_bckp = current_position[Y_AXIS];	
+	while(!response)
+	{
+		  response = mmu_get_response(true); //wait for "ok" from mmu
+		  if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit
+			  if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater
+				  if (lcd_update_enabled) {
+					  lcd_update_was_enabled = true;
+					  lcd_update_enable(false);
+				  }
+				  st_synchronize();
+				  mmu_print_saved = true;
+				  
+				  hotend_temp_bckp = degTargetHotend(active_extruder);
+				  if (move_axes) {
+					  z_position_bckp = current_position[Z_AXIS];
+					  x_position_bckp = current_position[X_AXIS];
+					  y_position_bckp = current_position[Y_AXIS];
+				  
+					  //lift z
+					  current_position[Z_AXIS] += Z_PAUSE_LIFT;
+					  if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
+					  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
+					  st_synchronize();
+					  					  
+					  //Move XY to side
+					  current_position[X_AXIS] = X_PAUSE_POS;
+					  current_position[Y_AXIS] = Y_PAUSE_POS;
+					  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
+					  st_synchronize();
+				  }
+				  if (turn_off_nozzle) {
+					  //set nozzle target temperature to 0
+					  setAllTargetHotends(0);
+					  printf_P(PSTR("MMU not responding\n"));
+					  lcd_show_fullscreen_message_and_wait_P(_i("MMU needs user attention. Please press knob to resume nozzle target temperature."));
+					  setTargetHotend(hotend_temp_bckp, active_extruder);
+					  while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) {
+						  delay_keep_alive(1000);
+						  lcd_wait_for_heater();
+					  }
+				  }
+			  }
+			  lcd_display_message_fullscreen_P(_i("Check MMU. Fix the issue and then press button on MMU unit."));
+		  }
+		  else if (mmu_print_saved) {
+			  printf_P(PSTR("MMU start responding\n"));
+			  lcd_clear();
+			  lcd_display_message_fullscreen_P(_i("MMU OK. Resuming..."));
+			  if (move_axes) {
+				  current_position[X_AXIS] = x_position_bckp;
+				  current_position[Y_AXIS] = y_position_bckp;
+				  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
+				  st_synchronize();
+				  current_position[Z_AXIS] = z_position_bckp;
+				  plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
+				  st_synchronize();
+			  }
+			  else {
+				  delay_keep_alive(1000); //delay just for showing MMU OK message for a while in case that there are no xyz movements
+			  }
+		  }
+	}
+	if (lcd_update_was_enabled) lcd_update_enable(true);
+}
+
+void mmu_load_to_nozzle()
+{
+	st_synchronize();
+	
+	bool saved_e_relative_mode = axis_relative_modes[E_AXIS];
+	if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true;
+	current_position[E_AXIS] += 7.2f;
+    float feedrate = 562;
+	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
+    st_synchronize();
+	current_position[E_AXIS] += 14.4f;
+	feedrate = 871;
+	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
+    st_synchronize();
+	current_position[E_AXIS] += 36.0f;
+	feedrate = 1393;
+	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
+    st_synchronize();
+	current_position[E_AXIS] += 14.4f;
+	feedrate = 871;
+	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
+    st_synchronize();
+	if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = false;
+}
+
+void mmu_M600_load_filament(bool automatic)
+{ 
+	//load filament for mmu 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 = mmu_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);
+		  mmu_printf_P(PSTR("T%d\n"), tmp_extruder);
+
+		  manage_response(false, true);
+    	  mmu_extruder = tmp_extruder; //filament change is finished
+
+		  mmu_load_to_nozzle();
+
+		  st_synchronize();
+		  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], 2, active_extruder);
+}
+
+
 void extr_mov(float shift, float feed_rate)
 { //move extruder no matter what the current heater temperature is
 	set_extrude_min_temp(.0);

+ 13 - 0
Firmware/mmu.h

@@ -7,6 +7,8 @@ extern bool mmu_enabled;
 
 extern uint8_t mmu_extruder;
 
+extern uint8_t tmp_extruder;
+
 extern int8_t mmu_finda;
 
 extern int16_t mmu_version;
@@ -27,6 +29,17 @@ extern int8_t mmu_read_finda(void);
 
 extern int16_t mmu_read_version(void);
 
+extern int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament);
+
+
+extern bool mmu_get_response(bool timeout);
+
+extern void manage_response(bool move_axes, bool turn_off_nozzle);
+
+extern void mmu_load_to_nozzle();
+
+extern void mmu_M600_load_filament(bool automatic);
+
 
 extern void extr_mov(float shift, float feed_rate);
 extern void change_extr(int extr);

+ 12 - 1
Firmware/ultralcd.cpp

@@ -604,12 +604,13 @@ static void lcd_implementation_status_screen()
     //Print Feedrate
     lcd_set_cursor(LCD_WIDTH - 8-2, 1);
     lcd_puts_P(PSTR("  "));
+/*
 	if (maxlimit_status)
 	{
 		maxlimit_status = 0;
 		lcd_print('!');
 	}
-	else
+	else*/
 		lcd_print(LCD_STR_FEEDRATE[0]);
     lcd_print(itostr3(feedmultiply));
     lcd_puts_P(PSTR("%     "));
@@ -1954,6 +1955,9 @@ static void lcd_menu_extruder_info()
 	// Display Nozzle fan RPM
 	fan_speed_RPM[0] = 60*fan_speed[0];
 	fan_speed_RPM[1] = 60*fan_speed[1];
+
+	lcd_timeoutToStatus.stop(); //infinite timeout
+
 	lcd_printf_P(_N(
 	  ESC_H(0,0)
 	  "Nozzle FAN: %4d RPM\n"
@@ -2001,6 +2005,7 @@ static void lcd_menu_fails_stats_total()
 // Filam. runouts  000
 // Crash  X 000  Y 000
 //////////////////////
+	lcd_timeoutToStatus.stop(); //infinite timeout
     uint16_t power = eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT);
     uint16_t filam = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT);
     uint16_t crashX = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT);
@@ -2017,6 +2022,7 @@ static void lcd_menu_fails_stats_print()
 // Filam. runouts  000
 // Crash  X 000  Y 000
 //////////////////////
+	lcd_timeoutToStatus.stop(); //infinite timeout
     uint8_t power = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT);
     uint8_t filam = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT);
     uint8_t crashX = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X);
@@ -2057,6 +2063,7 @@ static void lcd_menu_fails_stats()
  */
 static void lcd_menu_fails_stats()
 {
+	lcd_timeoutToStatus.stop(); //infinite timeout
     uint8_t filamentLast = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT);
     uint16_t filamentTotal = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT);
     lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Filam. runouts  %-3d" ESC_H(0,2) "Total failures" ESC_H(1,3) "Filam. runouts  %-3d"), filamentLast, filamentTotal);
@@ -2065,6 +2072,7 @@ static void lcd_menu_fails_stats()
 #else
 static void lcd_menu_fails_stats()
 {
+	lcd_timeoutToStatus.stop(); //infinite timeout
 	MENU_BEGIN();
 	MENU_ITEM_BACK_P(_T(MSG_MAIN));
 	MENU_END();
@@ -2091,6 +2099,8 @@ static void lcd_menu_debug()
 
 static void lcd_menu_temperatures()
 {
+	lcd_timeoutToStatus.stop(); //infinite timeout
+
 	lcd_printf_P(PSTR(ESC_H(1,0) "Nozzle:   %d%c" ESC_H(1,1) "Bed:      %d%c"), (int)current_temperature[0], '\x01', (int)current_temperature_bed, '\x01');
 #ifdef AMBIENT_THERMISTOR
 	lcd_printf_P(PSTR(ESC_H(1,2) "Ambient:  %d%c" ESC_H(1,3) "PINDA:    %d%c"), (int)current_temperature_ambient, '\x01', (int)current_temperature_pinda, '\x01');
@@ -2108,6 +2118,7 @@ static void lcd_menu_temperatures()
 #define VOLT_DIV_REF 5
 static void lcd_menu_voltages()
 {
+	lcd_timeoutToStatus.stop(); //infinite timeout
 	float volt_pwr = VOLT_DIV_REF * ((float)current_voltage_raw_pwr / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
 //	float volt_bed = VOLT_DIV_REF * ((float)current_voltage_raw_bed / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
 //	lcd_printf_P(PSTR(ESC_H(1,1)"PWR:      %d.%01dV" ESC_H(1,2)"BED:      %d.%01dV"), (int)volt_pwr, (int)(10*fabs(volt_pwr - (int)volt_pwr)), (int)volt_bed, (int)(10*fabs(volt_bed - (int)volt_bed)));