瀏覽代碼

finda runout sensor can be turned on/off from menu

PavelSindler 6 年之前
父節點
當前提交
03fffae4c3
共有 4 個文件被更改,包括 110 次插入75 次删除
  1. 45 36
      Firmware/Marlin_main.cpp
  2. 1 1
      Firmware/mmu.cpp
  3. 19 7
      Firmware/stepper.cpp
  4. 45 31
      Firmware/ultralcd.cpp

+ 45 - 36
Firmware/Marlin_main.cpp

@@ -1962,8 +1962,8 @@ void loop()
   checkHitEndstops();
   lcd_update(0);
 #ifdef FILAMENT_SENSOR
-	if (mcode_in_progress != 600) //M600 not in progress
-		fsensor_update();
+  if (mcode_in_progress != 600 && !mmu_enabled) //M600 not in progress
+	  fsensor_update();
 #endif //FILAMENT_SENSOR
 #ifdef TMC2130
 	tmc2130_check_overtemp();
@@ -3170,7 +3170,10 @@ void gcode_M701()
 		custom_message_type = CUSTOM_MSG_TYPE_F_LOAD;
 
 #ifdef FILAMENT_SENSOR
-		fsensor_oq_meassure_start(40);
+		if (mmu_enabled == false)
+		{
+			fsensor_oq_meassure_start(40);
+		}
 #endif //FILAMENT_SENSOR
 
 		lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT));
@@ -3212,15 +3215,18 @@ void gcode_M701()
 		custom_message_type = CUSTOM_MSG_TYPE_STATUS;
 
 #ifdef FILAMENT_SENSOR
-		fsensor_oq_meassure_stop();
-
-		if (!fsensor_oq_result())
+		if (mmu_enabled == false) 
 		{
-			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();
+			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
 	}
