Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
philbowles committed Feb 3, 2021
2 parents d4436f6 + 02b25d2 commit cc968e7
Show file tree
Hide file tree
Showing 228 changed files with 5,108 additions and 4,221 deletions.
20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Users\\phil\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
"C:\\Users\\phil\\Documents\\Arduino\\libraries\\**",
"C:\\Program Files (x86)\\Arduino\\libraries\\**",
"C:\\Users\\phil\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.7.4\\**"
],
"forcedInclude": [],
"defines": [
"USBCON"
],
"intelliSenseMode": "msvc-x64",
"cppStandard": "c++17"
}
],
"version": 4
}
15 changes: 0 additions & 15 deletions .vscode/launch.json

This file was deleted.

7 changes: 7 additions & 0 deletions LittleFS/fs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
echo off
del fs*.bin
set /p v=<../data/h4UIv
echo Making version %v%

mklittlefs -c ../data/ fs_1M.bin > nul
mklittlefs -p 256 -b 8192 -s 1024000 -c ../data/ fs_4M.bin > nul
Binary file added LittleFS/fs_1M.bin
Binary file not shown.
Binary file added LittleFS/fs_4M.bin
Binary file not shown.
Binary file added LittleFS/mklittlefs.exe
Binary file not shown.
279 changes: 172 additions & 107 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions SPIFFS/spiffs.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
echo off
del spiffs*.bin
set /p v=<../data/h4sv
set /p v=<../data/h4UI
echo Making version %v%
mkspiffs -c ../data/ spiffs_%v%_1M.bin > nul
mkspiffs -p 256 -b 8192 -s 0x0FA000 -c ../data/ spiffs_%v%_4M.bin > nul
mkspiffs -p 256 -b 8192 -s 0xFA000 -c ../data/ spiffs_%v%_4M.bin > nul
Binary file not shown.
Binary file not shown.
Binary file removed assets/GPIOsmall.jpg
Binary file not shown.
Binary file removed assets/Thumbs.db
Binary file not shown.
Binary file added assets/ccc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/empty.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fastboot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/h4plugins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/h4ui.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/phasing.xlsx
Binary file not shown.
Binary file added assets/plugins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/showfs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/showq.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/showq2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sonoff.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sonoffbasic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/svcwifi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/uidynamic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/uiinput.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/uistatic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/upnp2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/upnpsmall.jpg
Binary file not shown.
Binary file removed assets/webui056.jpg
Binary file not shown.
Binary file removed assets/xplat.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion boards.local.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##############################################################
H4_Wemos_d1mini.name=H4 Optimised Wemos D1 Mini
H4_Wemos_d1mini.build.board=ESP8266_WEMOS_D1MINI
H4_Wemos_d1mini.build.board=D1_MINI
H4_Wemos_d1mini.build.variant=d1_mini
H4_Wemos_d1mini.upload.tool=esptool
H4_Wemos_d1mini.upload.maximum_data_size=81920
Expand Down
3 changes: 1 addition & 2 deletions data/h4.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ grid-gap: 5px;
grid-template-columns: 40% 60%;
grid-gap: 5px;
}
#onoff{
#onof{
grid-column: 2;
cursor: pointer;
display: none;
Expand Down Expand Up @@ -137,7 +137,6 @@ grid-gap: 5px;
}
.tuia{
color: darkorange;
width: max-content;
}
.uia{
cursor: pointer;
Expand Down
144 changes: 90 additions & 54 deletions data/h4.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
let onof
let source

function toaster(t){
msg.innerHTML=t;
setTimeout(function () { msg.innerHTML="&nbsp;"; },30000);
}

function ajax(url,decode=true){
document.body.style.cursor = "wait";
toaster("&nbsp;");
var http = new XMLHttpRequest();
var fullurl="http://"+window.location.hostname+"/rest/"+url;
http.open('GET', fullurl);
Expand All @@ -13,96 +19,126 @@ function ajax(url,decode=true){
r.style.color="#ffffff" // css
var j=JSON.parse(e.currentTarget.responseText);
if(!j.res) j.lines.forEach(function(l){ r.innerHTML+=l+'\n'})
else msg.innerHTML="Error: "+j.res+" "+j.msg
else toaster("Error: "+j.res+" "+j.msg)
}
});
http.send();
}

function redgreen(id,b){
let i=document.getElementById(id)

function redgreen(n,b){
let i=document.getElementById(n)
i.classList.remove(b ? "led-red":"led-green");
i.classList.add(b ? "led-green":"led-red");
}
i.classList.add(b ? "led-green":"led-red");
}

