-<!DOCTYPE html><html><head><title>Arduino-View</title><meta name="description" content="Host websites on an Arduino an communicate between both parties WebSerial in Google Chrome. For more information and configuration, see:<br /><a href='https://github.com/edrys-labs/module-arduino-view' target='_blank'>https://github.com/edrys-labs/module-arduino-view</a>"><meta name="show-in" content="station"><script src="https://edrys-labs.github.io/module/edrys.js"></script><script defer src="https://edrys-labs.github.io/module/vendor/alpine.min.js"></script><link rel="stylesheet" href="https://edrys-labs.github.io/module/vendor/water.min.css"><style>body{margin:1rem;padding:0;font-family:Arial,sans-serif;overflow:hidden;min-width:calc(100% - 2rem)!important}input,select,button{display:inline-block!important}input[type=checkbox]{margin-top:.65rem}#reload{float:right;margin-right:0}#sandbox{background-color:#fff;border:1px solid #000;width:100%;height:calc(100vh - 70px);margin:0;padding:0}</style><script>window.state={autoconnect:!1,baudrate:"9600",connected:!1},window.binary={encode:function(e){let n="",t=new Uint8Array(e),d=t.byteLength;for(let e=0;e<d;e++)n+=String.fromCharCode(t[e]);return btoa(n)},decode:function(e){let n=atob(e),t=n.length,d=new Uint8Array(t);for(let e=0;e<t;e++)d[e]=n.charCodeAt(e);return d.buffer}},window.update=function(e){void 0===e?(window.state.baudrate=document.getElementById("baudrate").value,window.state.autoconnect=document.getElementById("autoconnect").checked,window.state.connected="Disconnect"===document.getElementById("connect").innerText,window.send("update",window.state)):(window.state.baudrate=e.baudrate,window.state.autoconnect=e.autoconnect,window.state.connected=e.connected,document.getElementById("autoconnect").checked=e.autoconnect,document.getElementById("baudrate").value=e.baudrate,e.connected?(document.getElementById("connect").innerText="Disconnect",document.getElementById("connect").disabled=!1,document.getElementById("autoconnect").disabled=!0,document.getElementById("baudrate").disabled=!0):(document.getElementById("connect").innerText="Connect",document.getElementById("connect").disabled=!1,document.getElementById("autoconnect").disabled=!1,document.getElementById("baudrate").disabled=!1))},window.send=function(e,n){console.log("Edrys is not loaded ... ",e,n)},Edrys.onReady(()=>{console.log("Module arduino-view is loaded!"),window.send=function(e,n){let t=e.match("buffer")?window.binary.encode(n):JSON.stringify(n);Edrys.sendMessage(e,t)},"station"===Edrys.role?(window.station=!0,window.send("update",window.state)):(window.station=!1,window.send("init",null))}),Edrys.onMessage(({from:e,subject:n,body:t})=>{switch(n){case"init":window.station&&window.send("update",window.state);break;case"connect":window.station&&document.getElementById("connect").click();break;case"reload":window.station&&document.getElementById("reload").click();break;case"receive-buffer":!0!==window.station&&window.onReceiveCallback(window.binary.decode(t));break;case"receivedFromSandbox":window.receiveFromSandBox(JSON.parse(t),!1);break;case"update":update(JSON.parse(t));break;default:console.warn("Unknown message:",n,t)}});</script></head><body> <div id="control"> <label for="autoconnect"> Auto-Connect: </label> <input type="checkbox" id="autoconnect" name="autoconnect" onchange="update()"> <label for="baudrate"> Baud-Rate: </label> <select id="baudrate" name="baudrate" onchange="update()"> <option value="110">110</option> <option value="300">300</option> <option value="1200">1200</option> <option value="2400">2400</option> <option value="4800">4800</option> <option value="9600" selected>9600</option> <option value="19200">19200</option> <option value="38400">38400</option> <option value="57600">57600</option> <option value="115200">115200</option> </select> | <button id="connect">Connect</button> <button id="reload">Reload</button> </div> <iframe id="sandbox" src="https://edrys-labs.github.io/module-arduinoview/sandbox.html"></iframe> <script src="https://edrys-labs.github.io/module-arduinoview/index.a2301e6f.js"></script> </body></html>
0 commit comments