Browse Source

Merge remote-tracking branch 'upstream/MK3' into 7x7

PavelSindler 5 years ago
parent
commit
b20d9171b6
9 changed files with 104 additions and 84 deletions
  1. 1 1
      Firmware/Marlin.h
  2. 49 38
      Firmware/Marlin_main.cpp
  3. 2 2
      Firmware/fsensor.cpp
  4. 1 0
      Firmware/messages.c
  5. 1 0
      Firmware/messages.h
  6. 37 31
      Firmware/mmu.cpp
  7. 1 1
      Firmware/mmu.h
  8. 11 11
      Firmware/ultralcd.cpp
  9. 1 0
      Firmware/ultralcd.h

+ 1 - 1
Firmware/Marlin.h

@@ -495,5 +495,5 @@ void proc_commands();
 void M600_load_filament();
 void M600_load_filament_movements();
 void M600_wait_for_user(float HotendTempBckp);
-void M600_check_state();
+void M600_check_state(float nozzle_temp);
 void load_filament_final_feed();

+ 49 - 38
Firmware/Marlin_main.cpp

@@ -3057,12 +3057,12 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
                 manage_response(false, false);
             }
         }
-        mmu_M600_load_filament(automatic);
+        mmu_M600_load_filament(automatic, HotendTempBckp);
     }
     else
         M600_load_filament();
 
-    if (!automatic) M600_check_state();
+    if (!automatic) M600_check_state(HotendTempBckp);
 
 		lcd_update_enable(true);
 
@@ -3480,11 +3480,6 @@ void process_commands()
 	}
 #endif //BACKLASH_Y
 #endif //TMC2130
