From dfc04a21544d6fddbf29c555182c527557844850 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Wed, 22 May 2024 16:47:03 +0200 Subject: [PATCH] Add support for gyro_cal_on_first_arm (#3938) * Add support for gyro_cal_on_first_arm * Add semver magic * cleanup * cleanup html * Update added parameter * Another update * Remove auto imported vite import * Change API and hide better --- locales/en/messages.json | 10 +++++----- src/css/tabs/configuration.less | 5 ----- src/js/fc.js | 1 + src/js/msp/MSPHelper.js | 10 ++++++++-- src/js/tabs/configuration.js | 21 ++++++++++++++++++--- src/tabs/configuration.html | 25 ++++++++++++++++++------- 6 files changed, 50 insertions(+), 22 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 6f1915df2e..6a23d638bb 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1395,13 +1395,13 @@ "message": "This option configures the mixer to expect the motor direction to be reversed and the propellers to be on accordingly. Warning: This does not reverse the motor direction. Use the configuration tool for your ESCs or switch the ESC - motor wiring order to achieve this. Also, make sure to check with propellers off that your motors are rotating in the directions shown in the diagram above before attempting to arm." }, "configurationAutoDisarmDelay": { - "message": "Disarm motors after set delay [seconds] (Requires MOTOR_STOP feature)" + "message": "Disarm motors after delay [seconds]" }, - "configurationDisarmKillSwitch": { - "message": "Disarm motors regardless of throttle value (When ARM is configured in Modes tab via AUX channel)" + "configurationAutoDisarmDelayHelp": { + "message": "Disarm motors after set delay [seconds] (Requires MOTOR_STOP feature)" }, - "configurationDisarmKillSwitchHelp": { - "message": "Arming is always disabled when the throttle is not low. Be careful as you could disarm accidentally with a switch while flying with this option active." + "configurationGyroCalOnFirstArm": { + "message": "Calibrate Gyro on first arm" }, "configurationDigitalIdlePercent": { "message": "Motor Idle ( %, static)" diff --git a/src/css/tabs/configuration.less b/src/css/tabs/configuration.less index 1420f7a084..62000b2f60 100644 --- a/src/css/tabs/configuration.less +++ b/src/css/tabs/configuration.less @@ -301,11 +301,6 @@ margin-right: 10px; font-weight: bold; } - ._smallAngle { - margin-top: 10px; - float: left; - width: 100%; - } } @media only screen and (max-width: 1055px) { .tab-configuration { diff --git a/src/js/fc.js b/src/js/fc.js index 4f51eedc1e..fece876ff7 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -392,6 +392,7 @@ const FC = { auto_disarm_delay: 0, disarm_kill_switch: 0, small_angle: 0, + gyro_cal_on_first_arm: 0, }; this.FC_CONFIG = { diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index a922efce31..dcdd4018d6 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -466,8 +466,11 @@ MspHelper.prototype.process_data = function(dataHandler) { case MSPCodes.MSP_ARMING_CONFIG: FC.ARMING_CONFIG.auto_disarm_delay = data.readU8(); - FC.ARMING_CONFIG.disarm_kill_switch = data.readU8(); + data.readU8(); // was FC.ARMING_CONFIG.auto_disarm_kill_switch FC.ARMING_CONFIG.small_angle = data.readU8(); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + FC.ARMING_CONFIG.gyro_cal_on_first_arm = data.readU8(); + } break; case MSPCodes.MSP_LOOP_TIME: FC.FC_CONFIG.loopTime = data.readU16(); @@ -1792,8 +1795,11 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) { break; case MSPCodes.MSP_SET_ARMING_CONFIG: buffer.push8(FC.ARMING_CONFIG.auto_disarm_delay) - .push8(FC.ARMING_CONFIG.disarm_kill_switch) + .push8(0) // was disarm_kill_switch .push8(FC.ARMING_CONFIG.small_angle); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + buffer.push8(FC.ARMING_CONFIG.gyro_cal_on_first_arm); + } break; case MSPCodes.MSP_SET_LOOP_TIME: buffer.push16(FC.FC_CONFIG.loopTime); diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index fb8ea8c248..012a5c1d37 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -6,7 +6,7 @@ import { mspHelper } from '../msp/MSPHelper'; import FC from '../fc'; import MSP from '../msp'; import MSPCodes from '../msp/MSPCodes'; -import { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_45 } from '../data_storage'; +import { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_45, API_VERSION_1_46 } from '../data_storage'; import { updateTabList } from '../utils/updateTabList'; import $ from 'jquery'; @@ -343,9 +343,21 @@ configuration.initialize = function (callback) { $('input[name="roll"]').val(FC.CONFIG.accelerometerTrims[1]); $('input[name="pitch"]').val(FC.CONFIG.accelerometerTrims[0]); - $('._smallAngle').show(); $('input[id="configurationSmallAngle"]').val(FC.ARMING_CONFIG.small_angle); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + $('input[id="configurationGyroCalOnFirstArm"]').prop('checked', FC.ARMING_CONFIG.gyro_cal_on_first_arm === 1); + + if (FC.FEATURE_CONFIG.features.isEnabled('MOTOR_STOP')) { + $('input[id="configurationAutoDisarmDelay"]').val(FC.ARMING_CONFIG.auto_disarm_delay); + } else { + $('input[id="configurationAutoDisarmDelay"]').parent().hide(); + } + } else { + $('input[id="configurationGyroCalOnFirstArm"]').parent().parent().hide(); + $('input[id="configurationAutoDisarmDelay"]').parent().parent().hide(); + } + // UI hooks function checkUpdateGpsControls() { @@ -395,7 +407,10 @@ configuration.initialize = function (callback) { FC.CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val()); FC.CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val()); - // small angle configuration + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + FC.ARMING_CONFIG.gyro_cal_on_first_arm = $('input[id="configurationGyroCalOnFirstArm"]').is(':checked') ? 1 : 0; + FC.ARMING_CONFIG.auto_disarm_delay = parseInt($('input[id="configurationAutoDisarmDelay"]').val()); + } FC.ARMING_CONFIG.small_angle = parseInt($('input[id="configurationSmallAngle"]').val()); FC.SENSOR_ALIGNMENT.gyro_to_use = parseInt(orientation_gyro_to_use_e.val()); diff --git a/src/tabs/configuration.html b/src/tabs/configuration.html index 9078dc18e7..1285949aea 100644 --- a/src/tabs/configuration.html +++ b/src/tabs/configuration.html @@ -104,14 +104,25 @@
-
-
- +
+ +
+
+ +
+
+
+
+