function onofRender(b){
let node=document.getElementById("onof")
node.children[0].src=(b ? "on":"of")+".jpg"
}

function properCase(s){ return s.split(" ").map(function (x){ return x.charAt(0).toUpperCase() + x.slice(1) }).join(" ") }

function uiItem(d,h="uhang"){
let parts=d.split(",");
let n=parts[0]
if(!document.getElementById(n)){
let node=document.getElementById(n)
let v=parts[2]
let b=parseInt(v);
if(!node){
let hangoff=document.getElementById(h);
let t=parseInt(parts[1])
let v=parts[2]
let a=parseInt(parts[3])
let title=document.createElement("div");
title.innerHTML=n;
let valu=document.createElement("div");
title.innerHTML=properCase(n);
let valu=document.createElement(t<4 ? "div":(t==4 ? "input":"select"));
valu.id=n;
valu.className="uv";
switch(t){
case 0: // label
valu.innerHTML=v;
source.addEventListener(n, function(e){ document.getElementById(n).innerHTML=e.data; });
break;
case 1:
case 1: // text
break;
case 2:
let b=parseInt(v);
valu.classList=(a ? "uia ":"")+"ld led-"+(b ? "green":"red");
case 2: // bool
valu.classList=(a ? "uia ":"")+"ld led-"+(b==1 ? "green":"red");
source.addEventListener(n, function(e){ redgreen(n,parseInt(e.data)); });
if(a) {
valu.addEventListener("click", function(e){
ajax("h4/asws/uib/"+n+","+(valu.classList.value.indexOf("red")==-1 ? 0:1)) },
ajax("h4/wifi/uichg/"+n+","+(valu.classList.value.indexOf("red")==-1 ? 0:1)) },
{capture: true});
title.classList.add("tuia");
}
break;
case 4: // input
valu.value=v;
valu.addEventListener("blur", function(e){
if(valu.value!=v) {
v=valu.value;
ajax("h4/wifi/uichg/"+n+","+v.replace("http://",""))
}
},{capture: true});
title.classList.add("tuia");
valu.classList.add("tuia");
source.addEventListener(n, function(e){ document.getElementById(n).value=e.data; });
break;
case 5: // droplist
let opts=parts.slice(2,parts.length-1)
opts.sort()
opts.forEach(function(e){
let kv=e.split("=");
let opt=document.createElement("option");
opt.value=kv[1];
opt.innerHTML=kv[0];
valu.appendChild(opt);
})
valu.addEventListener("change", function(e){
ajax("h4/wifi/uichg/"+n+","+valu.value) },
{capture: true});
title.classList.add("tuia");
valu.classList.add("tuia");
break;
}
let hangoff=document.getElementById(h);
hangoff.insertBefore(title,null)
hangoff.insertBefore(valu,null)
}
else {
if(n=="onof"){
let img=document.createElement("img");
node.appendChild(img)
node.style.display='block'
onofRender(b);
source.addEventListener(n, function(e){ onofRender(parseInt(e.data)) });
node.addEventListener('click', function(e){ ajax("h4/toggle",false); }
);
}
}
}
let dt;

function has(id){ return document.getElementById("has"+id).value!="?" }

document.addEventListener("DOMContentLoaded", function() {
if(!!window.EventSource) source=new EventSource("/evt");
let rr=document.getElementById("reply")
let cmd=document.getElementById("cmd")
let msg=document.getElementById("msg")
// frig ap test
//wifimode=2
if(parseInt(document.getElementById("wifi").value)==2) document.getElementById("ap").style.display='inline-grid'
else {
source.addEventListener('ui', function(e){ uiItem(e.data) });
source.onmessage=function(e){
let m=e.data;
if(m.substr(0,2)!='ka'){
msg.innerHTML=e.data;
setTimeout(function () { msg.innerHTML="&nbsp;"; },30000);
};
}
source.onmessage({data: "Thank you for using H4/Plugins"});
if(has("frnd")){
frnd=document.getElementById("frnd");
frnd.style.display='inline-flex'
}
if(has("onof")){
onof=document.getElementById("onof");
onof.parentNode.style.display='block'
onof.addEventListener('click', function(e){ ajax("h4/toggle",false); });
source.addEventListener('onof', function(e){ onof.src=parseInt(e.data) ? "on.jpg":"of.jpg" });
}
document.getElementById("cc").addEventListener('submit', function(e){
e.preventDefault();
ajax(cmd.value,true);
},{capture: true});
rr.addEventListener('click', function(e){
let lines=rr.value.split("\n")
let n=rr.value.substr(0, rr.selectionStart).split("\n").length
cmd.value=lines[n-1]
ajax(lines[n-1],true)
},{capture: true});
document.getElementById("qh").addEventListener('click', function(e){ ajax("help",true) },{capture: true});
}

source.addEventListener('ui', function(e){ uiItem(e.data) });
source.onmessage=function(e){ toaster(e.data) }
source.onerror=function(e){ document.querySelectorAll('div.uv').forEach(function(d){ d.style.background="#ff0000" })}

toaster("Thank you for using H4/Plugins - please support me on Patreon, see link below");

document.getElementById("cc").addEventListener('submit', function(e){
e.preventDefault();
ajax(cmd.value,true);
},{capture: true});

rr.addEventListener('click', function(e){
let lines=rr.value.split("\n")
let n=rr.value.substr(0, rr.selectionStart).split("\n").length
cmd.value=lines[n-1]
ajax(lines[n-1],true)
},{capture: true});

document.getElementById("qh").addEventListener('click', function(e){ ajax("help",true) },{capture: true});
})
1 change: 1 addition & 0 deletions data/h4UI
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1
1 change: 0 additions & 1 deletion data/h4sv

