From 3305d3a3fdc5f606bbf72537745f8b87db40ee6b Mon Sep 17 00:00:00 2001 From: iso9660 Date: Sat, 21 Jan 2023 01:08:07 +0100 Subject: [PATCH 1/4] Added new DSHOT debug modes Added checkbox to activate edt Restore other translation files than the english one Added logic to handle DSHOT edt checkbox in motors tab. Bumped API_VERSION to 1.46. Added dshot_edt setting to MSP_MOTOR_CONFIG frame. Added dshot_edt setting to MSP_SET_MOTOR_CONFIG frame. Updated API_VERSION in generate_filename. Fixed features in motors tab. Added exclusive selection between ESC_SENSOR and EDT options. Fixed a bug Fixed review findings Removed unecessary imports Fixed review findings Fixed review findings Added debug mode to match edt_events Betaflight branch Fixed RPM_LIMIT debug mode name Small refactoring to be coherent to current code style --- locales/en/messages.json | 6 +++++- src/js/VirtualFC.js | 1 + src/js/debug.js | 7 +++++++ src/js/fc.js | 1 + src/js/msp/MSPHelper.js | 22 +++++++++++++++++++--- src/js/tabs/motors.js | 38 +++++++++++++++++++++++++++++++++++++- src/tabs/motors.html | 6 +++++- 7 files changed, 75 insertions(+), 6 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 0a64e20143..6aba7f6475 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -6786,8 +6786,12 @@ "message": "Bidirectional DShot (requires supported ESC firmware)", "description": "Feature for the ESC/Motor" }, + "configurationDshotEdt": { + "message": "Built-in sensors", + "description": "ESC/Motor feature" + }, "configurationDshotBidirHelp": { - "message": "Sends ESC data to the FC via DShot telemetry. Required by RPM Filtering and dynamic idle.

Note: Requires a compatible ESC with appropriate firmware, eg JESC, Jazzmac, BLHeli-32.", + "message": "Sends ESC data to the FC via DShot telemetry. Required by RPM Filtering and dynamic idle.

Note: Requires a compatible ESC with appropriate firmware, eg Bluejay, AM32, JESC, Jazzmac, BLHeli-32.", "description": "Description of the Bidirectional DShot feature of the ESC/Motor" }, "configurationGyroSyncDenom": { diff --git a/src/js/VirtualFC.js b/src/js/VirtualFC.js index 05d0ecdab1..1e36cf4497 100644 --- a/src/js/VirtualFC.js +++ b/src/js/VirtualFC.js @@ -52,6 +52,7 @@ const VirtualFC = { motor_count: 4, motor_poles: 14, use_dshot_telemetry: true, + use_dshot_edt: true, use_esc_sensor: false, }; diff --git a/src/js/debug.js b/src/js/debug.js index d38c545c75..3a34cf0c43 100644 --- a/src/js/debug.js +++ b/src/js/debug.js @@ -98,6 +98,13 @@ const DEBUG = { {text: "S_TERM"}, {text: "SPA"}, {text: "TASK"}, + {text: "DSHOT_STATUS_N_TEMPERATURE"}, + {text: "DSHOT_STATUS_N_VOLTAGE"}, + {text: "DSHOT_STATUS_N_CURRENT"}, + {text: "DSHOT_STATUS_N_DEBUG1"}, + {text: "DSHOT_STATUS_N_DEBUG2"}, + {text: "DSHOT_STATUS_N_STRESS_LVL"}, + {text: "DSHOT_STATUS_N_ERPM_FRACTION_18"}, ], fieldNames: { diff --git a/src/js/fc.js b/src/js/fc.js index c14636d99c..e2c2fb7607 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -397,6 +397,7 @@ const FC = { motor_count: 0, motor_poles: 0, use_dshot_telemetry: false, + use_dshot_edt: false, use_esc_sensor: false, }; diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 26267dcc4a..885cf2376e 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -497,6 +497,17 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.MOTOR_CONFIG.motor_poles = data.readU8(); FC.MOTOR_CONFIG.use_dshot_telemetry = data.readU8() != 0; FC.MOTOR_CONFIG.use_esc_sensor = data.readU8() != 0; + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) { + FC.MOTOR_CONFIG.motor_count = data.readU8(); + FC.MOTOR_CONFIG.motor_poles = data.readU8(); + FC.MOTOR_CONFIG.use_dshot_telemetry = data.readU8() != 0; + FC.MOTOR_CONFIG.use_esc_sensor = data.readU8() != 0; + } + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + FC.MOTOR_CONFIG.use_dshot_edt = data.readU8() != 0; + } break; case MSPCodes.MSP_COMPASS_CONFIG: FC.COMPASS_CONFIG.mag_declination = data.read16() / 10; @@ -1816,9 +1827,14 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) { .push16(FC.MOTOR_CONFIG.maxthrottle) .push16(FC.MOTOR_CONFIG.mincommand); - // Introduced in 1.42 - buffer.push8(FC.MOTOR_CONFIG.motor_poles); - buffer.push8(FC.MOTOR_CONFIG.use_dshot_telemetry ? 1 : 0); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) { + buffer.push8(FC.MOTOR_CONFIG.motor_poles); + buffer.push8(FC.MOTOR_CONFIG.use_dshot_telemetry ? 1 : 0); + } + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + buffer.push8(FC.MOTOR_CONFIG.use_dshot_edt ? 1 : 0); + } break; case MSPCodes.MSP_SET_GPS_CONFIG: buffer.push8(FC.GPS_CONFIG.provider) diff --git a/src/js/tabs/motors.js b/src/js/tabs/motors.js index a479ff3d5b..920cefa617 100644 --- a/src/js/tabs/motors.js +++ b/src/js/tabs/motors.js @@ -12,6 +12,7 @@ import FC from "../fc"; import MSP from "../msp"; import { mixerList } from "../model"; import MSPCodes from "../msp/MSPCodes"; +import { API_VERSION_1_42, API_VERSION_1_44, API_VERSION_1_46 } from "../data_storage"; import EscProtocols from "../utils/EscProtocols"; import { updateTabList } from "../utils/updateTabList"; import { isInt, getMixerImageSrc } from "../utils/common"; @@ -20,6 +21,7 @@ import $ from 'jquery'; const motors = { previousDshotBidir: null, + previousDshotEdt: null, previousFilterDynQ: null, previousFilterDynCount: null, analyticsChanges: {}, @@ -275,6 +277,7 @@ motors.initialize = async function (callback) { feature12: FC.FEATURE_CONFIG.features.isEnabled('3D'), feature27: FC.FEATURE_CONFIG.features.isEnabled('ESC_SENSOR'), dshotBidir: FC.MOTOR_CONFIG.use_dshot_telemetry, + dshotEdt: FC.MOTOR_CONFIG.use_dshot_edt, motorPoles: FC.MOTOR_CONFIG.motor_poles, digitalIdlePercent: FC.PID_ADVANCED_CONFIG.digitalIdlePercent, idleMinRpm: FC.ADVANCED_TUNING.idleMinRpm, @@ -695,6 +698,7 @@ motors.initialize = async function (callback) { dshotBidirElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_telemetry).trigger("change"); self.previousDshotBidir = FC.MOTOR_CONFIG.use_dshot_telemetry; + self.previousDshotEdt = FC.MOTOR_CONFIG.use_dshot_edt; self.previousFilterDynQ = FC.FILTER_CONFIG.dyn_notch_q; self.previousFilterDynCount = FC.FILTER_CONFIG.dyn_notch_count; @@ -703,6 +707,12 @@ motors.initialize = async function (callback) { const newValue = (value !== FC.MOTOR_CONFIG.use_dshot_telemetry) ? 'On' : 'Off'; self.analyticsChanges['BidirectionalDshot'] = newValue; FC.MOTOR_CONFIG.use_dshot_telemetry = value; + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && !value) { + const dshotEdtElement = $('input[id="dshotEdt"]'); + + FC.MOTOR_CONFIG.use_dshot_edt = value; + dshotEdtElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_edt).trigger("change"); + } const rpmFilterIsDisabled = FC.FILTER_CONFIG.gyro_rpm_notch_harmonics === 0; FC.FILTER_CONFIG.dyn_notch_count = self.previousFilterDynCount; @@ -733,6 +743,21 @@ motors.initialize = async function (callback) { FC.FILTER_CONFIG.dyn_notch_count = self.previousFilterDynCount; FC.FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ; } + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + const dshotEdtElement = $('input[id="dshotEdt"]'); + + dshotEdtElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_edt).trigger("change"); + dshotEdtElement.on("change", function () { + const value = dshotEdtElement.is(':checked'); + const newValue = (value !== FC.MOTOR_CONFIG.use_dshot_edt) ? 'On' : 'Off'; + + self.analyticsChanges['DshotEdt'] = newValue; + FC.MOTOR_CONFIG.use_dshot_edt = value; + }); + } + + $('input[name="motorPoles"]').val(FC.MOTOR_CONFIG.motor_poles); }); $('input[name="motorPoles"]').val(FC.MOTOR_CONFIG.motor_poles); @@ -768,7 +793,10 @@ motors.initialize = async function (callback) { $('div.digitalIdlePercent').hide(); } - $('.escSensor').toggle(protocolConfigured && digitalProtocol); + $('.escSensor').toggle( + protocolConfigured && digitalProtocol && ( + semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46) || + semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && !FC.MOTOR_CONFIG.use_dshot_edt)); $('div.checkboxDshotBidir').toggle(protocolConfigured && digitalProtocol); $('div.motorPoles').toggle(protocolConfigured && rpmFeaturesVisible); @@ -776,6 +804,9 @@ motors.initialize = async function (callback) { $('.escMotorStop').toggle(protocolConfigured); $('#escProtocolDisabled').toggle(!protocolConfigured); + $('.checkboxDshotEdt').toggle( + protocolConfigured && digitalProtocol && dshotBidirElement.is(':checked') && + !$("input[name='ESC_SENSOR']").is(':checked') && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)); //trigger change unsyncedPWMSwitch to show/hide Motor PWM freq input unsyncedPWMSwitchElement.trigger("change"); @@ -797,6 +828,11 @@ motors.initialize = async function (callback) { //trigger change dshotBidir and ESC_SENSOR to show/hide Motor Poles tab dshotBidirElement.change(updateVisibility).trigger("change"); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + const dshotEdtElement = $('input[id="dshotEdt"]'); + + dshotEdtElement.change(updateVisibility).trigger("change"); + } $("input[name='ESC_SENSOR']").on("change", updateVisibility).trigger("change"); // fill throttle diff --git a/src/tabs/motors.html b/src/tabs/motors.html index 0257a89f52..ac72060bb7 100644 --- a/src/tabs/motors.html +++ b/src/tabs/motors.html @@ -88,8 +88,12 @@
+ +
+
+ +
-
From ebbafd6c780dc60a90ae3aa11ea350472acbd469 Mon Sep 17 00:00:00 2001 From: Chris L Date: Thu, 29 Aug 2024 01:22:51 +0200 Subject: [PATCH 2/4] Move EDT checkbox to separate row --- src/tabs/motors.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tabs/motors.html b/src/tabs/motors.html index ac72060bb7..c6d39063bd 100644 --- a/src/tabs/motors.html +++ b/src/tabs/motors.html @@ -90,7 +90,9 @@
-
+
+
+
From 21ec939fc5d183d94f9e2fc6804cc5081bdca0a9 Mon Sep 17 00:00:00 2001 From: Chris L Date: Thu, 29 Aug 2024 01:35:47 +0200 Subject: [PATCH 3/4] Bumped API versions, import semver --- src/js/data_storage.js | 1 + src/js/msp/MSPHelper.js | 6 +++--- src/js/tabs/motors.js | 22 +++++++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/js/data_storage.js b/src/js/data_storage.js index efb37b3498..d56b4a8f11 100644 --- a/src/js/data_storage.js +++ b/src/js/data_storage.js @@ -1,4 +1,5 @@ export const API_VERSION_1_39 = '1.39.0'; +export const API_VERSION_1_42 = '1.42.0'; export const API_VERSION_1_44 = '1.44.0'; export const API_VERSION_1_45 = '1.45.0'; export const API_VERSION_1_46 = '1.46.0'; diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 885cf2376e..a19dcefed9 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -8,7 +8,7 @@ import semver from 'semver'; import vtxDeviceStatusFactory from "../utils/VtxDeviceStatus/VtxDeviceStatusFactory"; import MSP from "../msp"; import MSPCodes from "./MSPCodes"; -import { API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47 } from '../data_storage'; +import { API_VERSION_1_42, API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47 } from '../data_storage'; import EscProtocols from "../utils/EscProtocols"; import huffmanDecodeBuf from "../huffman"; import { defaultHuffmanTree, defaultHuffmanLenIndex } from "../default_huffman_tree"; @@ -505,7 +505,7 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.MOTOR_CONFIG.use_esc_sensor = data.readU8() != 0; } - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) { FC.MOTOR_CONFIG.use_dshot_edt = data.readU8() != 0; } break; @@ -1832,7 +1832,7 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) { buffer.push8(FC.MOTOR_CONFIG.use_dshot_telemetry ? 1 : 0); } - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) { buffer.push8(FC.MOTOR_CONFIG.use_dshot_edt ? 1 : 0); } break; diff --git a/src/js/tabs/motors.js b/src/js/tabs/motors.js index 920cefa617..3d47daeac9 100644 --- a/src/js/tabs/motors.js +++ b/src/js/tabs/motors.js @@ -12,12 +12,13 @@ import FC from "../fc"; import MSP from "../msp"; import { mixerList } from "../model"; import MSPCodes from "../msp/MSPCodes"; -import { API_VERSION_1_42, API_VERSION_1_44, API_VERSION_1_46 } from "../data_storage"; +import { API_VERSION_1_46, API_VERSION_1_47 } from "../data_storage"; import EscProtocols from "../utils/EscProtocols"; import { updateTabList } from "../utils/updateTabList"; import { isInt, getMixerImageSrc } from "../utils/common"; import * as d3 from 'd3'; import $ from 'jquery'; +import semver from 'semver'; const motors = { previousDshotBidir: null, @@ -707,10 +708,11 @@ motors.initialize = async function (callback) { const newValue = (value !== FC.MOTOR_CONFIG.use_dshot_telemetry) ? 'On' : 'Off'; self.analyticsChanges['BidirectionalDshot'] = newValue; FC.MOTOR_CONFIG.use_dshot_telemetry = value; - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && !value) { - const dshotEdtElement = $('input[id="dshotEdt"]'); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47) && !value) { FC.MOTOR_CONFIG.use_dshot_edt = value; + + const dshotEdtElement = $('input[id="dshotEdt"]'); dshotEdtElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_edt).trigger("change"); } @@ -795,8 +797,8 @@ motors.initialize = async function (callback) { $('.escSensor').toggle( protocolConfigured && digitalProtocol && ( - semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46) || - semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && !FC.MOTOR_CONFIG.use_dshot_edt)); + semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46) || + semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47) && !FC.MOTOR_CONFIG.use_dshot_edt)); $('div.checkboxDshotBidir').toggle(protocolConfigured && digitalProtocol); $('div.motorPoles').toggle(protocolConfigured && rpmFeaturesVisible); @@ -805,8 +807,11 @@ motors.initialize = async function (callback) { $('#escProtocolDisabled').toggle(!protocolConfigured); $('.checkboxDshotEdt').toggle( - protocolConfigured && digitalProtocol && dshotBidirElement.is(':checked') && - !$("input[name='ESC_SENSOR']").is(':checked') && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)); + semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47) && + protocolConfigured && + digitalProtocol && + dshotBidirElement.is(':checked') && + !$("input[name='ESC_SENSOR']").is(':checked')); //trigger change unsyncedPWMSwitch to show/hide Motor PWM freq input unsyncedPWMSwitchElement.trigger("change"); @@ -828,9 +833,8 @@ motors.initialize = async function (callback) { //trigger change dshotBidir and ESC_SENSOR to show/hide Motor Poles tab dshotBidirElement.change(updateVisibility).trigger("change"); - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) { const dshotEdtElement = $('input[id="dshotEdt"]'); - dshotEdtElement.change(updateVisibility).trigger("change"); } $("input[name='ESC_SENSOR']").on("change", updateVisibility).trigger("change"); From becdc62513462d48c4b86ca526841bdeab41aecc Mon Sep 17 00:00:00 2001 From: Chris L Date: Thu, 29 Aug 2024 01:49:10 +0200 Subject: [PATCH 4/4] Conditionally ready motor config --- src/js/msp/MSPHelper.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index a19dcefed9..fa59f99aa7 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -493,10 +493,6 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.MOTOR_CONFIG.minthrottle = data.readU16(); // 0-2000 FC.MOTOR_CONFIG.maxthrottle = data.readU16(); // 0-2000 FC.MOTOR_CONFIG.mincommand = data.readU16(); // 0-2000 - FC.MOTOR_CONFIG.motor_count = data.readU8(); - FC.MOTOR_CONFIG.motor_poles = data.readU8(); - FC.MOTOR_CONFIG.use_dshot_telemetry = data.readU8() != 0; - FC.MOTOR_CONFIG.use_esc_sensor = data.readU8() != 0; if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) { FC.MOTOR_CONFIG.motor_count = data.readU8();