4646
4747#ifdef DOGLCD
4848 #include " StatsManager.h"
49+ #include " HeatedbedManager.h"
50+ #include " FanManager.h"
4951#endif
5052
5153bool raised = false ;
@@ -83,9 +85,11 @@ void action_preheat()
8385
8486void action_cooldown ()
8587{
86-
8788 temp::TemperatureManager::single::instance ().setBlowerControlState (true );
8889 temp::TemperatureManager::single::instance ().setTargetTemperature (0 );
90+ #if HEATER_BED_PIN > -1
91+ temp::TemperatureManager::single::instance ().setBedTargetTemperature (0 );
92+ #endif
8993}
9094
9195void action_filament_unload ()
@@ -288,10 +292,34 @@ static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float
288292
289293void action_get_plane ()
290294{
291-
292295 #if Z_MIN_PIN == -1
293296 #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
294297 #endif
298+
299+ #ifdef DOGLCD
300+ #if HEATER_BED_PIN > -1
301+ if (HeatedbedManager::single::instance ().detected ())
302+ {
303+ temp::TemperatureManager::single::instance ().setBedTargetTemperature (0 );
304+ while (HeatedbedManager::single::instance ().detected () && temp::TemperatureManager::single::instance ().getBedCurrentTemperature () > BED_AUTOLEVEL_TEMP)
305+ {
306+ unsigned long curtime = millis ();
307+ if (( millis () - curtime) > 1000 ) // Print Temp Reading every 1 second while heating up.
308+ {
309+ float tt=temp::TemperatureManager::single::instance ().getCurrentTemperature ();
310+ SERIAL_PROTOCOLPGM (" T:" );
311+ SERIAL_PROTOCOL (tt);
312+ SERIAL_PROTOCOLPGM (" E:" );
313+ SERIAL_PROTOCOL ((int )0 );
314+ SERIAL_PROTOCOLPGM (" B:" );
315+ SERIAL_PROTOCOL_F (temp::TemperatureManager::single::instance ().getBedCurrentTemperature (),1 );
316+ SERIAL_PROTOCOLLN (" " );
317+ curtime = millis ();
318+ }
319+ };
320+ }
321+ #endif // HEATER_BED_PIN > -1
322+ #endif // DOGLCD
295323
296324 // Prevent user from running a G29 without first homing in X and Y
297325 if (! (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) )
@@ -626,7 +654,6 @@ void action_start_print()
626654
627655 char cmd[LONG_FILENAME_LENGTH];
628656 char * c;
629-
630657 if (PrintManager::single::instance ().state () == PRINTING)
631658 {
632659 serial_printing = false ;
@@ -671,6 +698,13 @@ void action_start_print()
671698 StatsManager::single::instance ().increaseTotalPrints ();
672699#endif // DOGLCD
673700
701+ #ifdef FAN_BOX_PIN
702+ if (FanManager::single::instance ().state () == true )
703+ {
704+ digitalWrite (FAN_BOX_PIN, HIGH);
705+ }
706+ #endif // FAN_BOX_PIN
707+
674708 enquecommand_P (PSTR (" G90" ));
675709 enquecommand_P (PSTR (" G92 E0" ));
676710 enquecommand_P (PSTR (" G1 F1800" )); // sets slow initial feedrate
@@ -771,6 +805,10 @@ void action_stop_print()
771805 enquecommand_P (PSTR (SD_FINISHED_RELEASECOMMAND));
772806 }
773807 // autotempShutdown();
808+
809+ #if HEATER_BED_PIN > -1
810+ temp::TemperatureManager::single::instance ().setBedTargetTemperature (0 );
811+ #endif // HEATER_BED_PIN > -1
774812
775813 cancel_heatup = true ;
776814
@@ -783,6 +821,13 @@ void action_stop_print()
783821 StatsManager::single::instance ().updateTotalTime (printTime);
784822 #endif
785823
824+ #ifdef FAN_BOX_PIN
825+ if (FanManager::single::instance ().state () == true )
826+ {
827+ digitalWrite (FAN_BOX_PIN, LOW);
828+ }
829+ #endif // FAN_BOX_PIN
830+
786831 for (int i=0 ; i != num_ok; i++)
787832 {
788833 SERIAL_PROTOCOLLNPGM (MSG_OK);
0 commit comments