ColoOrderMap W channel swap

& cleanup
This commit is contained in:
Blaz Kristan 2024-01-11 20:22:42 +01:00
parent 447324b59f
commit 99efbd30f1
9 changed files with 580 additions and 573 deletions

16
wled00/bus_manager.cpp Normal file → Executable file
View File

@ -53,7 +53,8 @@ void ColorOrderMap::add(uint16_t start, uint16_t len, uint8_t colorOrder) {
if (len == 0) {
return;
}
if (colorOrder > COL_ORDER_MAX) {
// upper nibble contains W swap information
if ((colorOrder & 0x0F) > COL_ORDER_MAX) {
return;
}
_mappings[_count].start = start;
@ -63,12 +64,13 @@ void ColorOrderMap::add(uint16_t start, uint16_t len, uint8_t colorOrder) {
}
uint8_t IRAM_ATTR ColorOrderMap::getPixelColorOrder(uint16_t pix, uint8_t defaultColorOrder) const {
if (_count == 0) return defaultColorOrder;
// upper nibble containd W swap information
uint8_t swapW = defaultColorOrder >> 4;
for (unsigned i = 0; i < _count; i++) {
if (pix >= _mappings[i].start && pix < (_mappings[i].start + _mappings[i].len)) {
return _mappings[i].colorOrder | (swapW << 4);
if (_count > 0) {
// upper nibble contains W swap information
// when ColorOrderMap's upper nibble contains value >0 then swap information is used from it, otherwise global swap is used
for (unsigned i = 0; i < _count; i++) {
if (pix >= _mappings[i].start && pix < (_mappings[i].start + _mappings[i].len)) {
return _mappings[i].colorOrder | ((_mappings[i].colorOrder >> 4) ? 0 : (defaultColorOrder & 0xF0));
}
}
}
return defaultColorOrder;

2
wled00/cfg.cpp Normal file → Executable file
View File

@ -417,7 +417,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
CJSON(notifyButton, if_sync_send["btn"]);
CJSON(notifyAlexa, if_sync_send["va"]);
CJSON(notifyHue, if_sync_send["hue"]);
// CJSON(notifyMacro, if_sync_send["macro"]);
CJSON(syncGroups, if_sync_send["grp"]);
if (if_sync_send[F("twice")]) udpNumRetries = 1; // import setting from 0.13 and earlier
CJSON(udpNumRetries, if_sync_send["ret"]);
@ -886,7 +885,6 @@ void serializeConfig() {
if_sync_send["btn"] = notifyButton;
if_sync_send["va"] = notifyAlexa;
if_sync_send["hue"] = notifyHue;
// if_sync_send["macro"] = notifyMacro;
if_sync_send["grp"] = syncGroups;
if_sync_send["ret"] = udpNumRetries;

13
wled00/data/settings_leds.htm Normal file → Executable file
View File

@ -471,7 +471,7 @@ mA/LED: <select name="LAsel${i}" onchange="enLA(this,${i});UI();">
<hr class="sml">
${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:
<div>Color Order:
<select id="xo${i}" name="XO${i}">
<option value="0">GRB</option>
<option value="1">RGB</option>
@ -480,9 +480,16 @@ Length: <input type="number" name="XC${i}" id="xc${i}" class="l" min="1" max="65
<option value="4">BGR</option>
<option value="5">GBR</option>
</select>
</div><br></div>`;
Swap: <select id="xw${i}" name="XW${i}">
<option value="0">Use global</option>
<option value="1">W & B</option>
<option value="2">W & G</option>
<option value="3">W & R</option>
</select>
</div></div>`;
gId("com_entries").insertAdjacentHTML("beforeend", b);
gId("xo"+i).value = co;
gId("xo"+i).value = co & 0x0F;
gId("xw"+i).value = co >> 4;
btnCOM(i+1);
UI();
}

1
wled00/data/settings_sync.htm Normal file → Executable file
View File

@ -146,7 +146,6 @@ Send notifications on direct change: <input type="checkbox" name="SD"><br>
Send notifications on button press or IR: <input type="checkbox" name="SB"><br>
Send Alexa notifications: <input type="checkbox" name="SA"><br>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
<!-- Send Macro notifications: <input type="checkbox" name="SM"><br> -->
UDP packet retransmissions: <input name="UR" type="number" min="0" max="30" class="d5" required><br><br>
<i>Reboot required to apply changes. </i>
<hr class="sml">

File diff suppressed because it is too large Load Diff

5
wled00/set.cpp Normal file → Executable file
View File

@ -190,10 +190,12 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
char xs[4] = "XS"; xs[2] = 48+s; xs[3] = 0; //start LED
char xc[4] = "XC"; xc[2] = 48+s; xc[3] = 0; //strip length
char xo[4] = "XO"; xo[2] = 48+s; xo[3] = 0; //color order
char xw[4] = "XW"; xw[2] = 48+s; xw[3] = 0; //W swap
if (request->hasArg(xs)) {
start = request->arg(xs).toInt();
length = request->arg(xc).toInt();
colorOrder = request->arg(xo).toInt();
colorOrder = request->arg(xo).toInt() & 0x0F;
colorOrder |= (request->arg(xw).toInt() & 0x0F) << 4; // add W swap information
com.add(start, length, colorOrder);
}
}
@ -336,7 +338,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
notifyButton = request->hasArg(F("SB"));
notifyAlexa = request->hasArg(F("SA"));
notifyHue = request->hasArg(F("SH"));
notifyMacro = request->hasArg(F("SM"));
t = request->arg(F("UR")).toInt();
if ((t>=0) && (t<30)) udpNumRetries = t;

3
wled00/wled.h Normal file → Executable file
View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2401060
#define VERSION 2401110
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
@ -395,7 +395,6 @@ WLED_GLOBAL bool receiveSegmentBounds _INIT(false); // apply segme
WLED_GLOBAL bool notifyDirect _INIT(false); // send notification if change via UI or HTTP API
WLED_GLOBAL bool notifyButton _INIT(false); // send if updated by button or infrared remote
WLED_GLOBAL bool notifyAlexa _INIT(false); // send notification if updated via Alexa
WLED_GLOBAL bool notifyMacro _INIT(false); // send notification for macro
WLED_GLOBAL bool notifyHue _INIT(true); // send notification if Hue light changes
WLED_GLOBAL uint8_t udpNumRetries _INIT(0); // Number of times a UDP sync message is retransmitted. Increase to increase reliability

2
wled00/wled_eeprom.cpp Normal file → Executable file
View File

@ -321,7 +321,7 @@ void loadSettingsFromEEPROM()
}
receiveDirect = !EEPROM.read(2200);
notifyMacro = EEPROM.read(2201);
//notifyMacro = EEPROM.read(2201);
//strip.rgbwMode = EEPROM.read(2203);
//skipFirstLed = EEPROM.read(2204);

10
wled00/xml.cpp Normal file → Executable file
View File

@ -424,9 +424,9 @@ void getSettingsJS(byte subPage, char* dest)
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(");");
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);
@ -451,7 +451,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',SET_F("RM"),rlyMde);
for (uint8_t i=0; i<WLED_MAX_BUTTONS; i++) {
oappend(SET_F("addBtn("));
oappend(itoa(i,nS,10)); oappend(",");
oappend(itoa(i,nS,10)); oappend(",");
oappend(itoa(btnPin[i],nS,10)); oappend(",");
oappend(itoa(buttonType[i],nS,10));
oappend(SET_F(");"));
@ -466,7 +466,6 @@ void getSettingsJS(byte subPage, char* dest)
if (subPage == SUBPAGE_UI)
{
sappends('s',SET_F("DS"),serverDescription);
//sappend('c',SET_F("ST"),syncToggleReceive);
sappend('c',SET_F("SU"),simplifiedUI);
}
@ -493,7 +492,6 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',SET_F("SD"),notifyDirect);
sappend('c',SET_F("SB"),notifyButton);
sappend('c',SET_F("SH"),notifyHue);
// sappend('c',SET_F("SM"),notifyMacro);
sappend('v',SET_F("UR"),udpNumRetries);
sappend('c',SET_F("NL"),nodeListEnabled);