Browse Source

Simplify altfan override initialization

Yuri D'Elia 1 year ago
parent
commit
da6e56a17e
2 changed files with 13 additions and 14 deletions
  1. 8 5
      Firmware/Marlin_main.cpp
  2. 5 9
      Firmware/fancheck.cpp

+ 8 - 5
Firmware/Marlin_main.cpp

@@ -1265,11 +1265,14 @@ void setup()
     temp_mgr_init();
 
 #ifdef EXTRUDER_ALTFAN_DETECT
-	SERIAL_ECHORPGM(_n("Hotend fan type: "));
-	if (extruder_altfan_detect())
-		SERIAL_ECHOLNRPGM(PSTR("ALTFAN"));
-	else
-		SERIAL_ECHOLNRPGM(PSTR("NOCTUA"));
+    if (eeprom_read_byte((uint8_t*)EEPROM_ALTFAN_OVERRIDE) == EEPROM_EMPTY_VALUE) {
+        eeprom_update_byte((uint8_t*)EEPROM_ALTFAN_OVERRIDE, 0);
+        SERIAL_ECHORPGM(_n("Hotend fan type: "));
+        if (extruder_altfan_detect())
+            SERIAL_ECHOLNRPGM(PSTR("ALTFAN"));
+        else
+            SERIAL_ECHOLNRPGM(PSTR("NOCTUA"));
+    }
 #endif //EXTRUDER_ALTFAN_DETECT
 
 	plan_init();  // Initialize planner;

+ 5 - 9
Firmware/fancheck.cpp

@@ -162,18 +162,11 @@ ISR(INT6_vect) {
 
 bool extruder_altfan_detect()
 {
+    // override isAltFan setting for detection
+    altfanStatus.isAltfan = 0;
     setExtruderAutoFanState(3);
 
     SET_INPUT(TACH_0);
-
-    uint8_t overrideVal = eeprom_read_byte((uint8_t *)EEPROM_ALTFAN_OVERRIDE);
-    if (overrideVal == EEPROM_EMPTY_VALUE)
-    {
-        overrideVal = (calibration_status() == CALIBRATION_STATUS_CALIBRATED) ? 1 : 0;
-        eeprom_update_byte((uint8_t *)EEPROM_ALTFAN_OVERRIDE, overrideVal);
-    }
-    altfanStatus.altfanOverride = overrideVal;
-
     CRITICAL_SECTION_START;
     EICRB &= ~(1 << ISC61);
     EICRB |= (1 << ISC60);
@@ -187,8 +180,11 @@ bool extruder_altfan_detect()
     EIMSK &= ~(1 << INT6);
 
     countFanSpeed();
+
+    // restore fan state
     altfanStatus.isAltfan = fan_speed[0] > 100;
     setExtruderAutoFanState(1);
+
     return altfanStatus.isAltfan;
 }