Bläddra i källkod

unknown filament added; the same T-code will be not executed twice in a row; continue loading

PavelSindler 6 år sedan
förälder
incheckning
c256af0a1c
4 ändrade filer med 43 tillägg och 19 borttagningar
  1. 10 10
      Firmware/Marlin_main.cpp
  2. 23 6
      Firmware/mmu.cpp
  3. 2 0
      Firmware/mmu.h
  4. 8 3
      Firmware/ultralcd.cpp

+ 10 - 10
Firmware/Marlin_main.cpp

@@ -6875,6 +6875,10 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
 		if (mmu_enabled)
 		{
 			tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT));
+			if (tmp_extruder == mmu_extruder) {
+				printf_P(PSTR("Duplicit T-code ignored.\n"));
+				return; //dont execute the same T-code twice in a row
+			}
 			st_synchronize();
 			mmu_command(MMU_CMD_T0 + tmp_extruder);
 			manage_response(true, true);
@@ -6884,7 +6888,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
 	  	if (mmu_enabled) 
 		{
 			st_synchronize();
-			mmu_command(MMU_CMD_C0);
+			mmu_continue_loading();
 			mmu_extruder = tmp_extruder; //filament change is finished
 			mmu_load_to_nozzle();
 		}
@@ -6909,18 +6913,14 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
 
           if (mmu_enabled)
           {
+              if (tmp_extruder == mmu_extruder) {
+                  printf_P(PSTR("Duplicit T-code ignored.\n"));
+                  return; //dont execute the same T-code twice in a row
+              }
               mmu_command(MMU_CMD_T0 + tmp_extruder);
 
               manage_response(true, true);
-#ifdef MMU_IDLER_SENSOR_PIN
-			  for (int i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) {
-				  if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) break;		
-				  mmu_command(MMU_CMD_C0);
-				  manage_response(true, true);
-			  }
-#else 
-			  mmu_command(MMU_CMD_C0);
-#endif //MMU_IDLER_SENSOR_PIN
+			  mmu_continue_loading();
 			  mmu_extruder = tmp_extruder; //filament change is finished
 
               if (load_to_nozzle)// for single material usage with mmu

+ 23 - 6
Firmware/mmu.cpp

@@ -42,10 +42,10 @@ uint8_t mmu_cmd = 0;
 uint8_t mmu_idl_sens = 0;
 #endif //MMU_IDLER_SENSOR_PIN
 
-uint8_t mmu_extruder = 0;
+uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN;
 
 //! This variable probably has no meaning and is planed to be removed
-uint8_t tmp_extruder = 0;
+uint8_t tmp_extruder = MMU_FILAMENT_UNKNOWN;
 
 int8_t mmu_finda = -1;
 
@@ -307,7 +307,7 @@ void mmu_loop(void)
 			if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0)
 			{
 #ifdef MMU_DEBUG
-				printf_P(PSTR("MMU <= 'A'\n"), mmu_finda);
+				printf_P(PSTR("MMU <= 'A'\n"));
 #endif //MMU_DEBUG  
 				mmu_puts_P(PSTR("A\n")); //send 'abort' request
 				mmu_idl_sens = 0;
@@ -619,7 +619,7 @@ void mmu_M600_load_filament(bool automatic)
 		  mmu_command(MMU_CMD_T0 + tmp_extruder);
 
 		  manage_response(false, true);
-		  mmu_command(MMU_CMD_C0);
+		  mmu_continue_loading();
     	  mmu_extruder = tmp_extruder; //filament change is finished
 		  mmu_load_to_nozzle();
 		  load_filament_final_feed();
@@ -822,7 +822,8 @@ void extr_unload()
 		lcd_clear();
 		lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
 		lcd_print(" ");
-		lcd_print(mmu_extruder + 1);
+		if (mmu_extruder == MMU_FILAMENT_UNKNOWN) lcd_print("?");
+		else lcd_print(mmu_extruder + 1);
 
 		filament_ramming();
 
@@ -1125,7 +1126,7 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr)
 	lcd_print(tmp_extruder + 1);
 	mmu_command(MMU_CMD_T0 + tmp_extruder);
 	manage_response(true, true);
-	mmu_command(MMU_CMD_C0);
+	mmu_continue_loading();
 	mmu_extruder = tmp_extruder; //filament change is finished
 	mmu_load_to_nozzle();
 	load_filament_final_feed();
@@ -1181,3 +1182,19 @@ void mmu_eject_filament(uint8_t filament, bool recover)
 		puts_P(PSTR("Filament nr out of range!"));
 	}
 }
+
+void mmu_continue_loading() 
+{
+#ifdef MMU_IDLER_SENSOR_PIN
+			  for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) {
+#ifdef MMU_DEBUG
+				  printf_P(PSTR("Additional load attempt nr. %d\n"), i);
+#endif // MMU_DEBUG
+				  if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) break;		
+				  mmu_command(MMU_CMD_C0);
+				  manage_response(true, true);
+			  }
+#else 
+			  mmu_command(MMU_CMD_C0);
+#endif //MMU_IDLER_SENSOR_PIN
+}

+ 2 - 0
Firmware/mmu.h

@@ -14,6 +14,7 @@ extern int8_t mmu_finda;
 extern int16_t mmu_version;
 extern int16_t mmu_buildnr;
 
+#define MMU_FILAMENT_UNKNOWN 255
 
 #define MMU_CMD_NONE 0
 #define MMU_CMD_T0   0x10
@@ -103,3 +104,4 @@ extern void mmu_eject_fil_1();
 extern void mmu_eject_fil_2();
 extern void mmu_eject_fil_3();
 extern void mmu_eject_fil_4();
+extern void mmu_continue_loading();

+ 8 - 3
Firmware/ultralcd.cpp

@@ -537,10 +537,15 @@ void lcdui_print_percent_done(void)
 void lcdui_print_extruder(void)
 {
 	int chars = 0;
-	if (mmu_extruder == tmp_extruder)
-		chars = lcd_printf_P(_N(" F%u"), mmu_extruder+1);
+	if (mmu_extruder == tmp_extruder) {
+		if (mmu_extruder == MMU_FILAMENT_UNKNOWN) chars = lcd_printf_P(_N(" F?"));
+		else chars = lcd_printf_P(_N(" F%u"), mmu_extruder + 1);
+	}
 	else
-		chars = lcd_printf_P(_N(" %u>%u"), mmu_extruder+1, tmp_extruder+1);
+	{
+		if (mmu_extruder == MMU_FILAMENT_UNKNOWN) chars = lcd_printf_P(_N(" ?>%u"), tmp_extruder + 1);
+		else chars = lcd_printf_P(_N(" %u>%u"), mmu_extruder + 1, tmp_extruder + 1);
+	}
 	lcd_space(5 - chars);
 }