From 6aaababb1d87c364276f6db9db887e5720188d11 Mon Sep 17 00:00:00 2001 From: Asizon <43983086+Asizon@users.noreply.github.com> Date: Wed, 4 Mar 2020 10:36:32 +0100 Subject: [PATCH 1/3] Adding Dynamic Idle --- locales/en/messages.json | 6 ++++++ src/js/fc.js | 1 + src/js/msp/MSPHelper.js | 4 +++- src/js/tabs/configuration.js | 41 ++++++++++++++++++++++++++++++------ src/tabs/configuration.html | 9 ++++++++ 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index b57be99cfb..fe9fdc7848 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1227,6 +1227,12 @@ "configurationDigitalIdlePercentHelp": { "message": "This is the 'idle' value in percent of maximum throttle that is sent to the ESCs when the craft is armed and the trottle stick is at minimum position. Increase the percent value to gain more idle speed." }, + "configurationIdleMinRpm": { + "message": "Dynamic Idle Value [rpm]" + }, + "configurationIdleMinRpmHelp": { + "message": "PIDPROFILE Value, visit this page " + }, "configurationMotorPoles": { "message": "Motor poles", "description": "One of the fields of the ESC/Motor configuration" diff --git a/src/js/fc.js b/src/js/fc.js index f10a3f3813..e6632e9a5e 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -460,6 +460,7 @@ var FC = { integratedYawRelax: 0, motorOutputLimit: 0, autoProfileCellCount: 0, + idleMinRpm: 0, }; ADVANCED_TUNING_ACTIVE = { ...ADVANCED_TUNING }; diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index e998e6aaa0..28c29ec931 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1146,6 +1146,7 @@ MspHelper.prototype.process_data = function(dataHandler) { if(semver.gte(CONFIG.apiVersion, "1.43.0")) { ADVANCED_TUNING.motorOutputLimit = data.readU8(); ADVANCED_TUNING.autoProfileCellCount = data.readU8(); + ADVANCED_TUNING.idleMinRpm = data.readU8(); } } } @@ -2079,7 +2080,8 @@ MspHelper.prototype.crunch = function(code) { if (semver.gte(CONFIG.apiVersion, "1.43.0")) { buffer.push8(ADVANCED_TUNING.motorOutputLimit) - .push8(ADVANCED_TUNING.autoProfileCellCount); + .push8(ADVANCED_TUNING.autoProfileCellCount) + .push8(ADVANCED_TUNING.idleMinRpm); } } } diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index 39b9975a44..e99ebb10e2 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -181,13 +181,22 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } function load_rx_config() { - var next_callback = load_html; + var next_callback = load_profile_features; if (semver.gte(CONFIG.apiVersion, "1.31.0")) { MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, next_callback); } else { next_callback(); } } + + function load_profile_features() { + var next_callback = load_html; + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + MSP.send_message(MSPCodes.MSP_PID_ADVANCED, false, false, next_callback); + } else { + next_callback(); + } + } function load_html() { $('#content').load("./tabs/configuration.html", process_html); @@ -516,9 +525,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles); } - function hideMotorPoles() { - let motorPolesVisible = $("input[id='dshotBidir']").is(':checked') || $("input[name='ESC_SENSOR']").is(':checked'); - $('div.motorPoles').toggle(motorPolesVisible); + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + $('input[name="idleMinRpm"]').val(ADVANCED_TUNING.idleMinRpm); + } + + function hideRpmFeatures() { + let rpmFeaturesVisible = $("input[id='dshotBidir']").is(':checked') || $("input[name='ESC_SENSOR']").is(':checked'); + $('div.motorPoles').toggle(rpmFeaturesVisible); + $('div.idleMinRpm').toggle(rpmFeaturesVisible); } $('#escProtocolTooltip').toggle(semver.lt(CONFIG.apiVersion, "1.42.0")); @@ -548,9 +562,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('div.checkboxDshotBidir').toggle(semver.gte(CONFIG.apiVersion, "1.42.0") && digitalProtocol); $('div.motorPoles').toggle(semver.gte(CONFIG.apiVersion, "1.42.0")); + $('div.idleMinRpm').toggle(semver.gte(CONFIG.apiVersion, "1.43.0")); //trigger change dshotBidir and ESC_SENSOR to show/hide Motor Poles tab - $("input[id='dshotBidir']").change(hideMotorPoles).change(); - $("input[name='ESC_SENSOR']").change(hideMotorPoles); + $("input[id='dshotBidir']").change(hideRpmFeatures).change(); + $("input[name='ESC_SENSOR']").change(hideRpmFeatures); //trigger change unsyncedPWMSwitch to show/hide Motor PWM freq input $("input[id='unsyncedPWMSwitch']").change(); @@ -1167,6 +1182,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) { if(semver.gte(CONFIG.apiVersion, "1.42.0")) { MOTOR_CONFIG.motor_poles = parseInt($('input[name="motorPoles"]').val()); } + if(semver.gte(CONFIG.apiVersion, "1.43.0")) { + ADVANCED_TUNING.idleMinRpm = parseInt($('input[name="idleMinRpm"]').val()); + } if(self.SHOW_OLD_BATTERY_CONFIG) { MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val()); @@ -1343,13 +1361,22 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } function save_rx_config() { - var next_callback = save_to_eeprom; + var next_callback = save_profile_features; if (semver.gte(CONFIG.apiVersion, "1.20.0")) { MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, next_callback); } else { next_callback(); } } + + function save_profile_features() { + var next_callback = save_to_eeprom; + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + MSP.send_message(MSPCodes.MSP_SET_PID_ADVANCED, mspHelper.crunch(MSPCodes.MSP_SET_PID_ADVANCED), false, next_callback); + } else { + next_callback(); + } + } function save_to_eeprom() { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot); diff --git a/src/tabs/configuration.html b/src/tabs/configuration.html index fe79919147..43bb2de4c4 100644 --- a/src/tabs/configuration.html +++ b/src/tabs/configuration.html @@ -209,6 +209,15 @@
+