This file was deleted.

7 changes: 7 additions & 0 deletions data/srch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
M-SEARCH * HTTP/1.1
ST: upnp:rootdevice
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 10
Content-Length: 0

45 changes: 8 additions & 37 deletions data/sta.htm
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,13 @@
<body>
<div id="main">
<input id="hasfrnd" type="hidden" value="%name%">
<input id="hasonof" type="hidden" value="%onof%">
<input id="wifi" type="hidden" value="%wifi%">
<div id="header">
<img src="H4PLogo.jpg">
</div>
<div id="device" class="line">
<div class="title">Device</div>
<div class="data">%device%.local</div>
</div>
<div id="frnd" class="line">
<div class="title">Name</div>
<div class="data">%name%</div>
</div>
<div id="ip" class="line">
<div class="title">IP Address</div>
<div class="data">%ip%</div>
</div>
<div id="board" class="line">
<div class="title">Board</div>
<div class="data">%board%</div>
</div>
<div id="chip" class="line">
<div class="title">Chip</div>
<div class="data">%chip%</div>
</div>
<div id="h4v" class="line">
<div class="title">H4 Vn</div>
<div class="data">%h4v%</div>
</div>
<div id="h4pv" class="line">
<div class="title">Plugins Vn</div>
<div class="data">%h4pv%</div>
</div>
<div id="h4sv" class="line">
<div class="title">Spiffs Vn</div>
<div class="data">%h4sv%</div>
</div>
<div id="uhang">
</div>
<div id="onoff" class="line">
<img id="onof" src="of.jpg">
<div id="onof" class="line">
</div>
<div id="cchang">
<form id="cc">
Expand All @@ -63,6 +29,7 @@
</form>
</div>
<marquee id="msg">&nbsp;</marquee>
<!--
<div id="ap">
<form type="application/url-encoded" method="POST">
<div class="fline">
Expand Down Expand Up @@ -94,6 +61,8 @@
</div>
</form>
</div>
-->

<div id="footer"><hr>
<div id="donate" class="box">
Buying me a coffee helps keep me motivated to keep H4Plugins bug-free and er ...plain "free". It's a lot of work.
Expand All @@ -110,9 +79,11 @@
target="_blank">Support me on Patreon</a></div>
</div>
<hr>
<div>&copy; 2020 Phil Bowles [email protected]</div>
<div class="lnk"><a href="https://github.com/philbowles/H4Plugins" rel="noopener"
target="_blank">&copy; 2021 Phil Bowles https://github.com/philbowles/H4Plugins</a></div>
</div>
</div>
</div>
</div class="">
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion data/ucom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EXT:
LOCATION: http://%ip%:80/we
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: %chip%
SERVER: Forked AsyncWebServer, UPnP/1.0, H4/%h4v%
SERVER: Forked AsyncWebServer, UPnP/1.0, H4/%h4P%
X-H4-Device: %device%
X-H4-Chip: %chip%
X-User-Agent: redsonic
Expand Down
2 changes: 1 addition & 1 deletion data/up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<manufacturerURL>https://github.com/philbowles/H4</manufacturerURL>
<modelDescription>Chez ToiioT H4</modelDescription>
<modelName>%board%</modelName>
<modelNumber>%h4v%</modelNumber>
<modelNumber>%h4P%</modelNumber>
<modelURL>/</modelURL>
<serialNumber>%chip%</serialNumber>
<UDN>uuid:%udn%</UDN>
Expand Down
Loading

0 comments on commit cc968e7

Please sign in to comment.