@ -319,7 +319,7 @@ void setup_photpin()
void setup_powerhold ( )
void setup_powerhold ( )
{
{
# ifdef SUICIDE_PIN
# ifdef SUICIDE_PIN
# if (SUICIDE_PIN> -1 )
# if (SUICIDE_PIN> 0 )
SET_OUTPUT ( SUICIDE_PIN ) ;
SET_OUTPUT ( SUICIDE_PIN ) ;
WRITE ( SUICIDE_PIN , HIGH ) ;
WRITE ( SUICIDE_PIN , HIGH ) ;
# endif
# endif
@ -411,13 +411,9 @@ void setup()
lcd_init ( ) ;
lcd_init ( ) ;
# if def CONTROLLERFAN_PIN
# if CONTROLLERFAN_PIN > 0
SET_OUTPUT ( CONTROLLERFAN_PIN ) ; //Set pin used for driver cooling fan
SET_OUTPUT ( CONTROLLERFAN_PIN ) ; //Set pin used for driver cooling fan
# endif
# endif
# ifdef EXTRUDERFAN_PIN
SET_OUTPUT ( EXTRUDERFAN_PIN ) ; //Set pin used for extruder cooling fan
# endif
}
}
@ -1040,6 +1036,10 @@ void process_commands()
break ;
break ;
}
}
}
}
# if FAN_PIN > 0
if ( pin_number = = FAN_PIN )
fanSpeed = pin_status ;
# endif
if ( pin_number > - 1 )
if ( pin_number > - 1 )
{
{
pinMode ( pin_number , OUTPUT ) ;
pinMode ( pin_number , OUTPUT ) ;
@ -2064,7 +2064,12 @@ void prepare_arc_move(char isclockwise) {
previous_millis_cmd = millis ( ) ;
previous_millis_cmd = millis ( ) ;
}
}
# ifdef CONTROLLERFAN_PIN
# if CONTROLLERFAN_PIN > 0
# if CONTROLLERFAN_PIN == FAN_PIN
# error "You cannot set CONTROLLERFAN_PIN equal to FAN_PIN"
# endif
unsigned long lastMotor = 0 ; //Save the time for when a motor was turned on last
unsigned long lastMotor = 0 ; //Save the time for when a motor was turned on last
unsigned long lastMotorCheck = 0 ;
unsigned long lastMotorCheck = 0 ;
@ -2086,34 +2091,16 @@ void controllerFan()
lastMotor = millis ( ) ; //... set time to NOW so the fan will turn on
lastMotor = millis ( ) ; //... set time to NOW so the fan will turn on
}
}
if ( ( millis ( ) - lastMotor ) > = ( CONTROLLERFAN_SEC * 1000UL ) | | lastMotor = = 0 ) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
if ( ( millis ( ) - lastMotor ) > = ( CONTROLLERFAN_SECS * 1000UL ) | | lastMotor = = 0 ) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
{
WRITE ( CONTROLLERFAN_PIN , LOW ) ; //... turn the fan off
}
else
{
WRITE ( CONTROLLERFAN_PIN , HIGH ) ; //... turn the fan on
}
}
}
# endif
# ifdef EXTRUDERFAN_PIN
unsigned long lastExtruderCheck = 0 ;
void extruderFan ( )
{
if ( ( millis ( ) - lastExtruderCheck ) > = 2500 ) //Not a time critical function, so we only check every 2500ms
{
lastExtruderCheck = millis ( ) ;
if ( degHotend ( active_extruder ) < EXTRUDERFAN_DEC )
{
{
WRITE ( EXTRUDERFAN_PIN , LOW ) ; //... turn the fan off
digitalWrite ( CONTROLLERFAN_PIN , 0 ) ;
analogWrite ( CONTROLLERFAN_PIN , 0 ) ;
}
}
else
else
{
{
WRITE ( EXTRUDERFAN_PIN , HIGH ) ; //... turn the fan on
// allows digital or PWM fan output to be used (see M42 handling)
digitalWrite ( CONTROLLERFAN_PIN , CONTROLLERFAN_SPEED ) ;
analogWrite ( CONTROLLERFAN_PIN , CONTROLLERFAN_SPEED ) ;
}
}
}
}
}
}
@ -2137,11 +2124,11 @@ void manage_inactivity()
}
}
}
}
}
}
# if ( KILL_PIN>-1 )
# if KILL_PIN > 0
if ( 0 = = READ ( KILL_PIN ) )
if ( 0 = = READ ( KILL_PIN ) )
kill ( ) ;
kill ( ) ;
# endif
# endif
# if def CONTROLLERFAN_PIN
# if CONTROLLERFAN_PIN > 0
controllerFan ( ) ; //Check if fan should be turned on to cool stepper drivers down
controllerFan ( ) ; //Check if fan should be turned on to cool stepper drivers down
# endif
# endif
# ifdef EXTRUDER_RUNOUT_PREVENT
# ifdef EXTRUDER_RUNOUT_PREVENT