PR Feedback

- Limit max number of color order overrides to 5 on ESP8266
- Only append color overrides if they were provided in the POST of LED
  settings.
This commit is contained in:
Mike Ryan 2022-01-13 09:06:01 -06:00
parent b8e23b2d7e
commit 5c39d8d12e
5 changed files with 20 additions and 9 deletions

View File

@ -39,7 +39,11 @@
#endif
#endif
#ifdef ESP8266
#define WLED_MAX_COLOR_ORDER_MAPPINGS 5
#else
#define WLED_MAX_COLOR_ORDER_MAPPINGS 10
#endif
//Usermod IDs
#define USERMOD_ID_RESERVED 0 //Unused. Might indicate no usermod present

View File

@ -6,7 +6,7 @@
<title>LED Settings</title>
<script>
var d=document,laprev=55,maxB=1,maxM=4000,maxPB=4096,maxL=1333,maxLbquot=0; //maximum bytes for LED allocation: 4kB for 8266, 32kB for 32
var customStarts=false,startsDirty=[];
var customStarts=false,startsDirty=[],maxCOOverrides=5;
function H()
{
window.open("https://kno.wled.ge/features/settings/#led-settings");
@ -379,7 +379,10 @@ Length: <input type="number" name="XC${i}" id="xc${i}" class="l" min="1" max="65
btnCOM(i-1);
}
function resetCOM() {
function resetCOM(_newMaxCOOverrides=undefined) {
if (_newMaxCOOverrides) {
maxCOOverrides = _newMaxCOOverrides;
}
for (let e of d.getElementsByClassName("com_entry")) {
e.remove();
}
@ -387,7 +390,7 @@ Length: <input type="number" name="XC${i}" id="xc${i}" class="l" min="1" max="65
}
function btnCOM(i) {
gId("com_add").style.display = (i<10) ? "inline":"none";
gId("com_add").style.display = (i<maxCOOverrides) ? "inline":"none";
gId("com_rem").style.display = (i>0) ? "inline":"none";
}

File diff suppressed because one or more lines are too long

View File

@ -141,10 +141,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
start = request->arg(xs).toInt();
length = request->arg(xc).toInt();
colorOrder = request->arg(xo).toInt();
com.add(start, length, colorOrder);
if (request->hasArg(xs)) {
start = request->arg(xs).toInt();
length = request->arg(xc).toInt();
colorOrder = request->arg(xo).toInt();
com.add(start, length, colorOrder);
}
}
busses.updateColorOrderMap(com);

View File

@ -421,7 +421,9 @@ void getSettingsJS(byte subPage, char* dest)
oappend(SET_F("mA\";"));
}
oappend(SET_F("resetCOM();"));
oappend(SET_F("resetCOM("));
oappend(itoa(WLED_MAX_COLOR_ORDER_MAPPINGS,nS,10));
oappend(SET_F(");"));
const ColorOrderMap& com = busses.getColorOrderMap();
for (uint8_t s=0; s < com.count(); s++) {
const ColorOrderMapEntry* entry = com.get(s);