-#ifdef FILAMENT_SENSOR
-	else if (code_seen("FSENSOR_RECOVER")) { //! FSENSOR_RECOVER
-		fsensor_restore_print_and_continue();
-  }
-#endif //FILAMENT_SENSOR
   else if(code_seen("PRUSA")){
 		if (code_seen("Ping")) {  //! PRUSA Ping
 			if (farm_mode) {
@@ -3515,6 +3510,12 @@ void process_commands()
                eeprom_update_byte((uint8_t*)EEPROM_UVLO,0); 
                enquecommand_P(PSTR("M24")); 
 		}	
+#ifdef FILAMENT_SENSOR
+		else if (code_seen("fsensor_recover")) //! PRUSA fsensor_recover
+		{
+               fsensor_restore_print_and_continue();
+		}	
+#endif //FILAMENT_SENSOR
 		else if (code_seen("MMURES")) //! PRUSA MMURES
 		{
 			mmu_reset();
@@ -7597,11 +7598,18 @@ static void handleSafetyTimer()
 
 void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h
 {
+bool bInhibitFlag;
 #ifdef FILAMENT_SENSOR
 	if (mmu_enabled == false)
 	{
 //-//		if (mcode_in_progress != 600) //M600 not in progress
-          if ((mcode_in_progress != 600) && (eFilamentAction != e_FILAMENT_ACTION_autoLoad) && (menu_menu!=lcd_menu_extruder_info)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo menu not active
+#ifdef PAT9125
+          bInhibitFlag=(menu_menu==lcd_menu_extruder_info); // Support::ExtruderInfo menu active
+#endif // PAT9125
+#ifdef IR_SENSOR
+          bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active
+#endif // IR_SENSOR
+          if ((mcode_in_progress != 600) && (eFilamentAction != e_FILAMENT_ACTION_autoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active
 		{
 			if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL) && !wizard_active)
 			{
@@ -9385,38 +9393,41 @@ void load_filament_final_feed()
 	plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED_FINAL, active_extruder);
 }
 
-void M600_check_state()
+//! @brief Wait for user to check the state
+//! @par nozzle_temp nozzle temperature to load filament
+void M600_check_state(float nozzle_temp)
 {
-		//Wait for user to check the state
-		lcd_change_fil_state = 0;
-		while (lcd_change_fil_state != 1){
-			lcd_change_fil_state = 0;
-			KEEPALIVE_STATE(PAUSED_FOR_USER);
-			lcd_alright();
-			KEEPALIVE_STATE(IN_HANDLER);
-			switch(lcd_change_fil_state){
-				// Filament failed to load so load it again
-				case 2:
-					if (mmu_enabled)
-						mmu_M600_load_filament(false); //nonautomatic load; change to "wrong filament loaded" option?
-					else
-						M600_load_filament_movements();
-					break;
+    lcd_change_fil_state = 0;
+    while (lcd_change_fil_state != 1)
+    {
+        lcd_change_fil_state = 0;
+        KEEPALIVE_STATE(PAUSED_FOR_USER);
+        lcd_alright();
+        KEEPALIVE_STATE(IN_HANDLER);
+        switch(lcd_change_fil_state)
+        {
+        // Filament failed to load so load it again
+        case 2:
+            if (mmu_enabled)
+                mmu_M600_load_filament(false, nozzle_temp); //nonautomatic load; change to "wrong filament loaded" option?
+            else
+                M600_load_filament_movements();
+            break;
 
-				// Filament loaded properly but color is not clear
-				case 3:
-					st_synchronize();
-					load_filament_final_feed();
-					lcd_loading_color();
-					st_synchronize();
-					break;
-                 
-				// Everything good             
-				default:
-					lcd_change_success();
-					break;
-			}
-		}
+        // Filament loaded properly but color is not clear
+        case 3:
+            st_synchronize();
+            load_filament_final_feed();
+            lcd_loading_color();
+            st_synchronize();
+            break;
+
+        // Everything good
+        default:
+            lcd_change_success();
+            break;
+        }
+    }
 }
 
 //! @brief Wait for user action

+ 2 - 2
Firmware/fsensor.cpp

@@ -567,7 +567,7 @@ void fsensor_update(void)
 				printf_P(PSTR("fsensor_update - M600\n"));
 				eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
 				eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
-				enquecommand_front_P(PSTR("FSENSOR_RECOVER"));
+				enquecommand_front_P(PSTR("PRUSA fsensor_recover"));
 				enquecommand_front_P((PSTR("M600")));
 				fsensor_watch_runout = false;
 			}
@@ -581,7 +581,7 @@ void fsensor_update(void)
 			printf_P(PSTR("fsensor_update - M600\n"));
 			eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
 			eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
-			enquecommand_front_P(PSTR("FSENSOR_RECOVER"));
+			enquecommand_front_P(PSTR("PRUSA fsensor_recover"));
 			enquecommand_front_P((PSTR("M600")));
 		}
 #endif //PAT9125

+ 1 - 0
Firmware/messages.c

@@ -52,6 +52,7 @@ const char MSG_LOAD_FILAMENT[] PROGMEM_I1 = ISTR("Load filament"); ////c=17 r=0
 const char MSG_LOADING_FILAMENT[] PROGMEM_I1 = ISTR("Loading filament"); ////c=20 r=0
 const char MSG_M117_V2_CALIBRATION[] PROGMEM_I1 = ISTR("M117 First layer cal."); ////c=25 r=1
 const char MSG_MAIN[] PROGMEM_I1 = ISTR("Main"); ////c=0 r=0
+const char MSG_BACK[] PROGMEM_I1 = ISTR("Back"); ////c=0 r=0
 const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1[] PROGMEM_I1 = ISTR("Measuring reference height of calibration point"); ////c=60 r=0
 const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2[] PROGMEM_I1 = ISTR(" of 9"); ////c=14 r=0
 const char MSG_MENU_CALIBRATION[] PROGMEM_I1 = ISTR("Calibration"); ////c=0 r=0

+ 1 - 0
Firmware/messages.h

@@ -53,6 +53,7 @@ extern const char MSG_LOAD_FILAMENT[];
 extern const char MSG_LOADING_FILAMENT[];
 extern const char MSG_M117_V2_CALIBRATION[];
 extern const char MSG_MAIN[];
+extern const char MSG_BACK[];
 extern const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1[];
 extern const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2[];
 extern const char MSG_MENU_CALIBRATION[];

+ 37 - 31
Firmware/mmu.cpp

@@ -374,7 +374,7 @@ void mmu_loop(void)
 			//printf_P(PSTR("Eact: %d\n"), int(e_active()));
 			if (!mmu_finda && CHECK_FSENSOR && fsensor_enabled) {
 				fsensor_stop_and_save_print();
-				enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
+				enquecommand_front_P(PSTR("PRUSA fsensor_recover")); //then recover
 				ad_markDepleted(mmu_extruder);
 				if (lcd_autoDepleteEnabled() && !ad_allDepleted())
 				{
@@ -849,37 +849,43 @@ void mmu_M600_wait_and_beep() {
 		WRITE(BEEPER, LOW);
 }
 
-void mmu_M600_load_filament(bool automatic)
+//! @brief load filament for mmu v2
+//! @par nozzle_temp nozzle temperature to load filament
+void mmu_M600_load_filament(bool automatic, float nozzle_temp)
 { 
-	//load filament for mmu v2
-		  tmp_extruder = mmu_extruder;
-		  if (!automatic) {
-#ifdef MMU_M600_SWITCH_EXTRUDER
-		      bool 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();
-#endif //MMU_M600_SWITCH_EXTRUDER
-		  }
-		  else {
-			  tmp_extruder = ad_getAlternative(tmp_extruder);
-		  }
-		  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);
-		  mmu_command(MmuCmd::T0 + tmp_extruder);
-
-		  manage_response(false, true, MMU_LOAD_MOVE);
-		  mmu_continue_loading();
-    	  mmu_extruder = tmp_extruder; //filament change is finished
-		  
-		  mmu_load_to_nozzle();
-		  load_filament_final_feed();
-		  st_synchronize();
+    tmp_extruder = mmu_extruder;
+    if (!automatic)
+    {
+    #ifdef MMU_M600_SWITCH_EXTRUDER
+        bool 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();
+    #endif //MMU_M600_SWITCH_EXTRUDER
+    }
+    else
+    {
+        tmp_extruder = ad_getAlternative(tmp_extruder);
+    }
+    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);
+    setTargetHotend(nozzle_temp,active_extruder);
+    mmu_wait_for_heater_blocking();
+
+    mmu_command(MmuCmd::T0 + tmp_extruder);
+
+    manage_response(false, true, MMU_LOAD_MOVE);
+    mmu_continue_loading();
+    mmu_extruder = tmp_extruder; //filament change is finished
+
+    mmu_load_to_nozzle();
+    load_filament_final_feed();
+    st_synchronize();
 }
 
 

+ 1 - 1
Firmware/mmu.h

@@ -97,7 +97,7 @@ extern void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move =
 
 extern void mmu_load_to_nozzle();
 
-extern void mmu_M600_load_filament(bool automatic);
+extern void mmu_M600_load_filament(bool automatic, float nozzle_temp);
 extern void mmu_M600_wait_and_beep();
 
 extern void extr_mov(float shift, float feed_rate);

+ 11 - 11
Firmware/ultralcd.cpp

@@ -133,14 +133,14 @@ static void prusa_stat_farm_number();
 static void prusa_stat_temperatures();
 static void prusa_stat_printinfo();
 static void lcd_farm_no();
-void lcd_menu_extruder_info();                    // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
+//static void lcd_menu_extruder_info();           // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
 static void lcd_menu_xyz_y_min();
 static void lcd_menu_xyz_skew();
 static void lcd_menu_xyz_offset();
 static void lcd_menu_fails_stats_mmu();
 static void lcd_menu_fails_stats_mmu_print();
 static void lcd_menu_fails_stats_mmu_total();
-static void lcd_menu_show_sensors_state();
+//static void lcd_menu_show_sensors_state();      // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
 
 static void mmu_fil_eject_menu();
 static void mmu_load_to_nozzle_menu();
@@ -4059,7 +4059,7 @@ static void lcd_show_sensors_state()
 	lcd_print_state(idler_state);
 }
 
-static void lcd_menu_show_sensors_state()
+void lcd_menu_show_sensors_state()                // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
 {
 	lcd_timeoutToStatus.stop();
 	lcd_show_sensors_state();
@@ -4539,6 +4539,7 @@ static void lcd_silent_mode_set() {
 	}
   eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu);
 #ifdef TMC2130
+  lcd_display_message_fullscreen_P(_i("Mode change in progress ..."));
   // Wait until the planner queue is drained and the stepper routine achieves
   // an idle state.
   st_synchronize();
@@ -4559,6 +4560,7 @@ static void lcd_silent_mode_set() {
 #ifdef TMC2130
   if (CrashDetectMenu && (SilentModeMenu != SILENT_MODE_NORMAL))
 	  menu_submenu(lcd_crash_mode_info2);
+  lcd_encoder_diff=0;                             // reset 'encoder buffer'
 #endif //TMC2130
 }
 
@@ -5331,9 +5333,9 @@ do\
         EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));\
         switch (sdSort)\
         {\
-          case SD_SORT_TIME: MENU_ITEM_FUNCTION_P(_i("Sort:      [time]"), lcd_sort_type_set); break;/*////MSG_SORT_TIME c=17 r=1*/\
-          case SD_SORT_ALPHA: MENU_ITEM_FUNCTION_P(_i("Sort:  [alphabet]"), lcd_sort_type_set); break;/*////MSG_SORT_ALPHA c=17 r=1*/\
-          default: MENU_ITEM_FUNCTION_P(_i("Sort:      [none]"), lcd_sort_type_set);/*////MSG_SORT_NONE c=17 r=1*/\
+          case SD_SORT_TIME: MENU_ITEM_FUNCTION_P(_i("Sort       [time]"), lcd_sort_type_set); break;/*////MSG_SORT_TIME c=17 r=1*/\
+          case SD_SORT_ALPHA: MENU_ITEM_FUNCTION_P(_i("Sort   [alphabet]"), lcd_sort_type_set); break;/*////MSG_SORT_ALPHA c=17 r=1*/\
+          default: MENU_ITEM_FUNCTION_P(_i("Sort       [none]"), lcd_sort_type_set);/*////MSG_SORT_NONE c=17 r=1*/\
         }\
     }\
 }\
