Skip to content

Commit

Permalink
crude port
Browse files Browse the repository at this point in the history
  • Loading branch information
DzikuVx committed Nov 29, 2016
1 parent 706cb4c commit 25c8a6f
Show file tree
Hide file tree
Showing 15 changed files with 50,864 additions and 4 deletions.
Binary file added images/osd-bg-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 42 additions & 2 deletions js/gui.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*global $*/
'use strict';

var TABS = {}; // filled by individual tab js file
Expand Down Expand Up @@ -35,7 +36,8 @@ var GUI_control = function () {
'receiver',
'sensors',
'servos',
'setup'
'setup',
'osd'
];
this.allowedTabs = this.defaultAllowedTabsWhenDisconnected;

Expand Down Expand Up @@ -239,6 +241,44 @@ GUI_control.prototype.tab_switch_cleanup = function (callback) {
}
};

GUI_control.prototype.switchery = function() {
$('.togglesmall').each(function(index, elem) {
var switchery = new Switchery(elem, {
size: 'small',
color: '#ffbb00',
secondaryColor: '#c4c4c4'
});
$(elem).on("change", function (evt) {
switchery.setPosition();
});
$(elem).removeClass('togglesmall');
});

$('.toggle').each(function(index, elem) {
var switchery = new Switchery(elem, {
color: '#ffbb00',
secondaryColor: '#c4c4c4'
});
$(elem).on("change", function (evt) {
switchery.setPosition();
});
$(elem).removeClass('toggle');
});

$('.togglemedium').each(function(index, elem) {
var switchery = new Switchery(elem, {
className: 'switcherymid',
color: '#ffbb00',
secondaryColor: '#c4c4c4'
});
$(elem).on("change", function (evt) {
switchery.setPosition();
});
$(elem).removeClass('togglemedium');
});
};


GUI_control.prototype.content_ready = function (callback) {

$('.togglesmall').each(function(index, elem) {
Expand Down Expand Up @@ -303,7 +343,7 @@ GUI_control.prototype.content_ready = function (callback) {
});

if (callback) callback();
}
};

// initialize object into GUI variable
var GUI = new GUI_control();
92 changes: 92 additions & 0 deletions js/injected_methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Number.prototype.clamp = function(min, max) {
return Math.min(Math.max(this, min), max);
};

/**
* String formatting now supports currying (partial application).
* For a format string with N replacement indices, you can call .format
* with M <= N arguments. The result is going to be a format string
* with N-M replacement indices, properly counting from 0 .. N-M.
* The following Example should explain the usage of partial applied format:
* "{0}:{1}:{2}".format("a","b","c") === "{0}:{1}:{2}".format("a","b").format("c")
* "{0}:{1}:{2}".format("a").format("b").format("c") === "{0}:{1}:{2}".format("a").format("b", "c")
**/
String.prototype.format = function () {
var args = arguments;
return this.replace(/\{(\d+)\}/g, function (t, i) {
return args[i] !== void 0 ? args[i] : "{"+(i-args.length)+"}";
});
};

Array.prototype.push8 = function(val) {
this.push(0xFF & val);
return this;
};

Array.prototype.push16 = function(val) {
// low byte
this.push(0x00FF & val);
// high byte
this.push(val >> 8);
// chainable
return this;
};

Array.prototype.push32 = function(val) {
this.push8(val)
.push8(val >> 8)
.push8(val >> 16)
.push8(val >> 24);
return this;
};

DataView.prototype.offset = 0;
DataView.prototype.readU8 = function() {
if (this.byteLength >= this.offset+1) {
return this.getUint8(this.offset++);
} else {
return null;
}
};

DataView.prototype.readU16 = function() {
if (this.byteLength >= this.offset+2) {
return this.readU8() + this.readU8()*256;
} else {
return null;
}
};

DataView.prototype.readU32 = function() {
if (this.byteLength >= this.offset+4) {
return this.readU16() + this.readU16()*65536;
} else {
return null;
}
};

DataView.prototype.read8 = function() {
if (this.byteLength >= this.offset+1) {
return this.getInt8(this.offset++, 1);
} else {
return null;
}
};

DataView.prototype.read16 = function() {
this.offset += 2;
if (this.byteLength >= this.offset) {
return this.getInt16(this.offset-2, 1);
} else {
return null;
}
};

