kopia lustrzana https://github.com/OpenBuilds/OpenBuilds-CONTROL
rodzic
5c3675ff84
commit
9b0a806796
|
@ -1,3 +1,4 @@
|
|||
v1.0.235: Improved Serial Buffer check
|
||||
v1.0.234: Added check for USB Selective Suspend to Troubleshooting tab, improved simulation of arcs, Fixed right-click menu in Gcode Editor
|
||||
v1.0.233: Cleanup code
|
||||
v1.0.232: Fix bug in Keyboard Jog
|
||||
|
|
|
@ -1611,10 +1611,14 @@
|
|||
<script type="text/javascript" src="js/metroactions.js"></script>
|
||||
<script type="text/javascript" src="js/jog.js"></script>
|
||||
<script type="text/javascript" src="js/servo.js"></script>
|
||||
<script type="text/javascript" src="js/keyboard.js"></script>
|
||||
<script type="text/javascript" src="js/calibrate.js"></script>
|
||||
<script type="text/javascript" src="js/widget.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/keyboard.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/gamepad.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="lib/3dview/3dview.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/grbl-defaults.js"></script>
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
var haveEvents = 'ongamepadconnected' in window;
|
||||
var controllers = {};
|
||||
|
||||
var gamepadButtons = [];
|
||||
var oldGamepadButtons = [];
|
||||
var gamepadAxes = [];
|
||||
var oldGamepadAxes = [];
|
||||
|
||||
|
||||
function connecthandler(e) {
|
||||
addgamepad(e.gamepad);
|
||||
}
|
||||
|
||||
function addgamepad(gamepad) {
|
||||
controllers[gamepad.index] = gamepad;
|
||||
requestAnimationFrame(updateStatus);
|
||||
}
|
||||
|
||||
function disconnecthandler(e) {
|
||||
removegamepad(e.gamepad);
|
||||
}
|
||||
|
||||
function removegamepad(gamepad) {
|
||||
delete controllers[gamepad.index];
|
||||
}
|
||||
|
||||
function updateStatus() {
|
||||
if (!haveEvents) {
|
||||
scangamepads();
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var j;
|
||||
|
||||
for (j in controllers) {
|
||||
var controller = controllers[j];
|
||||
|
||||
// Buttons
|
||||
for (i = 0; i < gamepadButtons.length; i++) {
|
||||
oldGamepadButtons[i] = gamepadButtons[i];
|
||||
}
|
||||
gamepadButtons.length = 0;
|
||||
for (i = 0; i < controller.buttons.length; i++) {
|
||||
var val = controller.buttons[i];
|
||||
var pressed = val == 1.0;
|
||||
if (typeof(val) == "object") {
|
||||
pressed = val.pressed;
|
||||
val = val.value;
|
||||
}
|
||||
gamepadButtons.push({
|
||||
id: i,
|
||||
pressed: pressed,
|
||||
val: val
|
||||
})
|
||||
if (oldGamepadButtons.length && oldGamepadButtons[i].pressed != gamepadButtons[i].pressed) {
|
||||
console.log("event on ", i, pressed, val)
|
||||
}
|
||||
}
|
||||
// Axes
|
||||
for (i = 0; i < gamepadAxes.length; i++) {
|
||||
oldGamepadAxes[i] = gamepadAxes[i];
|
||||
}
|
||||
gamepadAxes.length = 0;
|
||||
for (i = 0; i < controller.axes.length; i++) {
|
||||
|
||||
|
||||
var val = parseFloat(controller.axes[i]).toFixed(2)
|
||||
if (val > 0.25) {
|
||||
val = 1
|
||||
} else if (val < -0.25) {
|
||||
val = -1
|
||||
} else {
|
||||
val = 0
|
||||
}
|
||||
|
||||
gamepadAxes.push({
|
||||
id: i,
|
||||
val: val
|
||||
})
|
||||
if (oldGamepadAxes.length && oldGamepadAxes[i].val != gamepadAxes[i].val) {
|
||||
console.log("event on ", i, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requestAnimationFrame(updateStatus);
|
||||
}
|
||||
|
||||
function scangamepads() {
|
||||
var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
|
||||
for (var i = 0; i < gamepads.length; i++) {
|
||||
if (gamepads[i]) {
|
||||
if (gamepads[i].index in controllers) {
|
||||
controllers[gamepads[i].index] = gamepads[i];
|
||||
} else {
|
||||
addgamepad(gamepads[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("gamepadconnected", connecthandler);
|
||||
window.addEventListener("gamepaddisconnected", disconnecthandler);
|
||||
|
||||
if (!haveEvents) {
|
||||
setInterval(scangamepads, 500);
|
||||
}
|
22
index.js
22
index.js
|
@ -1718,7 +1718,7 @@ function parseFeedback(data) {
|
|||
// debug_log(data)
|
||||
var state = data.substring(1, data.search(/(,|\|)/));
|
||||
status.comms.runStatus = state
|
||||
if (state == "Alarm") {
|
||||
if (state == "Alarm" || state == "Hold:0") {
|
||||
// debug_log("ALARM: " + data)
|
||||
status.comms.connectionStatus = 5;
|
||||
switch (status.machine.firmware.type) {
|
||||
|
@ -1975,15 +1975,17 @@ function send1Q() {
|
|||
case 'grbl':
|
||||
if ((gcodeQueue.length - queuePointer) > 0 && !status.comms.blocked && !status.comms.paused) {
|
||||
spaceLeft = BufferSpace('grbl');
|
||||
if (gcodeQueue[queuePointer].length < spaceLeft) {
|
||||
gcode = gcodeQueue[queuePointer];
|
||||
queuePointer++;
|
||||
sentBuffer.push(gcode);
|
||||
machineSend(gcode + '\n');
|
||||
// debug_log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer) + ' Bspace: ' + (spaceLeft - gcode.length - 1));
|
||||
} else {
|
||||
status.comms.blocked = true;
|
||||
}
|
||||
// v1.0.235 removed this
|
||||
// if (gcodeQueue[queuePointer].length < spaceLeft) {
|
||||
gcode = gcodeQueue[queuePointer];
|
||||
queuePointer++;
|
||||
sentBuffer.push(gcode);
|
||||
machineSend(gcode + '\n');
|
||||
// v1.0.235 removed this
|
||||
// debug_log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer) + ' Bspace: ' + (spaceLeft - gcode.length - 1));
|
||||
// } else {
|
||||
// status.comms.blocked = true;
|
||||
// }
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "OpenBuildsCONTROL",
|
||||
"version": "1.0.234",
|
||||
"version": "1.0.235",
|
||||
"license": "AGPL-3.0",
|
||||
"description": "OpenBuildsCONTROL CNC Machine Interface Software",
|
||||
"author": "github.com/openbuilds <webmaster@openbuilds.com>",
|
||||
|
|
Ładowanie…
Reference in New Issue