From e602c28ad975f2c0cb575509c99d13dcd35dff69 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 9 Jun 2015 16:54:28 -0700 Subject: [PATCH] Set auto fan pins to OUTPUT during init Fixes the problem of these pins being left in INPUT state, as described in #1497 --- Marlin/temperature.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index edbab7f19..25ec3887c 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -374,7 +374,6 @@ void setExtruderAutoFanState(int pin, bool state) { unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0; // this idiom allows both digital and PWM fan outputs (see M42 handling). - pinMode(pin, OUTPUT); digitalWrite(pin, newFanSpeed); analogWrite(pin, newFanSpeed); } @@ -918,6 +917,19 @@ void tp_init() { ANALOG_SELECT(FILWIDTH_PIN); #endif + #if HAS_AUTO_FAN_0 + pinMode(EXTRUDER_0_AUTO_FAN_PIN, OUTPUT); + #endif + #if HAS_AUTO_FAN_1 && (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + pinMode(EXTRUDER_1_AUTO_FAN_PIN, OUTPUT); + #endif + #if HAS_AUTO_FAN_2 && (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) && (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) + pinMode(EXTRUDER_2_AUTO_FAN_PIN, OUTPUT); + #endif + #if HAS_AUTO_FAN_3 && (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) && (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) && (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN) + pinMode(EXTRUDER_3_AUTO_FAN_PIN, OUTPUT); + #endif + // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt OCR0B = 128;