Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platformio_override.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ build_flags = ${common.build_flags_esp8266}
; -D IRPIN=4
; -D RLYPIN=12
; -D RLYMDE=1
; -D RLYODRAIN=0
; -D LED_BUILTIN=2 # GPIO of built-in LED
;
; Limit max buses
Expand Down
4 changes: 2 additions & 2 deletions wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void handleIO()
esp32RMTInvertIdle();
#endif
if (rlyPin>=0) {
pinMode(rlyPin, OUTPUT);
pinMode(rlyPin, rlyOpenDrain ? OUTPUT_OPEN_DRAIN : OUTPUT);
digitalWrite(rlyPin, rlyMde);
}
offMode = false;
Expand All @@ -400,7 +400,7 @@ void handleIO()
esp32RMTInvertIdle();
#endif
if (rlyPin>=0) {
pinMode(rlyPin, OUTPUT);
pinMode(rlyPin, rlyOpenDrain ? OUTPUT_OPEN_DRAIN : OUTPUT);
digitalWrite(rlyPin, !rlyMde);
}
}
Expand Down
5 changes: 4 additions & 1 deletion wled00/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,14 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
CJSON(irApplyToAllSelected, hw["ir"]["sel"]);

JsonObject relay = hw[F("relay")];

rlyOpenDrain = relay[F("odrain")] | rlyOpenDrain;
int hw_relay_pin = relay["pin"] | -2;
if (hw_relay_pin > -2) {
pinManager.deallocatePin(rlyPin, PinOwner::Relay);
if (pinManager.allocatePin(hw_relay_pin,true, PinOwner::Relay)) {
rlyPin = hw_relay_pin;
pinMode(rlyPin, OUTPUT);
pinMode(rlyPin, rlyOpenDrain ? OUTPUT_OPEN_DRAIN : OUTPUT);
} else {
rlyPin = -1;
}
Expand Down Expand Up @@ -868,6 +870,7 @@ void serializeConfig() {
JsonObject hw_relay = hw.createNestedObject(F("relay"));
hw_relay["pin"] = rlyPin;
hw_relay["rev"] = !rlyMde;
hw_relay[F("odrain")] = rlyOpenDrain;

hw[F("baud")] = serialBaud;

Expand Down
5 changes: 3 additions & 2 deletions wled00/data/settings_leds.htm
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@
}
if (c.hw.relay) {
d.getElementsByName("RL")[0].value = c.hw.relay.pin;
d.getElementsByName("RM")[0].checked = c.hw.relay.inv;
d.getElementsByName("RM")[0].checked = c.hw.relay.rev;
d.getElementsByName("RO")[0].checked = c.hw.relay.odrain;
}
UI();
}
Expand Down Expand Up @@ -822,7 +823,7 @@ <h3>Hardware setup</h3>
Apply IR change to main segment only: <input type="checkbox" name="MSO"><br>
<div id="json" style="display:none;">JSON file: <input type="file" name="data" accept=".json"><button type="button" class="sml" onclick="uploadFile('/ir.json')">Upload</button><br></div>
<a href="https://kno.wled.ge/interfaces/infrared/" target="_blank">IR info</a><br>
Relay GPIO: <input type="number" min="-1" max="48" name="RL" onchange="UI()" class="xs"> Invert <input type="checkbox" name="RM"><span style="cursor: pointer;" onclick="off('RL')">&nbsp;&#x2715;</span><br>
Relay GPIO: <input type="number" min="-1" max="48" name="RL" onchange="UI()" class="xs"><span style="cursor: pointer;" onclick="off('RL')">&nbsp;&#x2715;</span> Invert <input type="checkbox" name="RM"> Open drain <input type="checkbox" name="RO"><br>
<hr class="sml">
<h3>Defaults</h3>
Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br>
Expand Down
1 change: 1 addition & 0 deletions wled00/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
rlyPin = -1;
}
rlyMde = (bool)request->hasArg(F("RM"));
rlyOpenDrain = (bool)request->hasArg(F("RO"));

disablePullUp = (bool)request->hasArg(F("IP"));
touchThreshold = request->arg(F("TT")).toInt();
Expand Down
6 changes: 6 additions & 0 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ WLED_GLOBAL bool rlyMde _INIT(true);
#else
WLED_GLOBAL bool rlyMde _INIT(RLYMDE);
#endif
//Use open drain (floating pin) when relay should be off
#ifndef RLYODRAIN
WLED_GLOBAL bool rlyOpenDrain _INIT(false);
#else
WLED_GLOBAL bool rlyOpenDrain _INIT(RLYODRAIN);
#endif
#ifndef IRPIN
#define IRPIN -1
#endif
Expand Down
1 change: 1 addition & 0 deletions wled00/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('i',SET_F("PB"),strip.paletteBlend);
sappend('v',SET_F("RL"),rlyPin);
sappend('c',SET_F("RM"),rlyMde);
sappend('c',SET_F("RO"),rlyOpenDrain);
for (uint8_t i=0; i<WLED_MAX_BUTTONS; i++) {
oappend(SET_F("addBtn("));
oappend(itoa(i,nS,10)); oappend(",");
Expand Down