|
|
|
@ -185,7 +185,7 @@ int Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP ,
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HAS_AUTO_FAN
|
|
|
|
|
millis_t Temperature::next_auto_fan_check_ms;
|
|
|
|
|
millis_t Temperature::next_auto_fan_check_ms = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
unsigned char Temperature::soft_pwm[HOTENDS];
|
|
|
|
@ -465,21 +465,21 @@ int Temperature::getHeaterPower(int heater) {
|
|
|
|
|
|
|
|
|
|
void Temperature::checkExtruderAutoFans() {
|
|
|
|
|
const int8_t fanPin[] = { EXTRUDER_0_AUTO_FAN_PIN, EXTRUDER_1_AUTO_FAN_PIN, EXTRUDER_2_AUTO_FAN_PIN, EXTRUDER_3_AUTO_FAN_PIN };
|
|
|
|
|
const int fanBit[] = { 0,
|
|
|
|
|
EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 : 1,
|
|
|
|
|
EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 :
|
|
|
|
|
EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN ? 1 : 2,
|
|
|
|
|
EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 :
|
|
|
|
|
EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN ? 1 :
|
|
|
|
|
EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN ? 2 : 3
|
|
|
|
|
const int fanBit[] = {
|
|
|
|
|
0,
|
|
|
|
|
AUTO_1_IS_0 ? 0 : 1,
|
|
|
|
|
AUTO_2_IS_0 ? 0 : AUTO_2_IS_1 ? 1 : 2,
|
|
|
|
|
AUTO_3_IS_0 ? 0 : AUTO_3_IS_1 ? 1 : AUTO_3_IS_2 ? 2 : 3
|
|
|
|
|
};
|
|
|
|
|
uint8_t fanState = 0;
|
|
|
|
|
|
|
|
|
|
HOTEND_LOOP() {
|
|
|
|
|
if (current_temperature[e] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
|
|
|
|
SBI(fanState, fanBit[e]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t fanDone = 0;
|
|
|
|
|
for (int8_t f = 0; f <= 3; f++) {
|
|
|
|
|
for (int8_t f = 0; f < COUNT(fanPin); f++) {
|
|
|
|
|
int8_t pin = fanPin[f];
|
|
|
|
|
if (pin >= 0 && !TEST(fanDone, fanBit[f])) {
|
|
|
|
|
unsigned char newFanSpeed = TEST(fanState, fanBit[f]) ? EXTRUDER_AUTO_FAN_SPEED : 0;
|
|
|
|
@ -987,8 +987,6 @@ void Temperature::init() {
|
|
|
|
|
SET_OUTPUT(HEATER_BED_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if ENABLED(FAST_PWM_FAN) || ENABLED(FAN_SOFT_PWM)
|
|
|
|
|
|
|
|
|
|
#if HAS_FAN0
|
|
|
|
|
SET_OUTPUT(FAN_PIN);
|
|
|
|
|
#if ENABLED(FAST_PWM_FAN)
|
|
|
|
@ -1019,8 +1017,6 @@ void Temperature::init() {
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif // FAST_PWM_FAN || FAN_SOFT_PWM
|
|
|
|
|
|
|
|
|
|
#if ENABLED(HEATER_0_USES_MAX6675)
|
|
|
|
|
|
|
|
|
|
#if DISABLED(SDSUPPORT)
|
|
|
|
@ -1068,17 +1064,45 @@ void Temperature::init() {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HAS_AUTO_FAN_0
|
|
|
|
|
#if EXTRUDER_0_AUTO_FAN_PIN == FAN1_PIN
|
|
|
|
|
SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
|
|
|
|
|
#if ENABLED(FAST_PWM_FAN)
|
|
|
|
|
setPwmFrequency(EXTRUDER_0_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
pinMode(EXTRUDER_0_AUTO_FAN_PIN, OUTPUT);
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_AUTO_FAN_1 && (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_AUTO_FAN_1 && !AUTO_1_IS_0
|
|
|
|
|
#if EXTRUDER_1_AUTO_FAN_PIN == FAN1_PIN
|
|
|
|
|
SET_OUTPUT(EXTRUDER_1_AUTO_FAN_PIN);
|
|
|
|
|
#if ENABLED(FAST_PWM_FAN)
|
|
|
|
|
setPwmFrequency(EXTRUDER_1_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
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)
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_AUTO_FAN_2 && !AUTO_2_IS_0 && !AUTO_2_IS_1
|
|
|
|
|
#if EXTRUDER_2_AUTO_FAN_PIN == FAN1_PIN
|
|
|
|
|
SET_OUTPUT(EXTRUDER_2_AUTO_FAN_PIN);
|
|
|
|
|
#if ENABLED(FAST_PWM_FAN)
|
|
|
|
|
setPwmFrequency(EXTRUDER_2_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
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)
|
|
|
|
|
#endif
|
|
|
|
|
#if HAS_AUTO_FAN_3 && !AUTO_3_IS_0 && !AUTO_3_IS_1 && !AUTO_3_IS_2
|
|
|
|
|
#if EXTRUDER_3_AUTO_FAN_PIN == FAN1_PIN
|
|
|
|
|
SET_OUTPUT(EXTRUDER_3_AUTO_FAN_PIN);
|
|
|
|
|
#if ENABLED(FAST_PWM_FAN)
|
|
|
|
|
setPwmFrequency(EXTRUDER_3_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
pinMode(EXTRUDER_3_AUTO_FAN_PIN, OUTPUT);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Use timer0 for temperature measurement
|
|
|
|
|
// Interleave temperature interrupt with millies interrupt
|
|
|
|
|