diff --git a/plugins/pilot/index.js b/plugins/pilot/index.js index deb93fe..b5c223f 100644 --- a/plugins/pilot/index.js +++ b/plugins/pilot/index.js @@ -14,6 +14,10 @@ function pilot(name, deps) { console.log("calibrate", cmd); return deps.client.calibrate(cmd.device_num); }); + socket.on('/pilot/ftrim', function () { + console.log("flat trim"); + return deps.client.ftrim(); + }); socket.on('/pilot/animate', function (cmd) { console.log("animate", cmd); return deps.client.animate(cmd.action, 500); diff --git a/plugins/pilot/public/js/pilot.js b/plugins/pilot/public/js/pilot.js index f8f7fff..8ebb861 100644 --- a/plugins/pilot/public/js/pilot.js +++ b/plugins/pilot/public/js/pilot.js @@ -115,11 +115,17 @@ PILOT_ACCELERATION = 0.04; ev.preventDefault(); pilot.calibrate(0); }); + $('#ftrim').click(function(ev) { + ev.preventDefault(); + pilot.ftrim(); + }); this.cockpit.socket.on('hovering', function() { $('#calibratemagneto').prop('disabled', false); + $('#ftrim').prop('disabled', true); }); this.cockpit.socket.on('landed', function() { $('#calibratemagneto').prop('disabled', true); + $('#ftrim').prop('disabled', false); }); @@ -240,6 +246,14 @@ PILOT_ACCELERATION = 0.04; }); }; + /* + * Requests a flat trim. Disabled when flying. + */ + Pilot.prototype.ftrim = function ftrim() { + this.cockpit.socket.emit("/pilot/ftrim"); + }; + + window.Cockpit.plugins.push(Pilot); }(window, document)); diff --git a/views/index.ejs b/views/index.ejs index 26174e0..59b7cdf 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -25,6 +25,7 @@
+