@@ -7303,38 +7309,41 @@ static void handleSafetyTimer()
 void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h
 {
 #ifdef FILAMENT_SENSOR
-	if (mcode_in_progress != 600) //M600 not in progress
+	if (mmu_enabled == false)
 	{
-		if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
+		if (mcode_in_progress != 600) //M600 not in progress
 		{
-			if (fsensor_check_autoload())
+			if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
 			{
-				fsensor_autoload_check_stop();
-				if (degHotend0() > EXTRUDE_MINTEMP)
+				if (fsensor_check_autoload())
 				{
-if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
-					tone(BEEPER, 1000);
-					delay_keep_alive(50);
-					noTone(BEEPER);
-					loading_flag = true;
-					enquecommand_front_P((PSTR("M701")));
-				}
-				else
-				{
-					lcd_update_enable(false);
-					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_update_enable(true);
+					fsensor_autoload_check_stop();
+					if (degHotend0() > EXTRUDE_MINTEMP)
+					{
+						if ((eSoundMode == e_SOUND_MODE_LOUD) || (eSoundMode == e_SOUND_MODE_ONCE))
+							tone(BEEPER, 1000);
+						delay_keep_alive(50);
+						noTone(BEEPER);
+						loading_flag = true;
+						enquecommand_front_P((PSTR("M701")));
+					}
+					else
+					{
+						lcd_update_enable(false);
+						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_update_enable(true);
+					}
 				}
 			}
+			else
+				fsensor_autoload_check_stop();
 		}
-		else
-			fsensor_autoload_check_stop();
 	}
 #endif //FILAMENT_SENSOR
 

+ 1 - 1
Firmware/mmu.cpp

@@ -198,7 +198,7 @@ void mmu_loop(void)
 			fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
 			printf_P(PSTR("MMU => '%dok'\n"), mmu_finda);
 			//printf_P(PSTR("Eact: %d\n"), int(e_active()));
-			if (!mmu_finda && CHECK_FINDA) {
+			if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
 				fsensor_stop_and_save_print();
 				enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
 				enquecommand_front_P(PSTR("M600")); //save print and run M600 command

+ 19 - 7
Firmware/stepper.cpp

@@ -41,6 +41,8 @@
 int fsensor_counter = 0; //counter for e-steps
 #endif //FILAMENT_SENSOR
 
+#include "mmu.h"
+
 #ifdef DEBUG_STACK_MONITOR
 uint16_t SP_min = 0x21FF;
 #endif //DEBUG_STACK_MONITOR
@@ -470,8 +472,11 @@ FORCE_INLINE void stepper_next_block()
 #endif
 
 #ifdef FILAMENT_SENSOR
-    fsensor_counter = 0;
-    fsensor_st_block_begin(current_block);
+	if (mmu_enabled == false)
+	{
+		fsensor_counter = 0;
+		fsensor_st_block_begin(current_block);
+	}
 #endif //FILAMENT_SENSOR
     // The busy flag is set by the plan_get_current_block() call.
     // current_block->busy = true;
@@ -901,7 +906,10 @@ FORCE_INLINE void isr() {
         if (step_loops < estep_loops)
           estep_loops = step_loops;
     #ifdef FILAMENT_SENSOR
-        fsensor_counter += estep_loops;
+		if (mmu_enabled == false)
+		{
+			fsensor_counter += estep_loops;
+		}
     #endif //FILAMENT_SENSOR
         do {
           WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
@@ -1027,7 +1035,9 @@ FORCE_INLINE void isr() {
         // There is not enough time to fit even a single additional tick.
         // Tick all the extruder ticks now.
     #ifdef FILAMENT_SENSOR
-        fsensor_counter += e_steps;
+		  if (mmu_enabled == false) {
+			  fsensor_counter += e_steps;
+		  }
     #endif //FILAMENT_SENSOR
         MSerial.checkRx(); // Check for serial chars.
         do {
@@ -1049,15 +1059,17 @@ FORCE_INLINE void isr() {
     // If current block is finished, reset pointer
     if (step_events_completed.wide >= current_block->step_event_count.wide) {
 #ifdef FILAMENT_SENSOR
-      fsensor_st_block_chunk(current_block, fsensor_counter);
-	    fsensor_counter = 0;
+		if (mmu_enabled == false) {
+			fsensor_st_block_chunk(current_block, fsensor_counter);
+			fsensor_counter = 0;
+		}
 #endif //FILAMENT_SENSOR
 
       current_block = NULL;
       plan_discard_current_block();
     }
 #ifdef FILAMENT_SENSOR
-  	else if (fsensor_counter >= fsensor_chunk_len)
+  	else if ((fsensor_counter >= fsensor_chunk_len) && (mmu_enabled == false))
   	{
       fsensor_st_block_chunk(current_block, fsensor_counter);
   	  fsensor_counter = 0;

+ 45 - 31
Firmware/ultralcd.cpp

@@ -1882,20 +1882,22 @@ static void lcd_menu_extruder_info()
     //  Shutter register is an index of LASER shutter time. It is automatically controlled by the chip's internal
     //  auto-exposure algorithm. When the chip is tracking on a good reflection surface, the Shutter is small.
     //  When the chip is tracking on a poor reflection surface, the Shutter is large. Value ranges from 0 to 46.
-
-	if (!fsensor_enabled)
-		lcd_puts_P(_N("Filament sensor\n" "is disabled."));
-	else
+	if (mmu_enabled == false)
 	{
-		if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
-			pat9125_update();
-		lcd_printf_P(_N(
-		  "Fil. Xd:%3d Yd:%3d\n"
-		  "Int: %3d  Shut: %3d"
-		 ),
-		 pat9125_x, pat9125_y,
-		 pat9125_b, pat9125_s
-		);
+		if (!fsensor_enabled)
+			lcd_puts_P(_N("Filament sensor\n" "is disabled."));
+		else
+		{
+			if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
+				pat9125_update();
+			lcd_printf_P(_N(
+				"Fil. Xd:%3d Yd:%3d\n"
+				"Int: %3d  Shut: %3d"
+			),
+				pat9125_x, pat9125_y,
+				pat9125_b, pat9125_s
+			);
+		}
 	}
 #endif //FILAMENT_SENSOR
     
@@ -4040,15 +4042,16 @@ static void lcd_crash_mode_set()
 static void lcd_fsensor_state_set()
 {
 	FSensorStateMenu = !FSensorStateMenu; //set also from fsensor_enable() and fsensor_disable()
-    if (!FSensorStateMenu) {
-        fsensor_disable();
-        if (fsensor_autoload_enabled)
-            menu_submenu(lcd_filament_autoload_info);
-    }else{
-        fsensor_enable();
-        if (fsensor_not_responding)
-            menu_submenu(lcd_fsensor_fail);
-    }
+	if (!FSensorStateMenu) {
+		fsensor_disable();
+		if (fsensor_autoload_enabled && !mmu_enabled)
+			menu_submenu(lcd_filament_autoload_info);
+	}
+	else {
+		fsensor_enable();
+		if (fsensor_not_responding && !mmu_enabled)
+			menu_submenu(lcd_fsensor_fail);
+	}
 }
 #endif //FILAMENT_SENSOR
 
@@ -4546,17 +4549,23 @@ static void lcd_settings_menu()
 		{
 			// Filament sensor turned off, working, no problems
 			MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set);
-			MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);
+			if (mmu_enabled == false)
+			{
+				MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);
+			}
 		}
 	}
 	else
 	{
 		// Filament sensor turned on, working, no problems
 		MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_ON), lcd_fsensor_state_set);
-		if (fsensor_autoload_enabled)
-			MENU_ITEM_FUNCTION_P(_i("F. autoload  [on]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_ON c=17 r=1
-		else
-			MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_OFF c=17 r=1
+		if (mmu_enabled == false)
+		{
+			if (fsensor_autoload_enabled)
+				MENU_ITEM_FUNCTION_P(_i("F. autoload  [on]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_ON c=17 r=1
+			else
+				MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_OFF c=17 r=1
+		}
 	}
 #endif //FILAMENT_SENSOR
 
@@ -5558,7 +5567,7 @@ static void lcd_main_menu()
 	else
 	{
 #ifdef FILAMENT_SENSOR
-		if ( ((fsensor_autoload_enabled == true) && (fsensor_enabled == true)))
+		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
 		else
 #endif //FILAMENT_SENSOR
@@ -6079,14 +6088,19 @@ bool lcd_selftest()
 	{
 		_progress = lcd_selftest_screen(8, _progress, 3, true, 2000); //bed ok
 #ifdef FILAMENT_SENSOR
-		_progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor
-		_result = lcd_selftest_fsensor();
+		if (mmu_enabled == false) {
+			_progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor
+			_result = lcd_selftest_fsensor();
+		}
 #endif // FILAMENT_SENSOR
 	}
 	if (_result)
 	{
 #ifdef FILAMENT_SENSOR
-		_progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK
+		if (mmu_enabled == false)
+		{
+			_progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK
+		}
 #endif // FILAMENT_SENSOR
 		_progress = lcd_selftest_screen(11, _progress, 3, true, 5000); //all correct
 	}