kopia lustrzana https://github.com/OpenBuilds/OpenBuilds-CONTROL
v1.0.223
rodzic
631ac67c38
commit
2b2a63af63
|
@ -1,6 +1,7 @@
|
|||
v1.0.223: Added keyboard shortcuts to Macros, updated look of buttons to include showing keyboard assignment
|
||||
v1.0.222: Added Keyboard shortcuts for GotoZero, and switching between Incremental/Continuous jogging
|
||||
v1.0.221: Corrected product names for XYZ Probe Plus
|
||||
v1.0.220: New XYZ and Custom Probe wizards, new Probe Button on Main toolbar, fixed File Assocation Opening (Bug #119 ), added loaded Filename to titlebar (Issue #116), changed Keybinding for Devtools to ctrl+shift+i, added shortcut key F6 to jump to console (Issue #112)
|
||||
v1.0.220: New XYZ and Custom Probe wizards, new Probe Button on Main toolbar, fixed File association Opening (Bug #119 ), added loaded Filename to titlebar (Issue #116), changed Keybinding for Devtools to ctrl+shift+i, added shortcut key F6 to jump to console (Issue #112)
|
||||
v1.0.216-219: Internal Testing versions only
|
||||
v1.0.215: Fixed bug with Z Plate retract where plate is thicker than 10mm
|
||||
v1.0.214: Fixed bug with Z-Zero plate probing routine, added Z Plate thickness setting back
|
||||
|
|
|
@ -208,8 +208,15 @@ select {
|
|||
background-color: #fff
|
||||
}
|
||||
|
||||
.macroedit {
|
||||
position: absolute !important;
|
||||
top: 5px !important;
|
||||
right: 5px !important;
|
||||
font-size: 11px !important;
|
||||
}
|
||||
|
||||
.macroedit:hover {
|
||||
color: #CE352C !important;
|
||||
color: #ff1e11 !important;
|
||||
}
|
||||
|
||||
.machineicon:hover {
|
||||
|
|
|
@ -95,6 +95,31 @@ function bindKeys() {
|
|||
}
|
||||
});
|
||||
|
||||
// Bind for Macro keys
|
||||
if (buttonsarray.length > 0) {
|
||||
for (i = 0; i < buttonsarray.length; i++) {
|
||||
if (buttonsarray[i].macrokeyboardshortcut.length) {
|
||||
$(document).bind('keydown', buttonsarray[i].macrokeyboardshortcut, function(e) {
|
||||
console.log(e)
|
||||
var newVal = "";
|
||||
if (e.altKey) {
|
||||
newVal += 'alt+'
|
||||
}
|
||||
if (e.ctrlKey) {
|
||||
newVal += 'ctrl+'
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
newVal += 'shift+'
|
||||
}
|
||||
newVal += e.key
|
||||
var macro = searchMacro("macrokeyboardshortcut", newVal, buttonsarray)
|
||||
console.log(macro)
|
||||
sendGcode(macro.gcode);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bind for Jog and Control Buttons
|
||||
if (keyboardShortcuts.xM.length) {
|
||||
$(document).bind('keydown', keyboardShortcuts.xM, function(event) {
|
||||
|
|
100
app/js/macros.js
100
app/js/macros.js
|
@ -8,20 +8,35 @@ function populateMacroButtons() {
|
|||
if (!buttonsarray[i].tooltip) {
|
||||
buttonsarray[i].tooltip = ""
|
||||
};
|
||||
if (buttonsarray[i].macrokeyboardshortcut.length) {
|
||||
var keyboardAssignment = buttonsarray[i].macrokeyboardshortcut
|
||||
} else {
|
||||
var keyboardAssignment = "none"
|
||||
}
|
||||
var button = `
|
||||
<button title="` + buttonsarray[i].tooltip + `" id="macro` + i + `" onclick="sendGcode('` + buttonsarray[i].gcode.replace(/(\r\n|\n|\r)/gm, "\\n") + `');" class="shortcut outline rounded no-caption m-1 ` + buttonsarray[i].class + `">
|
||||
<span class="tag"><span onclick="edit(` + i + `, event);" id="edit` + i + `" class="fas fa-cogs macroedit"></span></span>
|
||||
<span class="caption">` + buttonsarray[i].title + `</span>
|
||||
<span class="` + buttonsarray[i].icon + ` icon"></span>
|
||||
</button>`
|
||||
<button class="macrobtn m-1 command-button outline ` + buttonsarray[i].class + `" title="` + buttonsarray[i].tooltip + `" onclick="sendGcode('` + buttonsarray[i].gcode.replace(/(\r\n|\n|\r)/gm, "\\n") + `');">
|
||||
<span class="` + buttonsarray[i].icon + ` icon"></span>
|
||||
<span class="caption mt-2">
|
||||
` + buttonsarray[i].title + `
|
||||
<small><i class="far fa-fw fa-keyboard"></i>: [` + keyboardAssignment + `]</small>
|
||||
</span>
|
||||
<span title="Edit Macro" onclick="edit(` + i + `, event);" id="edit` + i + `" class="fas fa-cogs macroedit"></span>
|
||||
</button>
|
||||
|
||||
`
|
||||
$("#macros").append(button);
|
||||
}
|
||||
// append add button
|
||||
var button = `
|
||||
<button class="shortcut outline rounded no-caption m-1" onclick="edit(` + (buttonsarray.length + 1) + `, event)">
|
||||
<span class="caption">Add Macro</span>
|
||||
<span class="fas fa-plus icon"></span>
|
||||
</button>`
|
||||
<button class="m-1 command-button outline rounded" onclick="edit(` + (buttonsarray.length + 1) + `, event)">
|
||||
<span class="fas fa-plus icon"></span>
|
||||
<span class="caption mt-2">
|
||||
Add
|
||||
<small>Macro</small>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
`
|
||||
$("#macros").append(button);
|
||||
localStorage.setItem('macroButtons', JSON.stringify(buttonsarray));
|
||||
}
|
||||
|
@ -37,15 +52,22 @@ function edit(i, evt) {
|
|||
var gcode = buttonsarray[i].gcode;
|
||||
var cls = buttonsarray[i].class;
|
||||
var tooltip = buttonsarray[i].tooltip;
|
||||
if (buttonsarray[i].macrokeyboardshortcut.length > 0) {
|
||||
var macrokeyboardshortcut = buttonsarray[i].macrokeyboardshortcut;
|
||||
} else {
|
||||
var macrokeyboardshortcut = "";
|
||||
}
|
||||
|
||||
} else {
|
||||
var icon = "far fa-question-circle";
|
||||
var title = "";
|
||||
var gcode = "";
|
||||
var cls = "";
|
||||
var tooltip = "";
|
||||
var macrokeyboardshortcut = "";
|
||||
}
|
||||
|
||||
var macroTemplate = `<form>
|
||||
var macroTemplate = `<form id="macroEditForm">
|
||||
<div class="row mb-2">
|
||||
<label class="cell-sm-2">Icon</label>
|
||||
<div class="cell-sm-10">
|
||||
|
@ -87,6 +109,13 @@ function edit(i, evt) {
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<span class="text-small">Click below to assign a new Keyboard Shortcut / combination to a function. Ctrl, Alt and Shift can be added to create combinations.</span>
|
||||
<label class="cell-sm-2">Keyboard Shortcut</label>
|
||||
<div class="cell-sm-10" >
|
||||
<input id="macrokeyboardshortcut" class="macrokeyboardshortcutinput" type="text" value="` + macrokeyboardshortcut + `" data-editable="true" onclick="$('.macrokeyboardshortcutinput').removeClass('newMacroKeyAssignment'); $('#macrokeyboardshortcut').addClass('newMacroKeyAssignment')">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="macroseq" value="` + i + `" />
|
||||
</form>`
|
||||
|
||||
|
@ -119,6 +148,7 @@ function edit(i, evt) {
|
|||
buttonsarray[seq].gcode = $('#macrogcode').val();
|
||||
buttonsarray[seq].class = $('#macrocls').val();
|
||||
buttonsarray[seq].tooltip = $('#macrotooltip').val();
|
||||
buttonsarray[seq].macrokeyboardshortcut = $('#macrokeyboardshortcut').val();
|
||||
populateMacroButtons();
|
||||
} else {
|
||||
buttonsarray.push({
|
||||
|
@ -126,7 +156,8 @@ function edit(i, evt) {
|
|||
icon: $('#macroicon').val(),
|
||||
gcode: $('#macrogcode').val(),
|
||||
class: $('#macrocls').val(),
|
||||
tooltip: $('#macrotooltip').val()
|
||||
tooltip: $('#macrotooltip').val(),
|
||||
macrokeyboardshortcut: $('#macrokeyboardshortcut').val(),
|
||||
})
|
||||
populateMacroButtons();
|
||||
}
|
||||
|
@ -135,6 +166,42 @@ function edit(i, evt) {
|
|||
]
|
||||
});
|
||||
|
||||
$('#macrokeyboardshortcut').bind('keydown', null, function(e) {
|
||||
e.preventDefault();
|
||||
console.log(e)
|
||||
var newVal = "";
|
||||
if (e.altKey) {
|
||||
newVal += 'alt+'
|
||||
}
|
||||
if (e.ctrlKey) {
|
||||
newVal += 'ctrl+'
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
newVal += 'shift+'
|
||||
}
|
||||
|
||||
if (e.key.toLowerCase() != 'alt' && e.key.toLowerCase() != 'control' && e.key.toLowerCase() != 'shift') {
|
||||
// Handle MetroUI naming non-standards of some keys
|
||||
if (e.keyCode == 32) {
|
||||
newVal += 'space';
|
||||
} else if (e.key.toLowerCase() == 'escape') {
|
||||
newVal += 'esc';
|
||||
} else if (e.key.toLowerCase() == 'arrowleft') {
|
||||
newVal += 'left';
|
||||
} else if (e.key.toLowerCase() == 'arrowright') {
|
||||
newVal += 'right';
|
||||
} else if (e.key.toLowerCase() == 'arrowup') {
|
||||
newVal += 'up';
|
||||
} else if (e.key.toLowerCase() == 'arrowdown') {
|
||||
newVal += 'down';
|
||||
} else {
|
||||
newVal += e.key.toLowerCase();
|
||||
}
|
||||
$('.newMacroKeyAssignment').val(newVal)
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var options = {
|
||||
placement: 'bottom',
|
||||
collision: 'none',
|
||||
|
@ -162,4 +229,13 @@ if (localStorage.getItem('macroButtons')) {
|
|||
buttonsarray = JSON.parse(localStorage.getItem('macroButtons'));
|
||||
}
|
||||
|
||||
populateMacroButtons()
|
||||
populateMacroButtons()
|
||||
|
||||
function searchMacro(prop, nameKey, myArray) {
|
||||
console.log(nameKey, prop, myArray)
|
||||
for (var i = 0; i < myArray.length; i++) {
|
||||
if (myArray[i][prop] === nameKey) {
|
||||
return myArray[i];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ function setConnectBar(val, status) {
|
|||
}
|
||||
$('#portUSB').parent(".select").addClass('success')
|
||||
$('#portUSB').parent(".select").removeClass('alert')
|
||||
$('.macrobtn').addClass('disabled')
|
||||
// Set Port Dropdown to Current Value
|
||||
// Not applicable to Status 0 as its set by populatePortsMenu();
|
||||
|
||||
|
@ -42,6 +43,8 @@ function setConnectBar(val, status) {
|
|||
$('#portUSB').parent(".select").addClass('alert')
|
||||
// Set Port Dropdown to Current Value
|
||||
$("#portUSB").val(status.comms.interfaces.activePort);
|
||||
$('.macrobtn').removeClass('disabled')
|
||||
|
||||
} else if (val == 3) { // Busy Streaming GCODE
|
||||
// Status Badge
|
||||
$('#connectStatus').html("Port: Connected");
|
||||
|
@ -58,6 +61,7 @@ function setConnectBar(val, status) {
|
|||
$('#portUSB').parent(".select").addClass('alert')
|
||||
// Set Port Dropdown to Current Value
|
||||
$("#portUSB").val(status.comms.interfaces.activePort);
|
||||
$('.macrobtn').addClass('disabled')
|
||||
|
||||
} else if (val == 4) { // Paused
|
||||
// Status Badge
|
||||
|
@ -75,6 +79,7 @@ function setConnectBar(val, status) {
|
|||
$('#portUSB').parent(".select").addClass('alert')
|
||||
// Set Port Dropdown to Current Value
|
||||
$("#portUSB").val(status.comms.interfaces.activePort);
|
||||
$('.macrobtn').addClass('disabled')
|
||||
|
||||
} else if (val == 5) { // Alarm State
|
||||
// Status Badge
|
||||
|
@ -92,6 +97,8 @@ function setConnectBar(val, status) {
|
|||
$('#portUSB').parent(".select").addClass('alert')
|
||||
// Set Port Dropdown to Current Value
|
||||
$("#portUSB").val(status.comms.interfaces.activePort);
|
||||
$('.macrobtn').addClass('disabled')
|
||||
|
||||
} else if (val == 6) { // Firmware Upgrade State
|
||||
// Status Badge
|
||||
$('#connectStatus').html("Port: Flashing");
|
||||
|
@ -108,6 +115,8 @@ function setConnectBar(val, status) {
|
|||
$('#portUSB').parent(".select").addClass('alert')
|
||||
// Set Port Dropdown to Current Value
|
||||
$("#portUSB").val(status.comms.interfaces.activePort);
|
||||
$('.macrobtn').addClass('disabled')
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue