From 2fd8c248fe296818c902a1db65fbdc79cce91abf Mon Sep 17 00:00:00 2001
From: Blair Thompson <mail@justblair.co.uk>
Date: Wed, 22 Feb 2012 23:05:52 +0000
Subject: [PATCH] Added Fan control to the pre-heat settings.

I find that the PID routine works better when the cooling fan is switched on
at the beginning of a warm up routine.  Otherwise when you enable the fan
just before a print, you have a delay as the PIDre-adjusts.

This should also be safer as most cooling fans are directed at the hot -ends
thermal barrier!
---
 Marlin/Configuration.h | 6 ++++++
 Marlin/ultralcd.pde    | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index e36751e85de..da4a0def711 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -194,10 +194,16 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
   #define ULTRA_LCD
   #define LCD_WIDTH 20
   #define LCD_HEIGHT 4
+
+// Preheat Constants
   #define PLA_PREHEAT_HOTEND_TEMP 180 
   #define PLA_PREHEAT_HPB_TEMP 70
+  #define PLA_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
+
   #define ABS_PREHEAT_HOTEND_TEMP 240
   #define ABS_PREHEAT_HPB_TEMP 100
+  #define ABS_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
+
 #else //no panel but just lcd 
   #ifdef ULTRA_LCD
     #define LCD_WIDTH 16
diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde
index c43290738a6..02da3dd30b5 100644
--- a/Marlin/ultralcd.pde
+++ b/Marlin/ultralcd.pde
@@ -490,10 +490,10 @@ void MainMenu::showPrepare()
       MENUITEM(  lcdprintPGM(MSG_SET_ORIGIN)  ,  BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
       break;
     case ItemP_preheat_pla:
-      MENUITEM(  lcdprintPGM(MSG_PREHEAT_PLA)  ,  BLOCK;setTargetHotend0(PLA_PREHEAT_HOTEND_TEMP);setTargetBed(PLA_PREHEAT_HPB_TEMP);beepshort(); ) ;
+      MENUITEM(  lcdprintPGM(MSG_PREHEAT_PLA)  ,  BLOCK;setTargetHotend0(PLA_PREHEAT_HOTEND_TEMP);setTargetBed(PLA_PREHEAT_HPB_TEMP);analogWrite(FAN_PIN, PLA_PREHEAT_FAN_SPEED); beepshort(); ) ;
       break;
     case ItemP_preheat_abs:
-      MENUITEM(  lcdprintPGM(MSG_PREHEAT_ABS)  ,  BLOCK;setTargetHotend0(ABS_PREHEAT_HOTEND_TEMP);setTargetBed(ABS_PREHEAT_HPB_TEMP);beepshort(); ) ;
+      MENUITEM(  lcdprintPGM(MSG_PREHEAT_ABS)  ,  BLOCK;setTargetHotend0(ABS_PREHEAT_HOTEND_TEMP);setTargetBed(ABS_PREHEAT_HPB_TEMP); analogWrite(FAN_PIN, ABS_PREHEAT_FAN_SPEED); beepshort(); ) ;
       break;
     case ItemP_cooldown:
       MENUITEM(  lcdprintPGM(MSG_COOLDOWN)  ,  BLOCK;setTargetHotend0(0);setTargetBed(0);beepshort(); ) ;