Skip to content

Commit

Permalink
Front Flip feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
weilonge committed Jun 24, 2015
1 parent 4eae95d commit 923a4be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<button id="takeoff">Take-Off</button>
<button id="landing">Landing</button>
<!--<button id="readyToGo">ReadyToGo</button>-->
<button id="frontFlip">Front Flip</button>
<span id="status">
<span id="flyingStatus"></span>
<span id="battery"></span>
Expand Down
4 changes: 4 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var App = {
buttonIds: [
'takeoff',
'landing',
'frontFlip',
'to-scripting-view',
'to-joystick-view',
'run-script',
Expand Down Expand Up @@ -191,6 +192,9 @@ var App = {
case 'landing':
this.rsHelper.landing();
break;
case 'frontFlip':
this.rsHelper.frontFlip();
break;
case 'import-script':
this.importScript();
break;
Expand Down
16 changes: 16 additions & 0 deletions js/rolling_spider_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ RollingSpiderHelper.prototype = evt({
}
},

frontFlip: function FrontFlip() {
if (this._stateManager.isConnected()) {
var characteristic = this._characteristics[Constants.CHARACTERISTICS.FA0B];

// 4, (byte)mSettingsCounter, 2, 4, 0, 0, 0, 0, 0, 0
var buffer = new ArrayBuffer(10);
var array = new Uint8Array(buffer);
array.set([4, this._settingsCounter++, 2, 4, 0, 0, 0, 0, 0, 0]);
characteristic.writeValue(buffer).then(function onResolve(){
console.log('frontFlip success');
}, function onReject(){
console.log('frontFlip failed');
});
}
},

emergencyStop: function EmergencyStop(){
var characteristic = this._characteristics[Constants.CHARACTERISTICS.FA0C];

Expand Down

0 comments on commit 923a4be

Please sign in to comment.