@@ -6830,10 +6832,7 @@ void lcd_sdcard_menu()
 
 
   MENU_BEGIN();
-  if(bMain)                                       // i.e. default menu-item
-    MENU_ITEM_BACK_P(_T(MSG_MAIN));
-  else                                            // i.e. menu-item after card insertion
-    MENU_ITEM_FUNCTION_P(_T(MSG_WATCH),lcd_return_to_status);
+  MENU_ITEM_BACK_P(_T(bMain?MSG_MAIN:MSG_BACK));  // i.e. default menu-item / menu-item after card insertion
   card.getWorkDirName();
   if (card.filename[0] == '/')
   {
@@ -8254,6 +8253,8 @@ void menu_lcd_lcdupdate_func(void)
 		}
 		else
 		{
+               if(menu_menu==lcd_sdcard_menu)
+                    menu_back();
 			card.release();
 			LCD_MESSAGERPGM(_i("Card removed"));////MSG_SD_REMOVED c=0 r=0
 		}
@@ -8298,4 +8299,3 @@ void menu_lcd_lcdupdate_func(void)
 	lcd_send_status();
 	if (lcd_commands_type == LCD_COMMAND_V2_CAL) lcd_commands();
 }
-

+ 1 - 0
Firmware/ultralcd.h

@@ -46,6 +46,7 @@ extern bool lcd_selftest();
 void lcd_menu_statistics(); 
 
 void lcd_menu_extruder_info();                    // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
+void lcd_menu_show_sensors_state();               // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
 
 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);