Add notice if no usermod installed

This commit is contained in:
cschwinne 2021-05-11 23:21:57 +02:00
parent 5ca8bc3f2a
commit cb7b7f1dca
9 changed files with 36 additions and 23 deletions

View File

@ -2,6 +2,11 @@
### Builds after release 0.12.0 ### Builds after release 0.12.0
#### Build 2105112
- Usermod settings page no usermods message
- Lowered min speed for Drip effect
#### Build 2105111 #### Build 2105111
- Fixed various Codacy code style and logic issues - Fixed various Codacy code style and logic issues

View File

@ -344,6 +344,10 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()=====";
str str
.replace(/\<link rel="stylesheet".*\>/gms, "") .replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%") .replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(
/function GetV().*\<\/script\>/gms,
"function GetV() {var d=document;\n"
),
} }
], ],
"wled00/html_settings.h" "wled00/html_settings.h"

View File

@ -3085,7 +3085,7 @@ uint16_t WS2812FX::mode_drip(void)
numDrops = 1 + (SEGMENT.intensity >> 6); numDrops = 1 + (SEGMENT.intensity >> 6);
float gravity = -0.001 - (SEGMENT.speed/50000.0); float gravity = -0.0005 - (SEGMENT.speed/50000.0);
gravity *= SEGLEN; gravity *= SEGLEN;
int sourcedrop = 12; int sourcedrop = 12;

View File

@ -182,9 +182,7 @@
} }
} }
function GetV() function GetV(){var d=document;}
{
}
</script> </script>
<style> <style>
@import url("style.css"); @import url("style.css");

View File

