From eb30daebf50b407617c7baabd3b1ad18d76ec702 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Jan 2019 15:28:13 -0500 Subject: [PATCH] add fanWhenOff option --- reference/speeduino.ini | 6 ++++-- speeduino/auxiliaries.ino | 5 +++-- speeduino/globals.h | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 16a8a7c6..ecd5c524 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -151,7 +151,7 @@ endianness = little nPages = 10 - pageSize = 288, 128, 288, 128, 288, 128, 240, 192, 192, 192 + pageSize = 288, 128, 288, 128, 288, 136, 240, 192, 192, 192 ;burnCommand = "B" ;pageActivate = "P\001", "P\002", "P\003", "P\004", "P\005", "P\006", "P\007", "P\010", "P\011", "P\012", "P\013" @@ -532,7 +532,8 @@ page = 6 ; Begin fan control vairables fanInv = bits, U08, 120, [0:0], "No", "Yes" fanEnable = bits, U08, 120, [1:1], "Off", "On/Off" - fanPin = bits , U08, 120, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID" + fanPin = bits, U08, 120, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID" + fanWhenOff = bits, U08, 128, [0:0], "No", "Yes" #if CELSIUS fanSP = scalar, U08, 121, "C", 1.0, -40, -40, 215.0, 0 fanHyster = scalar, U08, 122, "C", 1.0, 0.0, 0.0, 40, 0 @@ -1708,6 +1709,7 @@ menuDialog = main dialog = fanSettings,"Fan Settings",7 field = "Fan Mode", fanEnable + field = "Fan when off", fanWhenOff, { fanEnable } field = "Fan output pin", fanPin, { fanEnable } field = "Fan Output Inverted", fanInv , { fanEnable } field = "Fan temperature SP", fanSP, { fanEnable } diff --git a/speeduino/auxiliaries.ino b/speeduino/auxiliaries.ino index e578f16a..35b2a24c 100644 --- a/speeduino/auxiliaries.ino +++ b/speeduino/auxiliaries.ino @@ -32,15 +32,16 @@ void fanControl() { int onTemp = (int)configPage6.fanSP - CALIBRATION_TEMPERATURE_OFFSET; int offTemp = onTemp - configPage6.fanHyster; + bool fanPermit = fanWhenOff ? true : BIT_CHECK(currentStatus.engine, BIT_ENGINE_RUN) - if ( currentStatus.coolant >= onTemp ) + if ( currentStatus.coolant >= onTemp && fanPermit ) { //Fan needs to be turned on. Checked for normal or inverted fan signal if( configPage6.fanInv == 0 ) { FAN_PIN_HIGH(); } else { FAN_PIN_LOW(); } currentStatus.fanOn = true; } - else if ( currentStatus.coolant <= offTemp ) + else if ( currentStatus.coolant <= offTemp || !fanPermit ) { //Fan needs to be turned off. Checked for normal or inverted fan signal if( configPage6.fanInv == 0 ) { FAN_PIN_LOW(); } diff --git a/speeduino/globals.h b/speeduino/globals.h index 8ffea6ea..8aadf8ec 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -208,7 +208,7 @@ const char TSfirmwareVersion[] PROGMEM = "Speeduino"; const byte data_structure_version = 2; //This identifies the data structure when reading / writing. //const byte page_size = 64; -const int16_t npage_size[11] PROGMEM = {0,288,128,288,128,288,128,240,192,192,192}; +const int16_t npage_size[11] PROGMEM = {0,288,128,288,128,288,136,240,192,192,192}; //const byte page11_size = 128; #define MAP_PAGE_SIZE 288 @@ -692,6 +692,8 @@ struct config6 { byte fanHyster; // Fan hysteresis byte fanFreq; // Fan PWM frequency byte fanPWMBins[4]; //Temperature Bins for the PWM fan control + byte fanWhenOff : 1; // Only run fan when engine is running + #if defined(CORE_AVR) }; #else