`
function xstepspermm() {
console.log("x")
Metro.dialog.create({
width: 600,
toTop: true,
title: "Calibrate Steps per mm for X-Axis ($100)",
content: grblcalctemplate,
actions: [{
caption: "Apply",
cls: "js-dialog-close success",
onclick: function() {
$('#val-100-input').val($('#calculatedstepspermm').val());
checkifchanged();
}
},
{
caption: "Cancel",
cls: "js-dialog-close",
onclick: function() {
// alert("You clicked Disagree action");
}
}
]
});
setTimeout(function() {
processpreset()
}, 100)
}
function ystepspermm() {
console.log("y")
Metro.dialog.create({
width: 600,
toTop: true,
title: "Calibrate Steps per mm for Y-Axis ($101)",
content: grblcalctemplate,
actions: [{
caption: "Apply",
cls: "js-dialog-close success",
onclick: function() {
$('#val-101-input').val($('#calculatedstepspermm').val());
checkifchanged();
}
},
{
caption: "Cancel",
cls: "js-dialog-close",
onclick: function() {
// alert("You clicked Disagree action");
}
}
]
});
setTimeout(function() {
processpreset()
}, 100)
}
function zstepspermm() {
console.log("z")
Metro.dialog.create({
width: 600,
toTop: true,
title: "Calibrate Steps per mm for Z-Axis ($102)",
content: grblcalctemplate,
actions: [{
caption: "Apply",
cls: "js-dialog-close success",
onclick: function() {
$('#val-102-input').val($('#calculatedstepspermm').val());
checkifchanged();
}
},
{
caption: "Cancel",
cls: "js-dialog-close",
onclick: function() {
// alert("You clicked Disagree action");
}
}
]
});
setTimeout(function() {
processpreset()
}, 100)
}
// function motorselect() {
// var select = $("#motorselect").data('select');
// console.log("Current value: " + select.val());
// }
function actuatorselect() {
var select = $("#actuatorselect").data('select');
console.log("Current value: " + select.val());
if (select.val() == "belt") {
$('#beltrow').show();
$('#pulleyrow').show();
$('#leadscrewrow').hide();
} else if (select.val() == "lead") {
$('#beltrow').hide();
$('#pulleyrow').hide();
$('#leadscrewrow').show();
}
processpreset()
}
function processpreset() {
var actuatorselect = $("#actuatorselect").data('select');
// console.log("actuatorselect value: " + actuatorselect.val());
var motorselect = $("#motorselect").data('select');
// console.log("motorselect value: " + motorselect.val());
var microstepselect = $("#microstepselect").data('select');
// console.log("microstepselect value: " + microstepselect.val());
var beltselect = $("#beltselect").data('select');
// console.log("beltselect value: " + beltselect.val());
var pulleyselect = $("#pulleyselect").data('select');
// console.log("pulleyselect value: " + pulleyselect.val());
var leadscrewselect = $("#leadscrewselect").data('select');
// console.log("leadscrewselect value: " + leadscrewselect.val());
if (actuatorselect.val() == "belt") {
//step/mm = stepsperrev / beltpitch / pulleyteeth
var stepsperrev = motorselect.val() * microstepselect.val();
var beltpitch = beltselect.val();
var pulleyteeth = pulleyselect.val();
var calculatedstepspermm = stepsperrev / beltpitch / pulleyteeth
// console.log(stepsperrev, beltpitch, pulleyteeth)
$('#calculatedstepspermm').val(calculatedstepspermm.toFixed(3))
} else if (actuatorselect.val() == "lead") {
//steps/mm = stepsperrev / screwpitch
var stepsperrev = motorselect.val() * microstepselect.val();
var screwpitch = leadscrewselect.val()
var calculatedstepspermm = stepsperrev / screwpitch
// console.log(stepsperrev, screwpitch)
$('#calculatedstepspermm').val(calculatedstepspermm.toFixed(3))
}
}