diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 0f8b309e..fb235c92 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -389,6 +389,69 @@ ${i+1}: req.send(formData); d.Sf.data.value = ''; return false; + } + // https://stackoverflow.com/questions/7346563/loading-local-json-file + function loadCfg(o) { + var f, fr; + + if (typeof window.FileReader !== 'function') { + alert("The file API isn't supported on this browser yet."); + return; + } + + if (!o.files) { + alert("This browser doesn't seem to support the `files` property of file inputs."); + } else if (!o.files[0]) { + alert("Please select a file before clicking 'Load'"); + } else { + f = o.files[0]; + fr = new FileReader(); + fr.onload = receivedText; + fr.readAsText(f); + } + d.Sf.data2.value = ''; + + function receivedText(e) { + let lines = e.target.result; + var c = JSON.parse(lines); + if (c.hw) { + //console.log(c.hw); + if (c.hw.led) { + for (var i=0; i<10; i++) addLEDs(-1); + var l = c.hw.led; + l.ins.forEach((v,i,a)=>{ + addLEDs(1); + for (var j=0; j{ + addBtn(i,v.pin[0],v.type); + }); + d.getElementsByName("TT")[0].value = b.tt; + } + if (c.hw.ir) { + d.getElementsByName("IR")[0].value = c.hw.ir.pin; + d.getElementsByName("IT")[0].value = c.hw.ir.type; + } + if (c.hw.relay) { + d.getElementsByName("RL")[0].value = c.hw.relay.pin; + d.getElementsByName("RM")[0].checked = c.hw.relay.inv; + } + UI(); + } + } } function GetV() { @@ -507,7 +570,10 @@ ${i+1}: -

+
+
+
Config template:
+
diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 718aa56e..d1affb4b 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -77,7 +77,7 @@ onclick="B()">Back // Autogenerated from wled00/data/settings_leds.htm, do not edit!! const char PAGE_settings_leds[] PROGMEM = R"=====(LED Settings