Jelajahi Sumber

mmu2: filament senor (FINDA) can be switched ON/OFF from menu without dependency on pat9125 state

PavelSindler 5 tahun lalu
induk
melakukan
a6a81c6ea6
2 mengubah file dengan 24 tambahan dan 17 penghapusan
  1. 22 15
      Firmware/fsensor.cpp
  2. 2 2
      Firmware/ultralcd.cpp

+ 22 - 15
Firmware/fsensor.cpp

@@ -7,6 +7,7 @@
 #include "planner.h"
 #include "fastio.h"
 #include "cmdqueue.h"
+#include "mmu.h"
 
 //Basic params
 #define FSENSOR_CHUNK_LEN    0.64F  //filament sensor chunk length 0.64mm
@@ -136,21 +137,27 @@ void fsensor_init(void)
 
 bool fsensor_enable(void)
 {
-	uint8_t pat9125 = pat9125_init();
-    printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125);
-	if (pat9125)
-		fsensor_not_responding = false;
-	else
-		fsensor_not_responding = true;
-	fsensor_enabled = pat9125?true:false;
-	fsensor_watch_runout = true;
-	fsensor_oq_meassure = false;
-	fsensor_err_cnt = 0;
-	fsensor_dy_old = 0;
-	eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled?0x01:0x00); 
-	FSensorStateMenu = fsensor_enabled?1:0;
-
-
+	if (mmu_enabled == false) { //filament sensor is pat9125, enable only if it is working
+		uint8_t pat9125 = pat9125_init();
+		printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125);
+		if (pat9125)
+			fsensor_not_responding = false;
+		else
+			fsensor_not_responding = true;
+		fsensor_enabled = pat9125 ? true : false;
+		fsensor_watch_runout = true;
+		fsensor_oq_meassure = false;
+		fsensor_err_cnt = 0;
+		fsensor_dy_old = 0;
+		eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled ? 0x01 : 0x00);
+		FSensorStateMenu = fsensor_enabled ? 1 : 0;
+	}
+	else //filament sensor is FINDA, always enable 
+	{
+		fsensor_enabled = true;
+		eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x01);
+		FSensorStateMenu = 1;
+	}
 	return fsensor_enabled;
 }
 

+ 2 - 2
Firmware/ultralcd.cpp

@@ -4574,7 +4574,7 @@ do\
 {\
     if (FSensorStateMenu == 0)\
     {\
-        if (fsensor_not_responding)\
+        if (fsensor_not_responding && (mmu_enabled == false))\
         {\
             /* Filament sensor not working*/\
             MENU_ITEM_FUNCTION_P(_i("Fil. sensor [N/A]"), lcd_fsensor_state_set);/*////MSG_FSENSOR_NA c=0 r=0*/\
@@ -4584,7 +4584,7 @@ do\
         {\
             /* Filament sensor turned off, working, no problems*/\
             MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set);\
-            if (mmu_enabled == false)if (mmu_enabled == false)\
+            if (mmu_enabled == false)\
             {\
                 MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);\
             }\