Fix for missing inverse for analog bus.
Fix for usermod pin settings not being accounted for.
This commit is contained in:
parent
7463be862f
commit
d049e0a149
@ -317,15 +317,15 @@ class MultiRelay : public Usermod {
|
|||||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||||
* Values in the state object may be modified by connected clients
|
* Values in the state object may be modified by connected clients
|
||||||
*/
|
*/
|
||||||
void addToJsonState(JsonObject &root) {
|
//void addToJsonState(JsonObject &root) {
|
||||||
}
|
//}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||||
* Values in the state object may be modified by connected clients
|
* Values in the state object may be modified by connected clients
|
||||||
*/
|
*/
|
||||||
void readFromJsonState(JsonObject &root) {
|
//void readFromJsonState(JsonObject &root) {
|
||||||
}
|
//}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* provide the changeable values
|
* provide the changeable values
|
||||||
@ -335,11 +335,12 @@ class MultiRelay : public Usermod {
|
|||||||
|
|
||||||
top[FPSTR(_enabled)] = enabled;
|
top[FPSTR(_enabled)] = enabled;
|
||||||
for (uint8_t i=0; i<MULTI_RELAY_MAX_RELAYS; i++) {
|
for (uint8_t i=0; i<MULTI_RELAY_MAX_RELAYS; i++) {
|
||||||
String parName = FPSTR(_relay_str); parName += "-"; parName += i; parName += "-";
|
String parName = FPSTR(_relay_str); parName += '-'; parName += i;
|
||||||
top[parName+"pin"] = _relay[i].pin;
|
JsonObject relay = top.createNestedObject(parName);
|
||||||
top[parName+FPSTR(_activeHigh)] = _relay[i].mode;
|
relay["pin"] = _relay[i].pin;
|
||||||
top[parName+FPSTR(_delay_str)] = _relay[i].delay;
|
relay[FPSTR(_activeHigh)] = _relay[i].mode;
|
||||||
top[parName+FPSTR(_external)] = _relay[i].external;
|
relay[FPSTR(_delay_str)] = _relay[i].delay;
|
||||||
|
relay[FPSTR(_external)] = _relay[i].external;
|
||||||
}
|
}
|
||||||
DEBUG_PRINTLN(F("MultiRelay config saved."));
|
DEBUG_PRINTLN(F("MultiRelay config saved."));
|
||||||
}
|
}
|
||||||
@ -363,13 +364,19 @@ class MultiRelay : public Usermod {
|
|||||||
enabled = top[FPSTR(_enabled)] | enabled;
|
enabled = top[FPSTR(_enabled)] | enabled;
|
||||||
|
|
||||||
for (uint8_t i=0; i<MULTI_RELAY_MAX_RELAYS; i++) {
|
for (uint8_t i=0; i<MULTI_RELAY_MAX_RELAYS; i++) {
|
||||||
String parName = FPSTR(_relay_str); parName += "-"; parName += i; parName += "-";
|
String parName = FPSTR(_relay_str); parName += '-'; parName += i;
|
||||||
oldPin[i] = _relay[i].pin;
|
oldPin[i] = _relay[i].pin;
|
||||||
|
_relay[i].pin = top[parName]["pin"] | _relay[i].pin;
|
||||||
|
_relay[i].mode = top[parName][FPSTR(_activeHigh)] | _relay[i].mode;
|
||||||
|
_relay[i].external = top[parName][FPSTR(_external)] | _relay[i].external;
|
||||||
|
_relay[i].delay = top[parName][FPSTR(_delay_str)] | _relay[i].delay;
|
||||||
|
// begin backwards compatibility (beta) remove when 0.13 is released
|
||||||
|
parName += '-';
|
||||||
_relay[i].pin = top[parName+"pin"] | _relay[i].pin;
|
_relay[i].pin = top[parName+"pin"] | _relay[i].pin;
|
||||||
// _relay[i].pin = min(39,max(-1,(int)_relay[i].pin)); // bounds checking
|
|
||||||
_relay[i].mode = top[parName+FPSTR(_activeHigh)] | _relay[i].mode;
|
_relay[i].mode = top[parName+FPSTR(_activeHigh)] | _relay[i].mode;
|
||||||
_relay[i].external = top[parName+FPSTR(_external)] | _relay[i].external;
|
_relay[i].external = top[parName+FPSTR(_external)] | _relay[i].external;
|
||||||
_relay[i].delay = top[parName+FPSTR(_delay_str)] | _relay[i].delay;
|
_relay[i].delay = top[parName+FPSTR(_delay_str)] | _relay[i].delay;
|
||||||
|
// end compatibility
|
||||||
_relay[i].delay = min(600,max(0,abs((int)_relay[i].delay))); // bounds checking max 10min
|
_relay[i].delay = min(600,max(0,abs((int)_relay[i].delay))); // bounds checking max 10min
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +404,7 @@ class MultiRelay : public Usermod {
|
|||||||
DEBUG_PRINTLN(F(" config (re)loaded."));
|
DEBUG_PRINTLN(F(" config (re)loaded."));
|
||||||
}
|
}
|
||||||
// use "return !top["newestParameter"].isNull();" when updating Usermod with new features
|
// use "return !top["newestParameter"].isNull();" when updating Usermod with new features
|
||||||
return true;
|
return !top[F("relay-0")]["pin"].isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,15 +147,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (change) {
|
if (change) {
|
||||||
|
// // blazoncek experimental extension
|
||||||
// gId("ew"+n).checked = (type == 30 || type == 31 || type == 44 || type == 45); // RGBW checkbox, TYPE_xxxx values from const.h
|
// gId("ew"+n).checked = (type == 30 || type == 31 || type == 44 || type == 45); // RGBW checkbox, TYPE_xxxx values from const.h
|
||||||
gId("ls"+n).value = n+1; // set LED start
|
gId("ls"+n).value = n+1; // set LED start
|
||||||
if (type > 31 && type < 48) d.getElementsByName("LC"+n)[0].value = 1; // for sanity change analog count just to 1 LED
|
if (type > 31 && type < 48) d.getElementsByName("LC"+n)[0].value = 1; // for sanity change analog count just to 1 LED
|
||||||
}
|
}
|
||||||
|
// // blazoncek experimental extension
|
||||||
// gId("ew"+n).onclick = (type > 31 && type < 48) ? (function(){return false}) : (function(){}); // prevent change for analog
|
// gId("ew"+n).onclick = (type > 31 && type < 48) ? (function(){return false}) : (function(){}); // prevent change for analog
|
||||||
// isRGBW |= gId("ew"+n).checked;
|
// isRGBW |= gId("ew"+n).checked;
|
||||||
isRGBW |= (type == 30 || type == 31 || (type > 40 && type < 46 && type != 43)); // RGBW checkbox, TYPE_xxxx values from const.h
|
isRGBW |= (type == 30 || type == 31 || (type > 40 && type < 46 && type != 43)); // RGBW checkbox, TYPE_xxxx values from const.h
|
||||||
gId("dig"+n).style.display = (type > 31 && type < 48) ? "none":"inline"; // hide reverse, skip 1st & count for analog
|
gId("co"+n).style.display = (type == 41 || type == 42) ? "none":"inline"; // hide color order for PWM W & WW/CW
|
||||||
gId("psd"+n).innerHTML = (type > 31 && type < 48) ? "Index:":"Start:"; // change analog start description
|
gId("dig"+n+"c").style.display = (type > 40 && type < 48) ? "none":"inline"; // hide skip 1st & count for analog
|
||||||
|
gId("dig"+n+"s").style.display = (type > 40 && type < 48) ? "none":"inline"; // hide skip 1st & count for analog
|
||||||
|
gId("rev"+n).innerHTML = (type > 40 && type < 48) ? "Inverted":"Reverse (rotated 180°)"; // change reverse text for analog
|
||||||
|
gId("psd"+n).innerHTML = (type > 40 && type < 48) ? "Index:":"Start:"; // change analog start description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// display white channel calculation method
|
// display white channel calculation method
|
||||||
@ -274,7 +279,7 @@ ${i+1}:
|
|||||||
<option value="44">PWM RGBW</option>
|
<option value="44">PWM RGBW</option>
|
||||||
<option value="45">PWM RGBWC</option>
|
<option value="45">PWM RGBWC</option>
|
||||||
</select>
|
</select>
|
||||||
Color Order:
|
<div id="co${i}" style="display:inline">Color Order:
|
||||||
<select name="CO${i}">
|
<select name="CO${i}">
|
||||||
<option value="0">GRB</option>
|
<option value="0">GRB</option>
|
||||||
<option value="1">RGB</option>
|
<option value="1">RGB</option>
|
||||||
@ -282,7 +287,7 @@ Color Order:
|
|||||||
<option value="3">RBG</option>
|
<option value="3">RBG</option>
|
||||||
<option value="4">BGR</option>
|
<option value="4">BGR</option>
|
||||||
<option value="5">GBR</option>
|
<option value="5">GBR</option>
|
||||||
</select><br>
|
</select></div><br>
|
||||||
<span id="p0d${i}">GPIO:</span><input type="number" name="L0${i}" min="0" max="33" required class="s" onchange="UI()"/>
|
<span id="p0d${i}">GPIO:</span><input type="number" name="L0${i}" min="0" max="33" required class="s" onchange="UI()"/>
|
||||||
<span id="p1d${i}"></span><input type="number" name="L1${i}" min="0" max="33" class="s" onchange="UI()"/>
|
<span id="p1d${i}"></span><input type="number" name="L1${i}" min="0" max="33" class="s" onchange="UI()"/>
|
||||||
<span id="p2d${i}"></span><input type="number" name="L2${i}" min="0" max="33" class="s" onchange="UI()"/>
|
<span id="p2d${i}"></span><input type="number" name="L2${i}" min="0" max="33" class="s" onchange="UI()"/>
|
||||||
@ -290,11 +295,9 @@ Color Order:
|
|||||||
<span id="p4d${i}"></span><input type="number" name="L4${i}" min="0" max="33" class="s" onchange="UI()"/>
|
<span id="p4d${i}"></span><input type="number" name="L4${i}" min="0" max="33" class="s" onchange="UI()"/>
|
||||||
<br>
|
<br>
|
||||||
<span id="psd${i}">Start:</span> <input type="number" name="LS${i}" id="ls${i}" class="l" min="0" max="8191" value="${lastEnd(i)}" readonly required />
|
<span id="psd${i}">Start:</span> <input type="number" name="LS${i}" id="ls${i}" class="l" min="0" max="8191" value="${lastEnd(i)}" readonly required />
|
||||||
<div id="dig${i}" style="display:inline">
|
<div id="dig${i}c" style="display:inline">Count: <input type="number" name="LC${i}" class="l" min="0" max="${maxPB}" value="1" required oninput="UI()" /></div><br>
|
||||||
Count: <input type="number" name="LC${i}" class="l" min="0" max="${maxPB}" value="1" required oninput="UI()" /><br>
|
<span id="rev${i}">Reverse (rotated 180°)</span>: <input type="checkbox" name="CV${i}">
|
||||||
Reverse (rotated 180°): <input type="checkbox" name="CV${i}">
|
<div id="dig${i}s" style="display:inline"> Skip 1<sup>st</sup> LED: <input id="sl${i}" type="checkbox" name="SL${i}"></div><br>
|
||||||
Skip 1<sup>st</sup> LED: <input id="sl${i}" type="checkbox" name="SL${i}"><br>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
</div>`;
|
||||||
f.insertAdjacentHTML("beforeend", cn);
|
f.insertAdjacentHTML("beforeend", cn);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2109182
|
#define VERSION 2109191
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
|
@ -179,6 +179,52 @@ void sappends(char stype, const char* key, char* val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void extractPin(JsonObject &obj, const char *key) {
|
||||||
|
if (obj[key].is<JsonArray>()) {
|
||||||
|
JsonArray pins = obj[key].as<JsonArray>();
|
||||||
|
for (JsonVariant pv : pins) {
|
||||||
|
if (pv.as<int>() > -1) { oappend(","); oappendi(pv.as<int>()); }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (obj[key].as<int>() > -1) { oappend(","); oappendi(obj[key].as<int>()); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// oappens used pins by recursively scanning JsonObject
|
||||||
|
void fillUMPins(JsonObject &mods)
|
||||||
|
{
|
||||||
|
for (JsonPair kv : mods) {
|
||||||
|
// kv.key() is usermod name or subobject key
|
||||||
|
// kv.value() is object itself
|
||||||
|
JsonObject obj = kv.value();
|
||||||
|
if (!obj.isNull()) {
|
||||||
|
// element is an JsonObject
|
||||||
|
if (!obj["pin"].isNull()) {
|
||||||
|
extractPin(obj, "pin");
|
||||||
|
} else {
|
||||||
|
// scan keys (just one level deep as is possible with usermods)
|
||||||
|
for (JsonPair so : obj) {
|
||||||
|
const char *key = so.key().c_str();
|
||||||
|
if (strstr(key, "pin")) {
|
||||||
|
// we found a key containing "pin" substring
|
||||||
|
if (strlen(strstr(key, "pin")) == 3) {
|
||||||
|
// and it is at the end, we found another pin
|
||||||
|
extractPin(obj, key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!obj[so.key()].is<JsonObject>()) continue;
|
||||||
|
JsonObject subObj = obj[so.key()];
|
||||||
|
if (!subObj["pin"].isNull()) {
|
||||||
|
// get pins from subobject
|
||||||
|
extractPin(subObj, "pin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//get values for settings form in javascript
|
//get values for settings form in javascript
|
||||||
void getSettingsJS(byte subPage, char* dest)
|
void getSettingsJS(byte subPage, char* dest)
|
||||||
@ -268,22 +314,7 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
usermods.addToConfig(mods);
|
usermods.addToConfig(mods);
|
||||||
oappend(SET_F("d.um_p=[6,7,8,9,10,11"));
|
oappend(SET_F("d.um_p=[6,7,8,9,10,11"));
|
||||||
if (!mods.isNull()) {
|
if (!mods.isNull()) {
|
||||||
for (JsonPair kv : mods) {
|
fillUMPins(mods);
|
||||||
if (!kv.value().isNull()) {
|
|
||||||
// element is an JsonObject
|
|
||||||
JsonObject obj = kv.value();
|
|
||||||
if (obj["pin"] != nullptr) {
|
|
||||||
if (obj["pin"].is<JsonArray>()) {
|
|
||||||
JsonArray pins = obj["pin"].as<JsonArray>();
|
|
||||||
for (JsonVariant pv : pins) {
|
|
||||||
if (pv.as<int>() > -1) { oappend(","); oappendi(pv.as<int>()); }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (obj["pin"].as<int>() > -1) { oappend(","); oappendi(obj["pin"].as<int>()); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef WLED_ENABLE_DMX
|
#ifdef WLED_ENABLE_DMX
|
||||||
oappend(SET_F(",2")); // DMX hardcoded pin
|
oappend(SET_F(",2")); // DMX hardcoded pin
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user