Improved fan on/off logic
This commit is contained in:
parent
0d4994f884
commit
8b95fe891a
|
@ -10,15 +10,22 @@ Fan control
|
|||
*/
|
||||
void initialiseFan()
|
||||
{
|
||||
if(configPage4.fanInv == 1) {fanHIGH = LOW, fanLOW = HIGH; }
|
||||
else {fanHIGH = HIGH, fanLOW = LOW;}
|
||||
digitalWrite(pinFan, fanLOW); //Initiallise program with the fan in the off state
|
||||
if(configPage4.fanInv) { fanHIGH = LOW, fanLOW = HIGH; }
|
||||
else { fanHIGH = HIGH, fanLOW = LOW; }
|
||||
digitalWrite(pinFan, fanLOW); //Initiallise program with the fan in the off state
|
||||
currentStatus.fanOn = false;
|
||||
}
|
||||
|
||||
void fanControl()
|
||||
{
|
||||
if (currentStatus.coolant >= (configPage4.fanSP - CALIBRATION_TEMPERATURE_OFFSET)) { digitalWrite(pinFan,fanHIGH); }
|
||||
else if (currentStatus.coolant <= (configPage4.fanSP - configPage4.fanHyster)) { digitalWrite(pinFan, fanLOW); }
|
||||
if(configPage4.fanEnable)
|
||||
{
|
||||
int onTemp = (int)configPage4.fanSP - CALIBRATION_TEMPERATURE_OFFSET;
|
||||
int offTemp = onTemp - configPage4.fanHyster;
|
||||
|
||||
if (!currentStatus.fanOn && currentStatus.coolant >= onTemp) { digitalWrite(pinFan,fanHIGH); currentStatus.fanOn = true; }
|
||||
if (currentStatus.fanOn && currentStatus.coolant <= offTemp) { digitalWrite(pinFan, fanLOW); currentStatus.fanOn = false; }
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
|
|
|
@ -139,6 +139,7 @@ struct statuses {
|
|||
byte launchCorrection; //The amount of correction being applied if launch control is active
|
||||
byte afrTarget;
|
||||
byte idleDuty;
|
||||
bool fanOn; //Whether or not the fan is turned on
|
||||
byte flex; //Ethanol reading (if enabled). 0 = No ethanol, 100 = pure ethanol. Eg E85 = 85.
|
||||
unsigned long TAEEndTime; //The target end time used whenever TAE is turned on
|
||||
volatile byte squirt;
|
||||
|
|
Loading…
Reference in New Issue