From f2b28e101252bed734bc1ebc2961a2b7a40077f7 Mon Sep 17 00:00:00 2001 From: sphawes Date: Mon, 22 Jan 2024 22:13:14 +0000 Subject: [PATCH] deploy: 094ea230af60134abec128a0833f8db0a120f846 --- assets/index-8-_DZLIR.js | 21 +++++++++++++++++++++ assets/index-ohcTgOtU.js | 21 --------------------- index.html | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 assets/index-8-_DZLIR.js delete mode 100644 assets/index-ohcTgOtU.js diff --git a/assets/index-8-_DZLIR.js b/assets/index-8-_DZLIR.js new file mode 100644 index 0000000..ee04878 --- /dev/null +++ b/assets/index-8-_DZLIR.js @@ -0,0 +1,21 @@ +var S=Object.defineProperty;var x=(f,e,t)=>e in f?S(f,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[e]=t;var w=(f,e,t)=>(x(f,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))a(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function t(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(n){if(n.ep)return;n.ep=!0;const i=t(n);fetch(n.href,i)}})();class A{constructor(){w(this,"delay",e=>new Promise(t=>setTimeout(t,e)));this.encoder=new TextEncoder,this.decoder=new TextDecoder,this.consoleDiv=document.getElementById("console"),this.port,this.receiveBuffer=[],this.sentCommandBuffer=[""],this.sentCommandBufferIndex=0}appendToConsole(e,t){let a=document.createElement("p"),n=new Date().toISOString(),i="";t?i="[SEND]":i="[RECE]",a.innerHTML=i+" - "+n+" - "+e+` +`,this.consoleDiv.appendChild(a),this.consoleDiv.scrollTop=this.consoleDiv.scrollHeight}getNextBufferLine(){return this.receiveBuffer.shift()}clearBuffer(){for(;this.receiveBuffer.length>0;)this.receiveBuffer.shift()}async connect(){if(!navigator.serial)return alert("Please use a browser that supports WebSerial (Chrome)."),!1;const e=1155;return this.port=await navigator.serial.requestPort({filters:[{usbVendorId:e}]}),console.log("Port Selected."),await this.port.open({baudRate:115200,bufferSize:255,dataBits:8,flowControl:"none",parity:"none",stopBits:1}),console.log("Port Opened."),this.listen(),document.querySelector("#connect").style.background="green",document.querySelector("#connect").style.color="white",document.querySelector("#connect").innerHTML="Connected",!0}async listen(){var e;for(;(e=this.port)!=null&&e.readable;){console.log("Port is readable: Starting to listen.");let t="";document.getElementById("console");const a=this.port.readable.getReader();try{for(;;){const{value:n,done:i}=await a.read();if(i){console.log("Closing reader.");break}const l=this.decoder.decode(n);for(t=t.concat(l);t.indexOf(` +`)!=-1;){let r=t.split(` +`);this.receiveBuffer.push(r[0]),this.appendToConsole(r[0],!1),t=t.split(` +`).slice(1).join(` +`)}}}catch(n){console.error("Reading error.",n)}finally{a.releaseLock()}}}async send(e){var t;if(console.log("sending: ",e),(t=this.port)!=null&&t.writable){const a=await this.port.writable.getWriter();for(const n of e)await a.write(this.encoder.encode(n+` +`)),this.appendToConsole(n,!0);a.releaseLock()}else alert("Cannot write to port. Have you connected?")}async sendRepl(){let e=[document.querySelector("#repl-input").value];this.sentCommandBuffer.splice(1,0,e[0]),this.sentCommandBufferIndex=0,this.send(e)}async leftAirOn(){const e=["M106","M106 P1 S255"];await this.send(e)}async leftAirOff(){const e=["M107","M107 P1"];await this.send(e)}async rightAirOn(){const e=["M106 P2 S255","M106 P3 S255"];await this.send(e)}async rightAirOff(){const e=["M107 P2","M107 P3"];await this.send(e)}async ledOn(){const e=["M150 P255 R255 U255 B255"];await this.send(e)}async ledOff(){const e=["M150 P0"];await this.send(e)}async readLeftVac(){var u;if(!((u=this.port)!=null&&u.writable))return alert("Cannot write to port. Have you connected?"),!1;const e=["M260 A112 B1 S1","M260 A109","M260 B48","M260 B10","M260 S1"],t=40;this.clearBuffer();let a,n,i;const l=new RegExp("data:(..)");await this.send(e),await this.send(["M260 A109 B6 S1"]),await this.send(["M261 A109 B1 S1"]),await this.delay(t);for(var r=0,o=this.receiveBuffer.length;r>8&255}hexStringToIntArray(e){let t=[];console.log("string: ",e);for(let a=0;a1&&a===void 0)return console.log("Error: Selected command requires payload."),!1;let n;e[2]==0?(console.log("first one"),console.log(a.length),n=[t,0,this.packetID,a.length+1]):n=[t,0,this.packetID,e[2]],console.log(n," header");let i=n.concat([e[0]]);(e[2]>1||e[2]==0)&&(i=i.concat(a));let l=this.getGcodeFromPacketAndPayloadArray(i);this.serial.clearBuffer(),await this.serial.send([l]);let r=Date.now();for(;;){if(await this.serial.delay(10),Date.now()-r>400)return console.log("Timeout: didn't get serial response."),!1;let g=!1;console.log(this.serial.receiveBuffer);const c=new RegExp("ok");for(let p=0,E=this.serial.receiveBuffer.length;p{let f=document.getElementById("uni-command").value;["0x01","0x03","0x06"].includes(f)?(document.getElementById("uni-payload").style.display="none",document.getElementById("uni-payload-label").style.display="none"):(document.getElementById("uni-payload").style.display="inline",document.getElementById("uni-payload-label").style.display="inline")});document.getElementById("connect").addEventListener("click",()=>{d.connect()});document.getElementById("send").addEventListener("click",()=>{d.sendRepl(),R()});document.getElementById("tmc").addEventListener("click",()=>{d.testTMC()});document.getElementById("vac").addEventListener("click",()=>{d.testVac()});document.getElementById("left-air-on").addEventListener("click",()=>{d.leftAirOn()});document.getElementById("left-air-off").addEventListener("click",()=>{d.leftAirOff()});document.getElementById("right-air-on").addEventListener("click",()=>{d.rightAirOn()});document.getElementById("right-air-off").addEventListener("click",()=>{d.rightAirOff()});document.getElementById("ring-lights-on").addEventListener("click",()=>{d.ledOn()});document.getElementById("ring-lights-off").addEventListener("click",()=>{d.ledOff()});document.getElementById("left-vac").addEventListener("click",()=>{d.readLeftVac()});document.getElementById("right-vac").addEventListener("click",()=>{d.readRightVac()});document.getElementById("feeder-scan").addEventListener("click",()=>{var f;if(!((f=d.port)!=null&&f.writable))return alert("Cannot write to port. Have you connected?"),!1;document.getElementById("found-feeders").style.display="flex",document.getElementById("found-feeders").innerHTML="",document.getElementById("feeder-scan").innerHTML="Scanning...",B.scan()});document.getElementById("uni-send").addEventListener("click",()=>{B.sendUnicast()});document.getElementById("broad-send").addEventListener("click",()=>{B.sendBroadcast()});document.getElementById("calc-calculate").addEventListener("click",()=>{B.calculateUserCRC()});document.getElementById("program-slots").addEventListener("click",()=>{B.programSlotsUtility()});document.getElementById("more-controls").addEventListener("click",()=>{document.getElementById("unicast").style.display="block",document.getElementById("broadcast").style.display="block",document.getElementById("custom-packet").style.display="block",document.getElementById("crc-tool").style.display="block"});document.getElementById("found-feeders").addEventListener("click",function(f){let e=f.target;if(e.className.split(" ").includes("identify")&&e.nodeName=="BUTTON"){let a=e.parentElement.getElementsByTagName("H4")[0].innerHTML;a=B.hexStringToIntArray(a),B.sendPacket(h.IDENTIFY_FEEDER,255,a)}else if(e.className.split(" ").includes("feed")&&e.nodeName=="BUTTON"){let a=e.parentElement.getElementsByTagName("H3")[0].innerHTML;a=parseInt(a),B.sendPacket(h.MOVE_FEED_FORWARD,a,40)}}); diff --git a/assets/index-ohcTgOtU.js b/assets/index-ohcTgOtU.js deleted file mode 100644 index 108d23c..0000000 --- a/assets/index-ohcTgOtU.js +++ /dev/null @@ -1,21 +0,0 @@ -var S=Object.defineProperty;var A=(f,e,t)=>e in f?S(f,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[e]=t;var w=(f,e,t)=>(A(f,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))a(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function t(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(n){if(n.ep)return;n.ep=!0;const i=t(n);fetch(n.href,i)}})();class k{constructor(){w(this,"delay",e=>new Promise(t=>setTimeout(t,e)));this.encoder=new TextEncoder,this.decoder=new TextDecoder,this.consoleDiv=document.getElementById("console"),this.port,this.receiveBuffer=[]}appendToConsole(e,t){let a=document.createElement("p"),n=new Date().toISOString(),i="";t?i="[SEND]":i="[RECE]",a.innerHTML=i+" - "+n+" - "+e+` -`,this.consoleDiv.appendChild(a),this.consoleDiv.scrollTop=this.consoleDiv.scrollHeight}getNextBufferLine(){return this.receiveBuffer.shift()}clearBuffer(){for(;this.receiveBuffer.length>0;)this.receiveBuffer.shift()}async connect(){if(!navigator.serial)return alert("Please use a browser that supports WebSerial (Chrome)."),!1;const e=1155;return this.port=await navigator.serial.requestPort({filters:[{usbVendorId:e}]}),console.log("Port Selected."),await this.port.open({baudRate:115200,bufferSize:255,dataBits:8,flowControl:"none",parity:"none",stopBits:1}),console.log("Port Opened."),this.listen(),document.querySelector("#connect").style.background="green",document.querySelector("#connect").style.color="white",document.querySelector("#connect").innerHTML="Connected",!0}async listen(){var e;for(;(e=this.port)!=null&&e.readable;){console.log("Port is readable: Starting to listen.");let t="";document.getElementById("console");const a=this.port.readable.getReader();try{for(;;){const{value:n,done:i}=await a.read();if(i){console.log("Closing reader.");break}const l=this.decoder.decode(n);for(t=t.concat(l);t.indexOf(` -`)!=-1;){let r=t.split(` -`);this.receiveBuffer.push(r[0]),this.appendToConsole(r[0],!1),t=t.split(` -`).slice(1).join(` -`)}}}catch(n){console.error("Reading error.",n)}finally{a.releaseLock()}}}async send(e){var t;if(console.log("sending: ",e),(t=this.port)!=null&&t.writable){const a=await this.port.writable.getWriter();for(const n of e)await a.write(this.encoder.encode(n+` -`)),this.appendToConsole(n,!0);a.releaseLock()}else alert("Cannot write to port. Have you connected?")}async sendRepl(){let e=[document.querySelector("#repl-input").value];this.send(e)}async leftAirOn(){const e=["M106","M106 P1 S255"];await this.send(e)}async leftAirOff(){const e=["M107","M107 P1"];await this.send(e)}async rightAirOn(){const e=["M106 P2 S255","M106 P3 S255"];await this.send(e)}async rightAirOff(){const e=["M107 P2","M107 P3"];await this.send(e)}async ledOn(){const e=["M150 P255 R255 U255 B255"];await this.send(e)}async ledOff(){const e=["M150 P0"];await this.send(e)}async readLeftVac(){var d;if(!((d=this.port)!=null&&d.writable))return alert("Cannot write to port. Have you connected?"),!1;const e=["M260 A112 B1 S1","M260 A109","M260 B48","M260 B10","M260 S1"],t=40;this.clearBuffer();let a,n,i;const l=new RegExp("data:(..)");await this.send(e),await this.send(["M260 A109 B6 S1"]),await this.send(["M261 A109 B1 S1"]),await this.delay(t);for(var r=0,c=this.receiveBuffer.length;r>8&255}hexStringToIntArray(e){let t=[];console.log("string: ",e);for(let a=0;a1&&a===void 0)return console.log("Error: Selected command requires payload."),!1;let n;e[2]==0?(console.log("first one"),console.log(a.length),n=[t,0,this.packetID,a.length+1]):n=[t,0,this.packetID,e[2]],console.log(n," header");let i=n.concat([e[0]]);(e[2]>1||e[2]==0)&&(i=i.concat(a));let l=this.getGcodeFromPacketAndPayloadArray(i);this.serial.clearBuffer(),await this.serial.send([l]);let r=Date.now();for(;;){if(await this.serial.delay(10),Date.now()-r>400)return console.log("Timeout: didn't get serial response."),!1;let m=!1;console.log(this.serial.receiveBuffer);const o=new RegExp("ok");for(let g=0,p=this.serial.receiveBuffer.length;g{let f=document.getElementById("uni-command").value;["0x01","0x03","0x06"].includes(f)?(document.getElementById("uni-payload").style.display="none",document.getElementById("uni-payload-label").style.display="none"):(document.getElementById("uni-payload").style.display="inline",document.getElementById("uni-payload-label").style.display="inline")});document.getElementById("connect").addEventListener("click",()=>{E.connect()});document.getElementById("send").addEventListener("click",()=>{E.sendRepl(),R()});document.getElementById("tmc").addEventListener("click",()=>{E.testTMC()});document.getElementById("vac").addEventListener("click",()=>{E.testVac()});document.getElementById("left-air-on").addEventListener("click",()=>{E.leftAirOn()});document.getElementById("left-air-off").addEventListener("click",()=>{E.leftAirOff()});document.getElementById("right-air-on").addEventListener("click",()=>{E.rightAirOn()});document.getElementById("right-air-off").addEventListener("click",()=>{E.rightAirOff()});document.getElementById("ring-lights-on").addEventListener("click",()=>{E.ledOn()});document.getElementById("ring-lights-off").addEventListener("click",()=>{E.ledOff()});document.getElementById("left-vac").addEventListener("click",()=>{E.readLeftVac()});document.getElementById("right-vac").addEventListener("click",()=>{E.readRightVac()});document.getElementById("feeder-scan").addEventListener("click",()=>{var f;if(!((f=E.port)!=null&&f.writable))return alert("Cannot write to port. Have you connected?"),!1;document.getElementById("found-feeders").style.display="flex",document.getElementById("found-feeders").innerHTML="",document.getElementById("feeder-scan").innerHTML="Scanning...",B.scan()});document.getElementById("uni-send").addEventListener("click",()=>{B.sendUnicast()});document.getElementById("broad-send").addEventListener("click",()=>{B.sendBroadcast()});document.getElementById("calc-calculate").addEventListener("click",()=>{B.calculateUserCRC()});document.getElementById("program-slots").addEventListener("click",()=>{B.programSlotsUtility()});document.getElementById("more-controls").addEventListener("click",()=>{document.getElementById("unicast").style.display="block",document.getElementById("broadcast").style.display="block",document.getElementById("custom-packet").style.display="block",document.getElementById("crc-tool").style.display="block"});document.getElementById("found-feeders").addEventListener("click",function(f){let e=f.target;if(e.className.split(" ").includes("identify")&&e.nodeName=="BUTTON"){let a=e.parentElement.getElementsByTagName("H4")[0].innerHTML;a=B.hexStringToIntArray(a),B.sendPacket(u.IDENTIFY_FEEDER,255,a)}else if(e.className.split(" ").includes("feed")&&e.nodeName=="BUTTON"){let a=e.parentElement.getElementsByTagName("H3")[0].innerHTML;a=parseInt(a),B.sendPacket(u.MOVE_FEED_FORWARD,a,40)}}); diff --git a/index.html b/index.html index af936b4..a705bb5 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ LumenPnP Debug - +