firmware - improve output init, fix typos

This commit is contained in:
DeltaLima 2024-12-11 23:31:30 +01:00
parent d0ea1588b5
commit 35ed7ba616
3 changed files with 18 additions and 13 deletions

View file

@ -242,12 +242,9 @@ void setup() {
// we do this here because otherwise on inverted // we do this here because otherwise on inverted
// boards like CanGrow PCB v0.6 it would be turned on // boards like CanGrow PCB v0.6 it would be turned on
if(configured == true) { if(configured == true) {
pinMode(PinLED, OUTPUT); initOutputs();
pinMode(PinPUMP, OUTPUT);
pinMode(PinFAN, OUTPUT);
// set PWM frequency
analogWriteFreq(PWMFrequency);
} }
} }

View file

@ -830,3 +830,13 @@ void controlFAN() {
setOutput(4, PinFAN2PWM); setOutput(4, PinFAN2PWM);
} }
void initOutputs() {
pinMode(PinLED, OUTPUT);
pinMode(PinPUMP, OUTPUT);
pinMode(PinFAN, OUTPUT);
// set PWM frequency
analogWriteFreq(PWMFrequency);
for(byte i = 1; i <= 4; i++) {
setOutput(i, 0);
}
}

View file

@ -218,26 +218,26 @@ void SysMaintenance() {
if( (webserver.hasArg("DimmOn")) ) { if( (webserver.hasArg("DimmOn")) ) {
MaintenanceMode = true; MaintenanceMode = true;
MaintenanceStarted = millis(); MaintenanceStarted = millis();
body += "<div class='infomsg'>&#x26C5; Dimm LED On for "; body += "<div class='infomsg'>&#x26C5; Dimm LED ON for ";
body += MaintenanceDuration; body += MaintenanceDuration;
body += "s</div>"; body += "s</div>";
} else if( (webserver.hasArg("DimmOff")) ) { } else if( (webserver.hasArg("DimmOff")) ) {
MaintenanceMode = false; MaintenanceMode = false;
body += "<div class='infomsg'>&#x26C5; Dimm LED Off</div>"; body += "<div class='infomsg'>&#x26C5; Dimm LED OFF</div>";
} }
} else { } else {
// otherwise nice error // otherwise nice error
body += "<div class='warnmsg'>&#x26C5; LED setting <pre>Use relais for LED (disable PWM)<pre> is set to <b>Yes</b> in &#128262; Grow settings</div>"; body += "<div class='warnmsg'>&#x26C5; Cannot dimm LED, <i>Use relais for LED (disable PWM)</i> is set to <i>Yes</i> in &#128262; Grow settings</div>";
} }
} else if(webserver.hasArg("PumpOnManual")) { } else if(webserver.hasArg("PumpOnManual")) {
if(UsePump == true) { if(UsePump > 0) {
PumpOnManual = true; PumpOnManual = true;
body += "<div class='infomsg'>&#x1F4A7; Pump manual activated for "; body += "<div class='infomsg'>&#x1F4A7; Pump manual activated for ";
body += PumpOnTime; body += PumpOnTime;
body += "s</div>"; body += "s</div>";
} else { } else {
body += "<div class='warnmsg'>&#x1F4A7; Pump mode is set to <b>Off</b> in &#128262; Grow settings</div>"; body += "<div class='warnmsg'>&#x1F4A7; Cannot activate, <i>Pump mode</i> is set to <i>Off</i> in &#128262; Grow settings</div>";
} }
} }
@ -1036,9 +1036,7 @@ void POSTsystemSettings() {
// when configured is false, set it to true and ensure outputs are set // when configured is false, set it to true and ensure outputs are set
if(configured == false) { if(configured == false) {
configured = true; configured = true;
pinMode(PinLED, OUTPUT); initOutputs();
pinMode(PinPUMP, OUTPUT);
pinMode(PinFAN, OUTPUT);
} }
// size is 1 byte // size is 1 byte