2727
2828#include < math.h>
2929
30- #include " TemperatureManager.h"
30+ #include " TemperatureManager.h"
3131
3232#include " Configuration.h"
3333#include " temperature.h"
3434#include " Marlin.h"
3535#include " cardreader.h"
36+ #include " PrintManager.h"
3637
3738#ifdef DOGLCD
3839 #include " GuiManager.h"
@@ -78,7 +79,7 @@ namespace temp
7879 ADCSRA = 0x87 ;
7980 ADCSRB = 0x08 ;
8081 ADMUX = 0x45 ;
81-
82+
8283 ADCSRA |= 0x40 ;
8384 ADCSRA |= 0x10 ;
8485 delay (1 );
@@ -141,9 +142,9 @@ namespace temp
141142 }
142143
143144 for (uint8_t j = 0 ; j < 4 ; i++, j++)
144- {
145- m_cache[j].raw = pgm_read_word (&(*tt)[i][0 ]);
146- m_cache[j].temperature = pgm_read_word (&(*tt)[i][1 ]);
145+ {
146+ m_cache[j].raw = pgm_read_word (&(*tt)[i][0 ]);
147+ m_cache[j].temperature = pgm_read_word (&(*tt)[i][1 ]);
147148 }
148149 }
149150
@@ -161,7 +162,7 @@ namespace temp
161162 {
162163#ifdef DOGLCD
163164 m_control->setCurrentTemperature (temp);
164- #endif
165+ #endif
165166 if (m_current_temperature != temp)
166167 {
167168 m_current_temperature = temp;
@@ -242,25 +243,28 @@ namespace temp
242243 #endif // FAN_BLOCK_PIN
243244 if (m_blower_control == true )
244245 {
245- fanSpeed = 0 ;
246- }
246+ fanSpeed = 0 ;
247+ }
247248 }
248249#ifdef FAN_BLOWER_PIN
249250 analogWrite (FAN_BLOWER_PIN,fanSpeed);
250251#endif
251252
252253#ifdef FAN_BOX_PIN
253- if (FanManager::single::instance ().state () == true )
254- {
255- if (card.isFileOpen () == true )
254+ if (FanManager::single::instance ().state () == true )
255+ {
256+ if (! card.isFileOpen () && PrintManager::single::instance (). state () != SERIAL_CONTROL )
256257 {
258+ if (m_current_temperature > min_temp_cooling)
259+ {
257260 digitalWrite (FAN_BOX_PIN, HIGH);
258- }
259- else
260- {
261+ }
262+ else
263+ {
261264 digitalWrite (FAN_BOX_PIN, LOW);
265+ }
262266 }
263- }
267+ }
264268#endif // FAN_BOX_PIN
265269 }
266270
@@ -283,7 +287,7 @@ ISR(TIMER2_OVF_vect)
283287 if (control_flag == true )
284288 {
285289 temp::TemperatureManager::single::instance ().m_control ->manageControl ();
286- control_flag = false ;
290+ control_flag = false ;
287291 }
288292
289293 temp_counter++;
@@ -327,4 +331,4 @@ ISR(ADC_vect)
327331 accumulate = 0 ;
328332 }
329333}
330- #endif // DOGLCD
334+ #endif // DOGLCD
0 commit comments