Skip to content

Commit

Permalink
Handle COOLER auto fan like the others?
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 23, 2023
1 parent 70ff0e0 commit 443db01
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2566,10 +2566,15 @@
#define HAS_AUTO_FAN 1
#define _FANOVERLAP(A,B) (A##_AUTO_FAN_PIN == E##B##_AUTO_FAN_PIN)
#define _CHFANOVERLAP(A) || _FANOVERLAP(CHAMBER,B)
#define _COFANOVERLAP(A) || _FANOVERLAP(COOLER,B)
#if HAS_AUTO_FAN && (0 REPEAT(8, _CHFANOVERLAP))
#define AUTO_CHAMBER_IS_E 1
#endif
#if HAS_AUTO_FAN && (0 REPEAT(8, _COFANOVERLAP))
#define AUTO_COOLER_IS_E 1
#endif
#undef _CHFANOVERLAP
#undef _COFANOVERLAP
#endif

// Fans check
Expand Down
22 changes: 20 additions & 2 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,11 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
#else
#define INIT_CHAMBER_AUTO_FAN_PIN(P) SET_OUTPUT(P)
#endif
#if COOLER_AUTO_FAN_SPEED != 255
#define INIT_COOLER_AUTO_FAN_PIN(P) do{ if (0 REPEAT2(FAN_COUNT, _IS_FAN_PIN, P)) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0)
#else
#define INIT_COOLER_AUTO_FAN_PIN(P) SET_OUTPUT(P)
#endif

#ifndef CHAMBER_FAN_INDEX
#define CHAMBER_FAN_INDEX HOTENDS
Expand All @@ -1222,9 +1227,16 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
#define _NEXT_FAN(N) , REPEAT2(N,_EFAN,N) N
RREPEAT_S(1, HOTENDS, _NEXT_FAN)
#endif
#define _NFAN HOTENDS
#if HAS_AUTO_CHAMBER_FAN
#define _CFAN(B) _FANOVERLAP(CHAMBER,B) ? B :
, REPEAT(HOTENDS,_CFAN) (HOTENDS)
#define _CHFAN(B) _FANOVERLAP(CHAMBER,B) ? B :
, (REPEAT(HOTENDS,_CHFAN) (_NFAN))
#undef _NFAN
#define _NFAN INCREMENT(HOTENDS)
#endif
#if HAS_AUTO_COOLER_FAN
#define _COFAN(B) _FANOVERLAP(COOLER,B) ? B :
, (REPEAT(HOTENDS,_COFAN) (_NFAN))
#endif
};

Expand Down Expand Up @@ -1282,6 +1294,9 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
#if HAS_AUTO_CHAMBER_FAN && !AUTO_CHAMBER_IS_E
case CHAMBER_FAN_INDEX: _UPDATE_AUTO_FAN(CHAMBER, fan_on, CHAMBER_AUTO_FAN_SPEED); break;
#endif
#if HAS_AUTO_COOLER_FAN && !AUTO_COOLER_IS_E
case COOLER_FAN_INDEX: _UPDATE_AUTO_FAN(COOLER, fan_on, COOLER_AUTO_FAN_SPEED); break;
#endif
}
SBI(fanDone, realFan);
}
Expand Down Expand Up @@ -2743,6 +2758,9 @@ void Temperature::init() {
#if HAS_AUTO_CHAMBER_FAN && !AUTO_CHAMBER_IS_E
INIT_CHAMBER_AUTO_FAN_PIN(CHAMBER_AUTO_FAN_PIN);
#endif
#if HAS_AUTO_COOLER_FAN && !AUTO_COOLER_IS_E
INIT_COOLER_AUTO_FAN_PIN(COOLER_AUTO_FAN_PIN);
#endif
#endif // HAS_AUTO_FAN

#if HAS_HOTEND
Expand Down

0 comments on commit 443db01

Please sign in to comment.