diff --git a/speeduino.ino b/speeduino.ino index 5f9efa1e..4bf82052 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -81,6 +81,8 @@ unsigned long scheduleEnd; byte coilHIGH = HIGH; byte coilLOW = LOW; +byte FanHIGH = HIGH; // Used to invert the cooling fan output +byte FanLOW = LOW; // Used to invert the cooling fan output struct statuses currentStatus; volatile int mainLoopCount; @@ -156,6 +158,7 @@ void setup() initialiseTimers(); initialiseDisplay(); initialiseIdle(); + initialiseFan(); //Once the configs have been loaded, a number of one time calculations can be completed req_fuel_uS = configPage1.reqFuel * 100; //Convert to uS and an int. This is the only variable to be used in calculations @@ -358,6 +361,15 @@ void loop() currentStatus.O2 = o2CalibrationTable[currentStatus.O2ADC]; } + // Only check the fan controls every 1000 loops to save processing power // ################ + if ((mainLoopCount & 1001) == 1) + { + if (configPage4.FanEnable == 1) + { + FanControl(); // Fucntion to turn the cooling fan on/off + } + } + //Always check for sync //Main loop runs within this clause if (currentStatus.hasSync && (currentStatus.RPM > 0))