fix buggy output stuff, which behaved weird when using relais true
This commit is contained in:
parent
26a0c6603d
commit
3c14910747
4 changed files with 28 additions and 25 deletions
|
@ -71,13 +71,16 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
// set all OUTPUT to low
|
// set all OUTPUT to low
|
||||||
digitalWrite(PinFAN, HIGH);
|
|
||||||
digitalWrite(PINwaterlevel, LOW);
|
digitalWrite(PINwaterlevel, LOW);
|
||||||
|
|
||||||
|
// For CanGrow 0.6 PCB this has to be HIGH, as its MOSFET driver
|
||||||
|
// is inverted.
|
||||||
|
digitalWrite(PinFAN, HIGH);
|
||||||
digitalWrite(PinLED, HIGH);
|
digitalWrite(PinLED, HIGH);
|
||||||
digitalWrite(PinPUMP, HIGH);
|
digitalWrite(PinPUMP, HIGH);
|
||||||
// except PINsoilmoisture
|
// except PINsoilmoisture
|
||||||
// PINsoilmoisture is always HIGH and gets LOW in moment of waterlevel measurement
|
// PINsoilmoisture is always HIGH and gets LOW in moment of waterlevel measurement
|
||||||
digitalWrite(PINsoilmoisture, LOW);
|
digitalWrite(PINsoilmoisture, HIGH);
|
||||||
|
|
||||||
// set PWM frequency to 13.37KHz
|
// set PWM frequency to 13.37KHz
|
||||||
analogWriteFreq(13370);
|
analogWriteFreq(13370);
|
||||||
|
@ -100,7 +103,7 @@ void setup() {
|
||||||
Serial.println(":: initialise I2C ::");
|
Serial.println(":: initialise I2C ::");
|
||||||
// initialise Wire for I2C
|
// initialise Wire for I2C
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
// ClockStretchLimit seems to have negative effects
|
// just for testing
|
||||||
//Wire.setClockStretchLimit(2500);
|
//Wire.setClockStretchLimit(2500);
|
||||||
Serial.println(":: initialise display ::");
|
Serial.println(":: initialise display ::");
|
||||||
// initialise I2C display
|
// initialise I2C display
|
||||||
|
|
|
@ -449,10 +449,12 @@ void setOutput(byte Output, byte OutputState) {
|
||||||
// TODO read config for inverted outputs
|
// TODO read config for inverted outputs
|
||||||
|
|
||||||
if( (UseRelais == true) || (OutputPin == PinPUMP) ) {
|
if( (UseRelais == true) || (OutputPin == PinPUMP) ) {
|
||||||
|
// convert OutputState to bool when using relais, so we can invert it easy
|
||||||
|
bool OutputState_bool = OutputState;
|
||||||
if(OutputInvert == true) {
|
if(OutputInvert == true) {
|
||||||
OutputState_tmp = 1 - OutputState;
|
OutputState_tmp = 1 - OutputState_bool;
|
||||||
} else {
|
} else {
|
||||||
OutputState_tmp = OutputState;
|
OutputState_tmp = OutputState_bool;
|
||||||
}
|
}
|
||||||
digitalWrite(OutputPin, OutputState_tmp);
|
digitalWrite(OutputPin, OutputState_tmp);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* CanGrow_Version.h gets generated from cangrow.sh */
|
/* CanGrow_Version.h gets generated from cangrow.sh */
|
||||||
|
|
||||||
const char* CanGrowVer = "0.1-dev";
|
const char* CanGrowVer = "0.1-dev";
|
||||||
const char* CanGrowBuild = "461b816-20241205020134";
|
const char* CanGrowBuild = "26a0c66-20241205023254";
|
||||||
|
|
||||||
|
|
|
@ -501,6 +501,11 @@ void WEBgrowSettings() {
|
||||||
body += "LED brightness: <input type='range' id='PinLEDPWM' name='PinLEDPWM' min='0' max='255' value='";
|
body += "LED brightness: <input type='range' id='PinLEDPWM' name='PinLEDPWM' min='0' max='255' value='";
|
||||||
body += PinLEDPWM;
|
body += PinLEDPWM;
|
||||||
body += "'/> %<br>\n";
|
body += "'/> %<br>\n";
|
||||||
|
} else {
|
||||||
|
body += "LED on/off: <select id='PinLEDPWM' name='PinLEDPWM' required>\n";
|
||||||
|
body += "<option value='1'" + returnStrSelected(PinLEDPWM, 1) + ">On</option>\n";
|
||||||
|
body += "<option value='0'" + returnStrSelected(PinLEDPWM, 0) + ">Off</option>\n";
|
||||||
|
body += "</select><br>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(UseFANrelais == false) {
|
if(UseFANrelais == false) {
|
||||||
|
@ -509,8 +514,8 @@ void WEBgrowSettings() {
|
||||||
body += "'/> %<br>\n";
|
body += "'/> %<br>\n";
|
||||||
} else {
|
} else {
|
||||||
body += "FAN on/off: <select id='PinFANPWM' name='PinFANPWM' required>\n";
|
body += "FAN on/off: <select id='PinFANPWM' name='PinFANPWM' required>\n";
|
||||||
body += "<option value='1'" + returnStrSelected(PinFANPWM, 1) + ">Yes</option>\n";
|
body += "<option value='1'" + returnStrSelected(PinFANPWM, 1) + ">On</option>\n";
|
||||||
body += "<option value='0'" + returnStrSelected(PinFANPWM, 0) + ">No</option>\n";
|
body += "<option value='0'" + returnStrSelected(PinFANPWM, 0) + ">Off</option>\n";
|
||||||
body += "</select><br>\n";
|
body += "</select><br>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,14 +753,7 @@ void WEBhelp() {
|
||||||
|
|
||||||
void POSTgrowSettings() {
|
void POSTgrowSettings() {
|
||||||
|
|
||||||
if(UseLEDrelais == true) {
|
PinLEDPWM = webserver.arg("PinLEDPWM").toInt();
|
||||||
// if a relais is used to turn on grow light, we force PWM to max val
|
|
||||||
PinLEDPWM = 255;
|
|
||||||
} else {
|
|
||||||
// otherwise just do PWM
|
|
||||||
PinLEDPWM = webserver.arg("PinLEDPWM").toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
PinFANPWM = webserver.arg("PinFANPWM").toInt();
|
PinFANPWM = webserver.arg("PinFANPWM").toInt();
|
||||||
String GrowName_tmp = webserver.arg("GrowName");
|
String GrowName_tmp = webserver.arg("GrowName");
|
||||||
GrowName_tmp.toCharArray(GrowName, 32);
|
GrowName_tmp.toCharArray(GrowName, 32);
|
||||||
|
@ -888,20 +886,20 @@ void POSTsystemSettings() {
|
||||||
Serial.println(":: POSTsystemSettings ::");
|
Serial.println(":: POSTsystemSettings ::");
|
||||||
|
|
||||||
// when user uses an relais for LED control, we force here PinLEDPWM to 255
|
// when user uses an relais for LED control, we force here PinLEDPWM to 255
|
||||||
// to ensure nothing bad happens
|
// to ensure nothing bad happens and its turned on
|
||||||
if(UseLEDrelais == true) {
|
if(UseLEDrelais == false) {
|
||||||
PinLEDPWM = 255;
|
PinLEDPWM = 255;
|
||||||
EEPROM.put(213, PinLEDPWM);
|
EEPROM.put(213, PinLEDPWM);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
Serial.println("UseLEDrelais is 1, forcing PinLEDPWM to max to prevent relais damage");
|
Serial.println("UseLEDrelais is 0, forcing PinLEDPWM to max to prevent relais damage and ensure its turned on");
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ if(UseFANrelais == true) {
|
if(UseFANrelais == false) {
|
||||||
//~ PinFANPWM = 255;
|
PinFANPWM = 255;
|
||||||
//~ EEPROM.put(215, PinFANPWM);
|
EEPROM.put(215, PinFANPWM);
|
||||||
//~ EEPROM.commit();
|
EEPROM.commit();
|
||||||
//~ Serial.println("UseFANrelais is 1, forcing PinFANPWM to max to prevent relais damage");
|
Serial.println("UseFANrelais is 0, forcing PinFANPWM to max to prevent relais damage and ensure its turned on");
|
||||||
//~ }
|
}
|
||||||
|
|
||||||
Serial.print("configured: ");
|
Serial.print("configured: ");
|
||||||
Serial.println(configured);
|
Serial.println(configured);
|
||||||
|
|
Loading…
Reference in a new issue