Skip to content

Commit 05cb0d7

Browse files
committed
Added ftrim() command to the client
This command sets a reference of the horizontal plane for the drone internal control system. Relates to felixge#27
1 parent 0dc7144 commit 05cb0d7

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/Client.js

+16
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,22 @@ Client.prototype.calibrate = function(device_num) {
205205
this._udpControl.calibrate(device_num);
206206
};
207207

208+
Client.prototype.ftrim = function() {
209+
// @TODO Figure out if we can get a ACK for this, so we don't need to
210+
// repeat it blindly like this
211+
212+
if(this._ref.fly) {
213+
console.log("You can’t ftrim when you fly");
214+
return false;
215+
}
216+
217+
var self = this;
218+
console.log("Stabilizing…")
219+
this._repeat(10, function() {
220+
self._udpControl.ftrim();
221+
});
222+
};
223+
208224
Client.prototype.config = function(key, value) {
209225
// @TODO Figure out if we can get a ACK for this, so we don't need to
210226
// repeat it blindly like this

lib/control/AtCommandCreator.js

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ AtCommandCreator.prototype.config = function(name, value) {
6363
return this.raw('CONFIG', '"' + name + '"', '"' + value + '"');
6464
};
6565

66+
// TMP: Used to send FTRIM
67+
AtCommandCreator.prototype.ftrim = function() {
68+
return this.raw('FTRIM');
69+
}
70+
6671
AtCommandCreator.prototype.animateLeds = function(name, hz, duration) {
6772
// Default animation
6873
name = name || 'redSnake';

test/unit/control/test-AtCommandCreator.js

+6
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,10 @@ test('AtCommandCreator', {
132132
self.creator.animate('does not exist');
133133
},/animation/);
134134
},
135+
136+
'ftrim': function() {
137+
var cmd = this.creator.ftrim();
138+
assert.equal(cmd.type, 'FTRIM');
139+
assert.equal(cmd.args.length, 0);
140+
},
135141
});

0 commit comments

Comments
 (0)