From b8acb13e5dd660370d11c8ec97efb5f8a43ba542 Mon Sep 17 00:00:00 2001 From: tricopterY Date: Sun, 10 Jan 2016 09:48:41 +1100 Subject: [PATCH 1/6] Motors test mode switch and dynamically enabling/disabling Switchery Sliders see: #297 and #233 --- tabs/motors.html | 20 ++++++++++---------- tabs/motors.js | 45 +++++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/tabs/motors.html b/tabs/motors.html index 2cc9ccfe..2b2b2ff7 100644 --- a/tabs/motors.html +++ b/tabs/motors.html @@ -92,15 +92,15 @@
- + + + + + + + + +
    @@ -118,7 +118,7 @@

-
diff --git a/tabs/motors.js b/tabs/motors.js index 373fef40..1ddb0fcc 100644 --- a/tabs/motors.js +++ b/tabs/motors.js @@ -183,7 +183,8 @@ TABS.motors.initialize = function (callback) { self.allowTestMode = false; } - $('#motorsEnableTestMode').prop('disabled', 'true'); + $('#motorsEnableTestMode').prop('checked', false); + $('#motorsEnableTestMode').prop('disabled', true); update_model(CONFIG.multiType); @@ -345,7 +346,7 @@ TABS.motors.initialize = function (callback) { if (!buffer_delay) { buffer_delay = setTimeout(function () { buffer = buffering_set_motor.pop(); - + MSP.send_message(MSP_codes.MSP_SET_MOTOR, buffer); buffering_set_motor = []; @@ -448,26 +449,9 @@ TABS.motors.initialize = function (callback) { } var full_block_scale = MISC.maxthrottle - MISC.mincommand; - function update_ui() { - - var previousArmState = self.armed; - - update_arm_status(); - - if (self.armed) { - $('#motorsEnableTestMode').prop('disabled', true); - $('#motorsEnableTestMode').prop('checked', false); - } else { - if (self.allowTestMode) { - $('#motorsEnableTestMode').prop('disabled', false); - } - } - - if (previousArmState != self.armed) { - console.log('arm state change detected'); - $('#motorsEnableTestMode').change(); - } - + + function update_ui() { + var previousArmState = self.armed; var block_height = $('div.m-block:first').height(); for (var i = 0; i < MOTOR_DATA.length; i++) { @@ -490,6 +474,23 @@ TABS.motors.initialize = function (callback) { $('.servo-' + i + ' .label', servos_wrapper).text(SERVO_DATA[i]); $('.servo-' + i + ' .indicator', servos_wrapper).css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgba(89,170,41,1'+ color +')'}); } + //keep the following here so at least we get a visual cue of our motor setup + update_arm_status(); + if (!self.allowTestMode) return; + + if (self.armed) { + $('#motorsEnableTestMode').prop('disabled', true); + $('#motorsEnableTestMode').prop('checked', false); + } else { + if (self.allowTestMode) { + $('#motorsEnableTestMode').prop('disabled', false); + } + } + + if (previousArmState != self.armed) { + console.log('arm state change detected'); + $('#motorsEnableTestMode').change(); + } } // enable Status and Motor data pulling From 17d4a0153b3c35363eaa3c313c15dae16ad1f226 Mon Sep 17 00:00:00 2001 From: tricopterY Date: Sun, 10 Jan 2016 10:46:52 +1100 Subject: [PATCH 2/6] Update motors.html --- tabs/motors.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/motors.html b/tabs/motors.html index 2b2b2ff7..4fcfdcd6 100644 --- a/tabs/motors.html +++ b/tabs/motors.html @@ -118,7 +118,7 @@

-
@@ -126,4 +126,4 @@
- \ No newline at end of file + From 48a5953db1636db24799a13a317b52eab42767d6 Mon Sep 17 00:00:00 2001 From: tricopterY Date: Sun, 10 Jan 2016 11:40:11 +1100 Subject: [PATCH 3/6] Limitting 3D Neutral value to 1475 - 1525 --- tabs/configuration.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/configuration.html b/tabs/configuration.html index 763c1929..53b48e62 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -420,7 +420,7 @@
-
@@ -439,4 +439,4 @@ - \ No newline at end of file + From d22271ce61b8414281dbac145a6089a6bf7cc538 Mon Sep 17 00:00:00 2001 From: tricopterY Date: Sun, 10 Jan 2016 13:25:03 +1100 Subject: [PATCH 4/6] Sanity Check 3D-Neutral limits --- tabs/motors.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tabs/motors.js b/tabs/motors.js index 1ddb0fcc..e950f5b9 100644 --- a/tabs/motors.js +++ b/tabs/motors.js @@ -318,6 +318,11 @@ TABS.motors.initialize = function (callback) { $('div.values li:not(:last)').text(MISC.mincommand); if(self.feature3DEnabled && self.feature3DSupported) { + //Arbitrary sanity checks + //Note: values may need to be revisited + if(_3D.neutral3d > 1575 || _3D.neutral3d < 1425) + _3D.neutral3d = 1500; + $('div.sliders input').val(_3D.neutral3d); } else { $('div.sliders input').val(MISC.mincommand); @@ -502,4 +507,4 @@ TABS.motors.initialize = function (callback) { TABS.motors.cleanup = function (callback) { if (callback) callback(); -}; \ No newline at end of file +}; From eeccdd456b4b43f773d6f6905b80960320b11b62 Mon Sep 17 00:00:00 2001 From: tricopterY Date: Mon, 11 Jan 2016 13:12:06 +1100 Subject: [PATCH 5/6] Limitting 3D-Neutral and 3D-Deadband Low/High Limitting 3D Neutral value to 1475 - 1525 and 3D Deadband values relative to Neutral --- tabs/configuration.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/configuration.html b/tabs/configuration.html index 53b48e62..540c2540 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -410,12 +410,12 @@
-
-
From da4f916f101bc62fd2d4ef6577bafb867e34a07a Mon Sep 17 00:00:00 2001 From: NightHawk32 Date: Tue, 12 Jan 2016 17:18:34 -0500 Subject: [PATCH 6/6] no modifications to motor values in 3d mode if msp 3d isn't supported --- tabs/motors.js | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/tabs/motors.js b/tabs/motors.js index e950f5b9..7661d7fb 100644 --- a/tabs/motors.js +++ b/tabs/motors.js @@ -328,37 +328,39 @@ TABS.motors.initialize = function (callback) { $('div.sliders input').val(MISC.mincommand); } - // UI hooks - var buffering_set_motor = [], - buffer_delay = false; - $('div.sliders input:not(.master)').on('input', function () { + if(self.allowTestMode){ + // UI hooks + var buffering_set_motor = [], + buffer_delay = false; + $('div.sliders input:not(.master)').on('input', function () { - var index = $(this).index(), - buffer = [], - i; + var index = $(this).index(), + buffer = [], + i; - $('div.values li').eq(index).text($(this).val()); + $('div.values li').eq(index).text($(this).val()); - for (i = 0; i < 8; i++) { - var val = parseInt($('div.sliders input').eq(i).val()); + for (i = 0; i < 8; i++) { + var val = parseInt($('div.sliders input').eq(i).val()); - buffer.push(lowByte(val)); - buffer.push(highByte(val)); - } - - buffering_set_motor.push(buffer); + buffer.push(lowByte(val)); + buffer.push(highByte(val)); + } + + buffering_set_motor.push(buffer); - if (!buffer_delay) { - buffer_delay = setTimeout(function () { - buffer = buffering_set_motor.pop(); + if (!buffer_delay) { + buffer_delay = setTimeout(function () { + buffer = buffering_set_motor.pop(); - MSP.send_message(MSP_codes.MSP_SET_MOTOR, buffer); + MSP.send_message(MSP_codes.MSP_SET_MOTOR, buffer); - buffering_set_motor = []; - buffer_delay = false; - }, 10); - } - }); + buffering_set_motor = []; + buffer_delay = false; + }, 10); + } + }); + } $('div.sliders input.master').on('input', function () { var val = $(this).val(); @@ -385,8 +387,7 @@ TABS.motors.initialize = function (callback) { $('div.sliders input').val(MISC.mincommand); } - // trigger change event so values are sent to mcu - $('div.sliders input').trigger('input'); + $('div.sliders input').trigger('input'); } }); @@ -394,7 +395,7 @@ TABS.motors.initialize = function (callback) { var motors_running = false; for (var i = 0; i < number_of_valid_outputs; i++) { - if( ! bit_check(BF_CONFIG.features,12) ){ + if( !self.feature3DEnabled ){ if (MOTOR_DATA[i] > MISC.mincommand) { motors_running = true; break; @@ -408,7 +409,7 @@ TABS.motors.initialize = function (callback) { } if (motors_running) { - if (!self.armed) { + if (!self.armed && self.allowTestMode) { $('#motorsEnableTestMode').prop('checked', true); } // motors are running adjust sliders to current values