Skip to content

Instantly share code, notes, and snippets.

@klabarge
Created April 17, 2018 01:29
Show Gist options
  • Save klabarge/02f33c98a1e420687e0415cffc3d1454 to your computer and use it in GitHub Desktop.
Save klabarge/02f33c98a1e420687e0415cffc3d1454 to your computer and use it in GitHub Desktop.
eris.html
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>QZ Tray Sample Page</title>
</head>
<body onload="calibrate()">
Check the console.
</body>
<!-- Required scripts -->
<script type="text/javascript" src="js/dependencies/rsvp-3.1.0.min.js"></script>
<script type="text/javascript" src="js/dependencies/sha-256.min.js"></script>
<script type="text/javascript" src="js/qz-tray.js"></script>
<script>
// SeeMeCNC Eris
var port = 'COM4';
var serialBuffer = '';
var command = '\r\n\r\n\r\n\r\n\r\n';
var bounds = { start: null, end: null, width: 1 };
// FIXE: These properties cause problems. Must comment out L148-L149 SerialIO.java
var properties = { baudRate: 250000, dataBits: 8, stopBits: 1, parity: 'NONE', flowControl: 'XONXOFF_IN' };
properties = null;
// echo the serial data
var outputData = function(event) {
if (event.type == 'ERROR') {
console.error(event.exception);
return;
}
serialBuffer += event.output;
var hexVal = event.output.charCodeAt(0).toString(16).toUpperCase();
hexVal = hexVal.length == 1 ? '0' + hexVal : hexVal;
if (event.output =='\n') {
console.log(serialBuffer);
serialBuffer = "";
}
};
function calibrate() {
qz.serial.setSerialCallbacks(outputData);
qz.websocket.connect().then(function() {
return qz.serial.openPort(port, bounds);
}).then(function() {
return qz.serial.sendData(port, command, properties);
}).then(function() {
//return qz.serial.closePort(port);
}).catch(function(err) { console.error(err); });
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment