Add Color order override settings

- Adds color order override section to settings page.
This commit is contained in:
Mike Ryan 2022-01-01 15:08:07 -06:00
parent a06846fa74
commit b8e23b2d7e
5 changed files with 97 additions and 15 deletions

View File

@ -85,6 +85,12 @@ struct ColorOrderMap {
if (_count >= WLED_MAX_COLOR_ORDER_MAPPINGS) {
return;
}
if (len == 0) {
return;
}
if (colorOrder > COL_ORDER_MAX) {
return;
}
_mappings[_count].start = start;
_mappings[_count].len = len;
_mappings[_count].colorOrder = colorOrder;

View File

@ -172,6 +172,7 @@
#define COL_ORDER_RBG 3
#define COL_ORDER_BGR 4
#define COL_ORDER_GBR 5
#define COL_ORDER_MAX 5
//Button type

View File

@ -347,6 +347,50 @@ ${i+1}:
if (!init) UI();
}
function addCOM(start=0,len=1,co=0) {
var i = d.getElementsByClassName("com_entry").length;
if (i >= 10) return;
var b = `<div class="com_entry">
<hr style="width:260px">
${i+1}: Start: <input type="number" name="XS${i}" id="xs${i}" class="l starts" min="0" max="65535" value="${start}" oninput="UI();" required="">&nbsp;
Length: <input type="number" name="XC${i}" id="xc${i}" class="l" min="1" max="65535" value="${len}" required="" oninput="UI()">
<div style="display:inline">Color Order:
<select id="xo${i}" name="XO${i}">
<option value="0">GRB</option>
<option value="1">RGB</option>
<option value="2">BRG</option>
<option value="3">RBG</option>
<option value="4">BGR</option>
<option value="5">GBR</option>
</select>
</div><br></div>`;
gId("com_entries").insertAdjacentHTML("beforeend", b);
gId("xo"+i).value = co;
btnCOM(i+1);
}
function remCOM() {
var entries = d.getElementsByClassName("com_entry");
var i = entries.length;
if (i === 0) return;
entries[i-1].remove();
btnCOM(i-1);
}
function resetCOM() {
for (let e of d.getElementsByClassName("com_entry")) {
e.remove();
}
btnCOM(0);
}
function btnCOM(i) {
gId("com_add").style.display = (i<10) ? "inline":"none";
gId("com_rem").style.display = (i>0) ? "inline":"none";
}
function addBtn(i,p,t) {
var c = gId("btns").innerHTML;
var bt = "BT" + String.fromCharCode((i<10?48:55)+i);;
@ -431,6 +475,12 @@ ${i+1}:
d.getElementsByName("CV"+i)[0].checked = v.rev;
});
}
if(c.hw.com) {
resetCOM();
c.hw.com.forEach(e => {
addCOM(e.start, e.len, e.order);
});
}
if (c.hw.btn) {
var b = c.hw.btn;
if (Array.isArray(b.ins)) gId("btns").innerHTML = "";
@ -510,6 +560,14 @@ ${i+1}:
Make a segment for each output: <input type="checkbox" name="MS"> <br>
Custom bus start indices: <input type="checkbox" onchange="tglSi(this.checked)" id="si"> <br>
<hr style="width:260px">
<div id="color_order_mapping">
Color Order Override:
<div id="com_entries"></div>
<hr style="width:260px">
<button type="button" id="com_add" onclick="addCOM();UI()" style="display:none;border-radius:20px;height:36px;">+</button>
<button type="button" id="com_rem" onclick="remCOM();UI()" style="display:none;border-radius:20px;width:36px;height:36px;">-</button><br>
</div>
<hr style="width:260px">
<div id="btns"></div>
Touch threshold: <input type="number" class="s" min="0" max="100" name="TT" required><br>
IR GPIO: <input type="number" min="-1" max="40" name="IR" onchange="UI()" class="xs"><select name="IT" onchange="UI()">

File diff suppressed because one or more lines are too long

View File

@ -421,6 +421,17 @@ void getSettingsJS(byte subPage, char* dest)
oappend(SET_F("mA\";"));
}
oappend(SET_F("resetCOM();"));
const ColorOrderMap& com = busses.getColorOrderMap();
for (uint8_t s=0; s < com.count(); s++) {
const ColorOrderMapEntry* entry = com.get(s);
if (entry == nullptr) break;
oappend(SET_F("addCOM("));
oappend(itoa(entry->start,nS,10)); oappend(",");
oappend(itoa(entry->len,nS,10)); oappend(",");
oappend(itoa(entry->colorOrder,nS,10)); oappend(");");
}
sappend('v',SET_F("CA"),briS);
sappend('c',SET_F("BO"),turnOnAtBoot);