|
@@ -185,7 +185,7 @@ int Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP ,
|
185
|
185
|
#endif
|
186
|
186
|
|
187
|
187
|
#if HAS_AUTO_FAN
|
188
|
|
- millis_t Temperature::next_auto_fan_check_ms;
|
|
188
|
+ millis_t Temperature::next_auto_fan_check_ms = 0;
|
189
|
189
|
#endif
|
190
|
190
|
|
191
|
191
|
unsigned char Temperature::soft_pwm[HOTENDS];
|
|
@@ -465,21 +465,21 @@ int Temperature::getHeaterPower(int heater) {
|
465
|
465
|
|
466
|
466
|
void Temperature::checkExtruderAutoFans() {
|
467
|
467
|
const int8_t fanPin[] = { EXTRUDER_0_AUTO_FAN_PIN, EXTRUDER_1_AUTO_FAN_PIN, EXTRUDER_2_AUTO_FAN_PIN, EXTRUDER_3_AUTO_FAN_PIN };
|
468
|
|
- const int fanBit[] = { 0,
|
469
|
|
- EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 : 1,
|
470
|
|
- EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 :
|
471
|
|
- EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN ? 1 : 2,
|
472
|
|
- EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 :
|
473
|
|
- EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN ? 1 :
|
474
|
|
- EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN ? 2 : 3
|
|
468
|
+ const int fanBit[] = {
|
|
469
|
+ 0,
|
|
470
|
+ AUTO_1_IS_0 ? 0 : 1,
|
|
471
|
+ AUTO_2_IS_0 ? 0 : AUTO_2_IS_1 ? 1 : 2,
|
|
472
|
+ AUTO_3_IS_0 ? 0 : AUTO_3_IS_1 ? 1 : AUTO_3_IS_2 ? 2 : 3
|
475
|
473
|
};
|
476
|
474
|
uint8_t fanState = 0;
|
|
475
|
+
|
477
|
476
|
HOTEND_LOOP() {
|
478
|
477
|
if (current_temperature[e] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
479
|
478
|
SBI(fanState, fanBit[e]);
|
480
|
479
|
}
|
|
480
|
+
|
481
|
481
|
uint8_t fanDone = 0;
|
482
|
|
- for (int8_t f = 0; f <= 3; f++) {
|
|
482
|
+ for (int8_t f = 0; f < COUNT(fanPin); f++) {
|
483
|
483
|
int8_t pin = fanPin[f];
|
484
|
484
|
if (pin >= 0 && !TEST(fanDone, fanBit[f])) {
|
485
|
485
|
unsigned char newFanSpeed = TEST(fanState, fanBit[f]) ? EXTRUDER_AUTO_FAN_SPEED : 0;
|
|
@@ -987,39 +987,35 @@ void Temperature::init() {
|
987
|
987
|
SET_OUTPUT(HEATER_BED_PIN);
|
988
|
988
|
#endif
|
989
|
989
|
|
990
|
|
- #if ENABLED(FAST_PWM_FAN) || ENABLED(FAN_SOFT_PWM)
|
991
|
|
-
|
992
|
|
- #if HAS_FAN0
|
993
|
|
- SET_OUTPUT(FAN_PIN);
|
994
|
|
- #if ENABLED(FAST_PWM_FAN)
|
995
|
|
- setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
996
|
|
- #endif
|
997
|
|
- #if ENABLED(FAN_SOFT_PWM)
|
998
|
|
- soft_pwm_fan[0] = fanSpeedSoftPwm[0] / 2;
|
999
|
|
- #endif
|
|
990
|
+ #if HAS_FAN0
|
|
991
|
+ SET_OUTPUT(FAN_PIN);
|
|
992
|
+ #if ENABLED(FAST_PWM_FAN)
|
|
993
|
+ setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
1000
|
994
|
#endif
|
1001
|
|
-
|
1002
|
|
- #if HAS_FAN1
|
1003
|
|
- SET_OUTPUT(FAN1_PIN);
|
1004
|
|
- #if ENABLED(FAST_PWM_FAN)
|
1005
|
|
- setPwmFrequency(FAN1_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
1006
|
|
- #endif
|
1007
|
|
- #if ENABLED(FAN_SOFT_PWM)
|
1008
|
|
- soft_pwm_fan[1] = fanSpeedSoftPwm[1] / 2;
|
1009
|
|
- #endif
|
|
995
|
+ #if ENABLED(FAN_SOFT_PWM)
|
|
996
|
+ soft_pwm_fan[0] = fanSpeedSoftPwm[0] / 2;
|
1010
|
997
|
#endif
|
|
998
|
+ #endif
|
1011
|
999
|
|
1012
|
|
- #if HAS_FAN2
|
1013
|
|
- SET_OUTPUT(FAN2_PIN);
|
1014
|
|
- #if ENABLED(FAST_PWM_FAN)
|
1015
|
|
- setPwmFrequency(FAN2_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
1016
|
|
- #endif
|
1017
|
|
- #if ENABLED(FAN_SOFT_PWM)
|
1018
|
|
- soft_pwm_fan[2] = fanSpeedSoftPwm[2] / 2;
|
1019
|
|
- #endif
|
|
1000
|
+ #if HAS_FAN1
|
|
1001
|
+ SET_OUTPUT(FAN1_PIN);
|
|
1002
|
+ #if ENABLED(FAST_PWM_FAN)
|
|
1003
|
+ setPwmFrequency(FAN1_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
1004
|
+ #endif
|
|
1005
|
+ #if ENABLED(FAN_SOFT_PWM)
|
|
1006
|
+ soft_pwm_fan[1] = fanSpeedSoftPwm[1] / 2;
|
1020
|
1007
|
#endif
|
|
1008
|
+ #endif
|
1021
|
1009
|
|
1022
|
|
- #endif // FAST_PWM_FAN || FAN_SOFT_PWM
|
|
1010
|
+ #if HAS_FAN2
|
|
1011
|
+ SET_OUTPUT(FAN2_PIN);
|
|
1012
|
+ #if ENABLED(FAST_PWM_FAN)
|
|
1013
|
+ setPwmFrequency(FAN2_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
1014
|
+ #endif
|
|
1015
|
+ #if ENABLED(FAN_SOFT_PWM)
|
|
1016
|
+ soft_pwm_fan[2] = fanSpeedSoftPwm[2] / 2;
|
|
1017
|
+ #endif
|
|
1018
|
+ #endif
|
1023
|
1019
|
|
1024
|
1020
|
#if ENABLED(HEATER_0_USES_MAX6675)
|
1025
|
1021
|
|
|
@@ -1068,16 +1064,44 @@ void Temperature::init() {
|
1068
|
1064
|
#endif
|
1069
|
1065
|
|
1070
|
1066
|
#if HAS_AUTO_FAN_0
|
1071
|
|
- pinMode(EXTRUDER_0_AUTO_FAN_PIN, OUTPUT);
|
|
1067
|
+ #if EXTRUDER_0_AUTO_FAN_PIN == FAN1_PIN
|
|
1068
|
+ SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
|
|
1069
|
+ #if ENABLED(FAST_PWM_FAN)
|
|
1070
|
+ setPwmFrequency(EXTRUDER_0_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
1071
|
+ #endif
|
|
1072
|
+ #else
|
|
1073
|
+ pinMode(EXTRUDER_0_AUTO_FAN_PIN, OUTPUT);
|
|
1074
|
+ #endif
|
1072
|
1075
|
#endif
|
1073
|
|
- #if HAS_AUTO_FAN_1 && (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
|
1074
|
|
- pinMode(EXTRUDER_1_AUTO_FAN_PIN, OUTPUT);
|
|
1076
|
+ #if HAS_AUTO_FAN_1 && !AUTO_1_IS_0
|
|
1077
|
+ #if EXTRUDER_1_AUTO_FAN_PIN == FAN1_PIN
|
|
1078
|
+ SET_OUTPUT(EXTRUDER_1_AUTO_FAN_PIN);
|
|
1079
|
+ #if ENABLED(FAST_PWM_FAN)
|
|
1080
|
+ setPwmFrequency(EXTRUDER_1_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
1081
|
+ #endif
|
|
1082
|
+ #else
|
|
1083
|
+ pinMode(EXTRUDER_1_AUTO_FAN_PIN, OUTPUT);
|
|
1084
|
+ #endif
|
1075
|
1085
|
#endif
|
1076
|
|
- #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)
|
1077
|
|
- pinMode(EXTRUDER_2_AUTO_FAN_PIN, OUTPUT);
|
|
1086
|
+ #if HAS_AUTO_FAN_2 && !AUTO_2_IS_0 && !AUTO_2_IS_1
|
|
1087
|
+ #if EXTRUDER_2_AUTO_FAN_PIN == FAN1_PIN
|
|
1088
|
+ SET_OUTPUT(EXTRUDER_2_AUTO_FAN_PIN);
|
|
1089
|
+ #if ENABLED(FAST_PWM_FAN)
|
|
1090
|
+ setPwmFrequency(EXTRUDER_2_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
1091
|
+ #endif
|
|
1092
|
+ #else
|
|
1093
|
+ pinMode(EXTRUDER_2_AUTO_FAN_PIN, OUTPUT);
|
|
1094
|
+ #endif
|
1078
|
1095
|
#endif
|
1079
|
|
- #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)
|
1080
|
|
- pinMode(EXTRUDER_3_AUTO_FAN_PIN, OUTPUT);
|
|
1096
|
+ #if HAS_AUTO_FAN_3 && !AUTO_3_IS_0 && !AUTO_3_IS_1 && !AUTO_3_IS_2
|
|
1097
|
+ #if EXTRUDER_3_AUTO_FAN_PIN == FAN1_PIN
|
|
1098
|
+ SET_OUTPUT(EXTRUDER_3_AUTO_FAN_PIN);
|
|
1099
|
+ #if ENABLED(FAST_PWM_FAN)
|
|
1100
|
+ setPwmFrequency(EXTRUDER_3_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
|
1101
|
+ #endif
|
|
1102
|
+ #else
|
|
1103
|
+ pinMode(EXTRUDER_3_AUTO_FAN_PIN, OUTPUT);
|
|
1104
|
+ #endif
|
1081
|
1105
|
#endif
|
1082
|
1106
|
|
1083
|
1107
|
// Use timer0 for temperature measurement
|