1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-25 17:25:14 +03:00

Servo update fix

This commit is contained in:
Pawel Spychalski (DzikuVx) 2016-12-22 21:13:31 +01:00
parent 694d672e06
commit ef831a32ac

View file

@ -11,7 +11,9 @@ TABS.motors.initialize = function (callback) {
self.armed = false; self.armed = false;
self.feature3DSupported = false; self.feature3DSupported = false;
self.allowTestMode = true; self.allowTestMode = true;
var $motorsEnableTestMode = $('#motorsEnableTestMode');
if (GUI.active_tab != 'motors') { if (GUI.active_tab != 'motors') {
GUI.active_tab = 'motors'; GUI.active_tab = 'motors';
googleAnalytics.sendAppView('Motors'); googleAnalytics.sendAppView('Motors');
@ -26,14 +28,7 @@ TABS.motors.initialize = function (callback) {
} }
function load_3d() { function load_3d() {
var next_callback = get_motor_data; MSP.send_message(MSPCodes.MSP_3D, false, false, get_motor_data);
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
self.feature3DSupported = true;
MSP.send_message(MSPCodes.MSP_3D, false, false, next_callback);
} else {
next_callback();
}
} }
function get_motor_data() { function get_motor_data() {
@ -60,7 +55,7 @@ TABS.motors.initialize = function (callback) {
function initDataArray(length) { function initDataArray(length) {
var data = new Array(length); var data = new Array(length);
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
data[i] = new Array(); data[i] = [];
data[i].min = -1; data[i].min = -1;
data[i].max = 1; data[i].max = 1;
} }
@ -165,7 +160,7 @@ TABS.motors.initialize = function (callback) {
var group = svg.select("g.data"); var group = svg.select("g.data");
var lines = group.selectAll("path").data(data, function (d, i) {return i;}); var lines = group.selectAll("path").data(data, function (d, i) {return i;});
var newLines = lines.enter().append("path").attr("class", "line"); lines.enter().append("path").attr("class", "line");
lines.attr('d', graphHelpers.line); lines.attr('d', graphHelpers.line);
} }
@ -182,9 +177,9 @@ TABS.motors.initialize = function (callback) {
if (self.feature3DEnabled && !self.feature3DSupported) { if (self.feature3DEnabled && !self.feature3DSupported) {
self.allowTestMode = false; self.allowTestMode = false;
} }
$('#motorsEnableTestMode').prop('checked', false); $motorsEnableTestMode.prop('checked', false);
$('#motorsEnableTestMode').prop('disabled', true); $motorsEnableTestMode.prop('disabled', true);
update_model(CONFIG.multiType); update_model(CONFIG.multiType);
@ -383,7 +378,7 @@ TABS.motors.initialize = function (callback) {
$('div.sliders input:not(:last):first').trigger('input'); $('div.sliders input:not(:last):first').trigger('input');
}); });
$('#motorsEnableTestMode').change(function () { $motorsEnableTestMode.change(function () {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
$('div.sliders input').slice(0, number_of_valid_outputs).prop('disabled', false); $('div.sliders input').slice(0, number_of_valid_outputs).prop('disabled', false);
@ -423,7 +418,7 @@ TABS.motors.initialize = function (callback) {
if (motors_running) { if (motors_running) {
if (!self.armed && self.allowTestMode) { if (!self.armed && self.allowTestMode) {
$('#motorsEnableTestMode').prop('checked', true); $motorsEnableTestMode.prop('checked', true);
} }
// motors are running adjust sliders to current values // motors are running adjust sliders to current values
@ -450,29 +445,30 @@ TABS.motors.initialize = function (callback) {
} }
} }
$('#motorsEnableTestMode').change(); $motorsEnableTestMode.change();
// data pulling functions used inside interval timer // data pulling functions used inside interval timer
function get_status() { function periodicUpdateHandler() {
// status needed for arming flag
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) { if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, get_sensor_status); getPeriodicSensorStatus();
} } else {
else { getPeriodicMotorOutput();
MSP.send_message(MSPCodes.MSP_STATUS, false, false, get_motor_data);
} }
} }
function get_sensor_status() { function getPeriodicSensorStatus() {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, get_motor_data); MSP.send_message(MSPCodes.MSP_SENSOR_STATUS, false, false, getPeriodicMotorOutput);
} }
function get_motor_data() { function getPeriodicMotorOutput() {
MSP.send_message(MSPCodes.MSP_MOTOR, false, false, get_servo_data); MSP.send_message(MSPCodes.MSP_MOTOR, false, false, getPeriodicServoOutput);
} }
function get_servo_data() { function getPeriodicServoOutput() {
MSP.send_message(MSPCodes.MSP_SERVO, false, false, update_ui); MSP.send_message(MSPCodes.MSP_SERVO, false, false, update_ui);
} }
@ -507,22 +503,22 @@ TABS.motors.initialize = function (callback) {
if (!self.allowTestMode) return; if (!self.allowTestMode) return;
if (self.armed) { if (self.armed) {
$('#motorsEnableTestMode').prop('disabled', true); $motorsEnableTestMode.prop('disabled', true);
$('#motorsEnableTestMode').prop('checked', false); $motorsEnableTestMode.prop('checked', false);
} else { } else {
if (self.allowTestMode) { if (self.allowTestMode) {
$('#motorsEnableTestMode').prop('disabled', false); $motorsEnableTestMode.prop('disabled', false);
} }
} }
if (previousArmState != self.armed) { if (previousArmState != self.armed) {
console.log('arm state change detected'); console.log('arm state change detected');
$('#motorsEnableTestMode').change(); $motorsEnableTestMode.change();
} }
} }
// enable Status and Motor data pulling // enable Status and Motor data pulling
GUI.interval_add('motor_and_status_pull', get_status, 50, true); GUI.interval_add('motor_and_status_pull', periodicUpdateHandler, 75, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }