$("#gpio-go").click(function () {
if ($("#gpio-menu").val()) {
- $("#gpio-container").exportGPIO($("#gpio-menu"));
+ $(this).attr("disabled", true);
+ $("#gpio-container").exportGPIO($("#gpio-menu")).always(function () {
+ $("#gpio-go").attr("disabled", false);
+ });
}
});
$("#pwm-go").click(function () {
if ($("#pwm-menu").val()) {
- $("#pwm-container").exportPWM($("#pwm-menu"));
+ $(this).attr("disabled", true);
+ $("#pwm-container").exportPWM($("#pwm-menu")).always(function () {
+ $("#pwm-go").attr("disabled", false);
+ });
}
});
$("#adc-controls").trigger("reset").setADCControl();
var number = menu.val();
var container = this;
- $.ajax({url : mctx.pintest.api, data : {type : "gpi", num : number, export : 1}})
+ return $.ajax({url : mctx.pintest.api, data : {type : "gpi", num : number, export : 1}})
.done(function () {
var form = $("<form/>", {"class" : "controls", action : "#", id : "gpio-" + number});
var title = $("<div/>", {"class" : "centre bold", text : "GPIO " + number});
alert("Failed to export GPIO " + number + ". Is the server running?\n" +
"Error code: " + jqXHR.status);
});
- return this;
};
$.fn.exportPWM = function(menu) {
var number = menu.val();
var container = this;
- $.ajax({url : mctx.pintest.api, data : {type : "pwm", num : number, export : "1"}})
+ return $.ajax({url : mctx.pintest.api, data : {type : "pwm", num : number, export : "1"}})
.done(function () {
var form = $("<form/>", {"class" : "controls", action : "#", id : "pwm-" + number});
var title = $("<div/>", {"class" : "centre bold", text : "PWM " + number});
alert("Failed to export PWM " + number + ". Is the server running?\n" +
"Error code: " + jqXHR.status);
});
- return this;
};
$.fn.setGPIOControl = function (number, menu) {