Disable use of switchery on motors tab for motor control checkbox.

Switchery sliders do not respect the 'disabled' property.
10.3.x-maintenance
Dominic Clifton 2015-12-16 12:12:02 +01:00
parent af2089e38c
commit 18fd5d01ec
2 changed files with 36 additions and 17 deletions

View File

@ -118,7 +118,7 @@
</div>
<div class="notice">
<p i18n="motorsNotice"></p>
<label><input id="motorsEnableTestMode" class="togglesmall" type="checkbox" /><span
<label><input id="motorsEnableTestMode" type="checkbox" /><span
class="motorsEnableTestMode" i18n="motorsEnableControl"></span></label>
</div>
<div class="cler-both"></div>

View File

@ -1,6 +1,10 @@
'use strict';
TABS.motors = {};
TABS.motors = {
allowTestMode: false,
feature3DEnabled: false,
feature3DSupported: false
};
TABS.motors.initialize = function (callback) {
var self = this;
@ -20,13 +24,16 @@ TABS.motors.initialize = function (callback) {
}
function load_3d() {
MSP.send_message(MSP_codes.MSP_3D, false, false, get_motor_data);
var next_callback = get_motor_data;
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
self.feature3DSupported = true;
MSP.send_message(MSP_codes.MSP_3D, false, false, next_callback);
} else {
next_callback();
}
}
function update_arm_status() {
self.armed = bit_check(CONFIG.mode, 0);
}
function get_motor_data() {
update_arm_status();
MSP.send_message(MSP_codes.MSP_MOTOR, false, false, load_html);
@ -38,6 +45,10 @@ TABS.motors.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_MISC, false, false, get_arm_status);
function update_arm_status() {
self.armed = bit_check(CONFIG.mode, 0);
}
function initSensorData() {
for (var i = 0; i < 3; i++) {
SENSOR_DATA.accelerometer[i] = 0;
@ -164,8 +175,14 @@ TABS.motors.initialize = function (callback) {
// translate to user-selected language
localize();
self.feature3DEnabled = bit_check(BF_CONFIG.features, 12);
self.allowTestMode = true;
if (self.feature3DEnabled && !self.feature3DSupported) {
self.allowTestMode = false;
}
$('#motorsEnableTestMode').prop('disabled', 'true');
update_model(CONFIG.multiType);
// Always start with default/empty sensor data array, clean slate all
@ -296,12 +313,12 @@ TABS.motors.initialize = function (callback) {
$('div.sliders input').prop('min', MISC.mincommand);
$('div.sliders input').prop('max', MISC.maxthrottle);
$('div.values li:not(:last)').text(MISC.mincommand);
if(bit_check(BF_CONFIG.features,12)){
if(self.feature3DEnabled && self.feature3DSupported) {
$('div.sliders input').val(_3D.neutral3d);
}else{
$('div.sliders input').val(MISC.mincommand);
}
} else {
$('div.sliders input').val(MISC.mincommand);
}
// UI hooks
var buffering_set_motor = [],
@ -354,10 +371,10 @@ TABS.motors.initialize = function (callback) {
$('div.sliders input').prop('disabled', true);
// change all values to default
if (! bit_check(BF_CONFIG.features,12)) {
$('div.sliders input').val(MISC.mincommand);
} else {
if (self.feature3DEnabled && self.feature3DSupported) {
$('div.sliders input').val(_3D.neutral3d);
} else {
$('div.sliders input').val(MISC.mincommand);
}
// trigger change event so values are sent to mcu
@ -439,7 +456,9 @@ TABS.motors.initialize = function (callback) {
$('#motorsEnableTestMode').prop('disabled', true);
$('#motorsEnableTestMode').prop('checked', false);
} else {
$('#motorsEnableTestMode').prop('disabled', false);
if (self.allowTestMode) {
$('#motorsEnableTestMode').prop('disabled', false);
}
}
if (previousArmState != self.armed) {