@ -3,14 +3,15 @@
<head lang="en"> <head lang="en">
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=500"> <meta name="viewport" content="width=500">
<title>UI Settings</title> <title>Usermod Settings</title>
<script> <script>
var d = document; var d = document;
var umCfg = {}; var umCfg = {};
var pins = [6,7,8,9,10,11]; var pins = [6,7,8,9,10,11];
var pinO = ["reserved","reserved","reserved","reserved","reserved","reserved"], owner; var pinO = ["rsvd","rsvd","rsvd","rsvd","rsvd","rsvd"], owner;
var loc = false, locip; var loc = false, locip;
var urows; var urows;
var numM = 0;
function gId(s) { return d.getElementById(s); } function gId(s) { return d.getElementById(s); }
function isO(i) { return (i && typeof i === 'object' && !Array.isArray(i)); } function isO(i) { return (i && typeof i === 'object' && !Array.isArray(i)); }
function H() { window.open("https://github.com/Aircoookie/WLED/wiki/Settings#usermod-settings"); } function H() { window.open("https://github.com/Aircoookie/WLED/wiki/Settings#usermod-settings"); }
@ -24,7 +25,9 @@
localStorage.setItem('locIp', locip); localStorage.setItem('locIp', locip);
} }
} }
ldS(); GetV();
if (numM > 0 || locip) ldS();
else gId("um").innerHTML = "No Usermods installed.";
} }
function check(o,k) { function check(o,k) {
var n = o.name.replace("[]","").substr(-3); var n = o.name.replace("[]","").substr(-3);
@ -99,11 +102,8 @@
urows += `<hr><h3>${k}</h3>`; urows += `<hr><h3>${k}</h3>`;
addField(k,'unknown',o); addField(k,'unknown',o);
} }
if (urows==="")
urows = "No Usermods configuration found.<br>Press <i>Save</i> to initialize defaults.";
} else {
urows = "Usermods configuration not found.<br>Most likely no Usermods exist.<br>Press <i>Save</i> to initialize defaults.";
} }
if (urows==="") urows = "Usermods configuration not found.<br>Press <i>Save</i> to initialize defaults.";
gId("um").innerHTML = urows; gId("um").innerHTML = urows;
}) })
.catch(function (error) { .catch(function (error) {

View File

@ -96,13 +96,12 @@ bool bufferedFindSpace(uint16_t targetLen, bool fromStart = true) {
if (!f || !f.size()) return false; if (!f || !f.size()) return false;
uint16_t index = 0; uint16_t index = 0;
uint16_t bufsize = 0, count = 0;
byte buf[FS_BUFSIZE]; byte buf[FS_BUFSIZE];
if (fromStart) f.seek(0); if (fromStart) f.seek(0);
while (f.position() < f.size() -1) { while (f.position() < f.size() -1) {
bufsize = f.read(buf, FS_BUFSIZE); uint16_t bufsize = f.read(buf, FS_BUFSIZE);
count = 0; uint16_t count = 0;
while (count < bufsize) { while (count < bufsize) {
if(buf[count] == ' ') { if(buf[count] == ' ') {
@ -139,13 +138,12 @@ bool bufferedFindObjectEnd() {
if (!f || !f.size()) return false; if (!f || !f.size()) return false;
uint16_t objDepth = 0; //num of '{' minus num of '}'. return once 0 uint16_t objDepth = 0; //num of '{' minus num of '}'. return once 0
uint16_t bufsize = 0, count = 0;
//size_t start = f.position(); //size_t start = f.position();
byte buf[FS_BUFSIZE]; byte buf[FS_BUFSIZE];
while (f.position() < f.size() -1) { while (f.position() < f.size() -1) {
bufsize = f.read(buf, FS_BUFSIZE); uint16_t bufsize = f.read(buf, FS_BUFSIZE);
count = 0; uint16_t count = 0;
while (count < bufsize) { while (count < bufsize) {
if (buf[count] == '{') objDepth++; if (buf[count] == '{') objDepth++;

View File

@ -394,9 +394,9 @@ type="submit">Save & Reboot</button></form></body></html>)=====";
// Autogenerated from wled00/data/settings_um.htm, do not edit!! // Autogenerated from wled00/data/settings_um.htm, do not edit!!
const char PAGE_settings_um[] PROGMEM = R"=====(<!DOCTYPE html><html><head lang="en"><meta charset="utf-8"><meta const char PAGE_settings_um[] PROGMEM = R"=====(<!DOCTYPE html><html><head lang="en"><meta charset="utf-8"><meta
name="viewport" content="width=500"><title>UI Settings</title><script> name="viewport" content="width=500"><title>Usermod Settings</title><script>
var owner,locip,urows,d=document,umCfg={},pins=[6,7,8,9,10,11],pinO=["reserved","reserved","reserved","reserved","reserved","reserved"],loc=!1;function gId(e){return d.getElementById(e)}function isO(e){return e&&"object"==typeof e&&!Array.isArray(e)}function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#usermod-settings")}function B(){window.open("/settings","_self")}function S(){"file:"==window.location.protocol&&(loc=!0,(locip=localStorage.getItem("locIp"))||(locip=prompt("File Mode. Please enter WLED IP!"),localStorage.setItem("locIp",locip))),ldS()}function check(e,o){var n=e.name.replace("[]","").substr(-3);if("number"==e.type&&"pin"==n.substr(0,3))for(var i=0;i<pins.length;i++)if(o!=pinO[i]){if(e.value==pins[i]||e.value<-1||e.value>39){e.style.color="red";break}e.style.color=e.value>33?"orange":"#fff"}}function getPins(e){if(isO(e))for(const[n,i]of Object.entries(e))if(isO(i))owner=n,getPins(i);else if("pin"==n.replace("[]","").substr(-3))if(Array.isArray(i))for(var o=0;o<i.length;o++)i[o]>=0&&(pins.push(i[o]),pinO.push(owner));else i>=0&&(pins.push(i),pinO.push(owner));else if(Array.isArray(i))for(o=0;o<i.length;o++)getPins(i[o])}function addField(e,o,n,i=!1){if(isO(n))for(const[o,i]of Object.entries(n))addField(e,o,i);else if(Array.isArray(n))for(var r=0;r<n.length;r++)addField(e,o,n[r],!0);else{var s,t;switch(typeof n){case"boolean":s="checkbox",t=n?'checked value="on"':"";break;case"number":s="number",t=`value="${parseInt(n,10)}"`;break;case"string":default:s="text",t=`value="${n}"`}"checkbox"==s&&(urows+=`<input type="hidden" name="${e}_${o}${i?"[]":""}" value="off">`),urows+=`${o}: <input type="${s}" name="${e}_${o}${i?"[]":""}" ${t} oninput="check(this,'${e}')"><br>`}}function ldS(){fetch((loc?"http://"+locip:"")+"/cfg.json",{method:"get"}).then(e=>(e.ok||(gId("lserr").style.display="inline"),e.json())).then(e=>{if(umCfg=e.um,getPins(e),urows="",isO(umCfg)){for(const[e,o]of Object.entries(umCfg))urows+=`<hr><h3>${e}</h3>`,addField(e,"unknown",o);""===urows&&(urows="No Usermods configuration found.<br>Press <i>Save</i> to initialize defaults.")}else urows="Usermods configuration not found.<br>Most likely no Usermods exist.<br>Press <i>Save</i> to initialize defaults.";gId("um").innerHTML=urows}).catch((function(e){gId("lserr").style.display="inline",console.log(e)}))}function svS(e){e.preventDefault(),console.log(d.Sf),d.Sf.checkValidity()&&d.Sf.submit()}function GetV(){} var owner,locip,urows,d=document,umCfg={},pins=[6,7,8,9,10,11],pinO=["rsvd","rsvd","rsvd","rsvd","rsvd","rsvd"],loc=!1,numM=0;function gId(e){return d.getElementById(e)}function isO(e){return e&&"object"==typeof e&&!Array.isArray(e)}function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#usermod-settings")}function B(){window.open("/settings","_self")}function S(){"file:"==window.location.protocol&&(loc=!0,(locip=localStorage.getItem("locIp"))||(locip=prompt("File Mode. Please enter WLED IP!"),localStorage.setItem("locIp",locip))),GetV(),numM>0||locip?ldS():gId("um").innerHTML="No Usermods installed."}function check(e,n){var o=e.name.replace("[]","").substr(-3);if("number"==e.type&&"pin"==o.substr(0,3))for(var i=0;i<pins.length;i++)if(n!=pinO[i]){if(e.value==pins[i]||e.value<-1||e.value>39){e.style.color="red";break}e.style.color=e.value>33?"orange":"#fff"}}function getPins(e){if(isO(e))for(const[o,i]of Object.entries(e))if(isO(i))owner=o,getPins(i);else if("pin"==o.replace("[]","").substr(-3))if(Array.isArray(i))for(var n=0;n<i.length;n++)i[n]>=0&&(pins.push(i[n]),pinO.push(owner));else i>=0&&(pins.push(i),pinO.push(owner));else if(Array.isArray(i))for(n=0;n<i.length;n++)getPins(i[n])}function addField(e,n,o,i=!1){if(isO(o))for(const[n,i]of Object.entries(o))addField(e,n,i);else if(Array.isArray(o))for(var t=0;t<o.length;t++)addField(e,n,o[t],!0);else{var r,s;switch(typeof o){case"boolean":r="checkbox",s=o?'checked value="on"':"";break;case"number":r="number",s=`value="${parseInt(o,10)}"`;break;case"string":default:r="text",s=`value="${o}"`}"checkbox"==r&&(urows+=`<input type="hidden" name="${e}_${n}${i?"[]":""}" value="off">`),urows+=`${n}: <input type="${r}" name="${e}_${n}${i?"[]":""}" ${s} oninput="check(this,'${e}')"><br>`}}function ldS(){fetch((loc?"http://"+locip:"")+"/cfg.json",{method:"get"}).then(e=>(e.ok||(gId("lserr").style.display="inline"),e.json())).then(e=>{if(umCfg=e.um,getPins(e),urows="",isO(umCfg))for(const[e,n]of Object.entries(umCfg))urows+=`<hr><h3>${e}</h3>`,addField(e,"unknown",n);""===urows&&(urows="Usermods configuration not found.<br>Press <i>Save</i> to initialize defaults."),gId("um").innerHTML=urows}).catch((function(e){gId("lserr").style.display="inline",console.log(e)}))}function svS(e){e.preventDefault(),console.log(d.Sf),d.Sf.checkValidity()&&d.Sf.submit()}function GetV() {var d=document;
</script>%CSS%%SCSS%</head><body onload="S()"><form %CSS%%SCSS%</head><body onload="S()"><form
id="form_s" name="Sf" method="post" onsubmit="svS(event)"><div class="toprow"> id="form_s" name="Sf" method="post" onsubmit="svS(event)"><div class="toprow">
<div class="helpB"><button type="button" onclick="H()">?</button></div><button <div class="helpB"><button type="button" onclick="H()">?</button></div><button
type="button" onclick="B()">Back</button><button type="submit">Save</button><br> type="button" onclick="B()">Back</button><button type="submit">Save</button><br>

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2105111 #define VERSION 2105112
//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

View File

@ -185,7 +185,7 @@ void getSettingsJS(byte subPage, char* dest)
obuf = dest; obuf = dest;
olen = 0; olen = 0;
if (subPage <1 || subPage >7) return; if (subPage <1 || subPage >8) return;
if (subPage == 1) { if (subPage == 1) {
sappends('s',SET_F("CS"),clientSSID); sappends('s',SET_F("CS"),clientSSID);
@ -520,5 +520,13 @@ void getSettingsJS(byte subPage, char* dest)
sappend('i',SET_F("CH15"),DMXFixtureMap[14]); sappend('i',SET_F("CH15"),DMXFixtureMap[14]);
} }
#endif #endif
if (subPage == 8) //usermods
{
oappend(SET_F("numM="));
oappendi(usermods.getModCount());
oappend(";");
}
oappend(SET_F("}</script>")); oappend(SET_F("}</script>"));
} }