DataView.prototype.read32 = function() {
this.offset += 4;
if (this.byteLength >= this.offset) {
return this.getInt32(this.offset-4, 1);
} else {
return null;
}
};
31 changes: 31 additions & 0 deletions js/libraries/inflection.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions js/libraries/jquery.ba-throttle-debounce.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
11 changes: 11 additions & 0 deletions js/msp.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var MSP_codes = {
MSP_SET_BLACKBOX_CONFIG: 81,
MSP_TRANSPONDER_CONFIG: 82,
MSP_SET_TRANSPONDER_CONFIG: 83,
MSP_OSD_CONFIG: 84,

MSP_ADVANCED_CONFIG: 90,
MSP_SET_ADVANCED_CONFIG: 91,
Expand Down Expand Up @@ -1180,6 +1181,8 @@ var MSP = {
case MSP_codes.MSP_SET_FAILSAFE_CONFIG:
console.log('Failsafe config saved');
break;
case MSP_codes.MSP_OSD_CONFIG:
break;
default:
console.log('Unknown code detected: ' + code);
} else {
Expand Down Expand Up @@ -1282,6 +1285,14 @@ var MSP = {
}
return true;
},
promise: function(code, data) {
var self = this;
return new Promise(function(resolve) {
self.send_message(code, data, false, function(data) {
resolve(data);
});
});
},
callbacks_cleanup: function () {
for (var i = 0; i < this.callbacks.length; i++) {
clearInterval(this.callbacks[i].timer);
Expand Down
6 changes: 4 additions & 2 deletions js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ function onOpen(openInfo) {
// continue as usually
CONFIGURATOR.connectionValid = true;
GUI.allowedTabs = GUI.defaultAllowedTabsWhenConnected.slice();
if (semver.lt(CONFIG.apiVersion, "1.4.0")) {
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('led_strip'), 1);
//TODO here we can remove led_strip tab from NAZE and CC3D at least!
//FIXME add real version here
if (false && semver.lt(CONFIG.flightControllerVersion, "1.4.0")) {
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('osd'), 1);
}

onConnect();
Expand Down
6 changes: 6 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<link type="text/css" rel="stylesheet" href="./tabs/auxiliary.css" media="all" />
<link type="text/css" rel="stylesheet" href="./tabs/failsafe.css" media="all" />
<link type="text/css" rel="stylesheet" href="./tabs/transponder.css" media="all" />
<link type="text/css" rel="stylesheet" href="./tabs/osd.css" media="all" />
<link type="text/css" rel="stylesheet" href="./css/opensans_webfontkit/fonts.css" media="all" />
<link type="text/css" rel="stylesheet" href="./css/dropdown-lists/css/style_lists.css" media="all" />
<link type="text/css" rel="stylesheet" href="./js/libraries/switchery/switchery.css" media="all" />
Expand All @@ -44,6 +45,9 @@
<script type="text/javascript" src="./js/libraries/semver.js"></script>
<script type="text/javascript" src="./js/libraries/jbox/jBox.min.js"></script>
<script type="text/javascript" src="./js/libraries/switchery/switchery.js"></script>
<script type="text/javascript" src="./js/libraries/jquery.ba-throttle-debounce.min.js"></script>
<script type="text/javascript" src="./js/libraries/inflection.min.js"></script>
<script type="text/javascript" src="./js/injected_methods.js"></script>
<script type="text/javascript" src="./js/port_handler.js"></script>
<script type="text/javascript" src="./js/port_usage.js"></script>
<script type="text/javascript" src="./js/serial.js"></script>
Expand Down Expand Up @@ -80,6 +84,7 @@
<script type="text/javascript" src="./tabs/firmware_flasher.js"></script>
<script type="text/javascript" src="./tabs/failsafe.js"></script>
<script type="text/javascript" src="./tabs/transponder.js"></script>
<script type="text/javascript" src="./tabs/osd.js"></script>
<title></title>
</head>
<body>
Expand Down Expand Up @@ -217,6 +222,7 @@
<li class="tab_servos"><a href="#" i18n="tabServos" class="tabicon ic_servo" title="Servos"></a></li>
<li class="tab_gps"><a href="#" i18n="tabGPS" class="tabicon ic_gps" title="GPS"></a></li>
<li class="tab_motors"><a href="#" i18n="tabMotorTesting" class="tabicon ic_motor" title="Motors"></a></li>
<li class="tab_osd"><a href="#" i18n="tabOSD" class="tabicon ic_osd" title="OSD"></a></li>
<li class="tab_transponder"><a href="#" i18n="tabTransponder" class="tabicon ic_transponder" title="Transponder"></a></li>
<li class="tab_led_strip"><a href="#" i18n="tabLedStrip" class="tabicon ic_led" title="LED Strip"></a></li>
<li class="tab_sensors"><a href="#" i18n="tabRawSensorData" class="tabicon ic_sensors" title="Sensors"></a></li>
Expand Down
4 changes: 4 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*global $, chrome*/
'use strict';

// Google Analytics
Expand Down Expand Up @@ -163,6 +164,9 @@ $(document).ready(function () {
case 'motors':
TABS.motors.initialize(content_ready);
break;
case 'osd':
TABS.osd.initialize(content_ready);
break;
case 'sensors':
TABS.sensors.initialize(content_ready);
break;
Expand Down
Loading

0 comments on commit 25c8a6f

Please sign in to comment.