From c4d6b7b0df3a67cff3c5577c45158aaa99fdfd31 Mon Sep 17 00:00:00 2001 From: phobos- Date: Tue, 29 Mar 2022 16:49:14 +0200 Subject: [PATCH] MSP VTX device --- locales/en/messages.json | 7 +++++++ src/js/msp/MSPHelper.js | 1 + src/js/tabs/ports.js | 4 ++++ src/js/tabs/vtx.js | 4 ++++ .../utils/VtxDeviceStatus/VtxDeviceStatus.js | 1 + .../VtxDeviceStatus/VtxMspDeviceStatus.js | 19 +++++++++++++++++++ 6 files changed, 36 insertions(+) create mode 100644 src/js/utils/VtxDeviceStatus/VtxMspDeviceStatus.js diff --git a/locales/en/messages.json b/locales/en/messages.json index 11a87bbad0..2d5af5f29f 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1627,6 +1627,9 @@ "portsFunction_FRSKY_OSD": { "message": "OSD (FrSky Protocol)" }, + "portsFunction_VTX_MSP": { + "message": "VTX (MSP)" + }, "pidTuningProfileOption": { "message": "Profile $1" }, @@ -5837,6 +5840,10 @@ "message": "Tramp", "description": "Text for one of the types of the VTX type in VTX tab" }, + "vtxType_5": { + "message": "MSP", + "description": "Text for one of the types of the VTX type in VTX tab" + }, "vtxType_255": { "message": "Unknown", "description": "Text for one of the types of the VTX type in VTX tab" diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 3dfcbb9144..333539bbc1 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -33,6 +33,7 @@ function MspHelper() { 'RUNCAM_DEVICE_CONTROL': 14, // support communitate with RunCam Device 'LIDAR_TF': 15, 'FRSKY_OSD': 16, + 'VTX_MSP': 17, }; self.REBOOT_TYPES = { diff --git a/src/js/tabs/ports.js b/src/js/tabs/ports.js index 79b0ade1c7..9e38f92ad9 100644 --- a/src/js/tabs/ports.js +++ b/src/js/tabs/ports.js @@ -57,6 +57,10 @@ TABS.ports.initialize = function (callback, scrollPosition) { functionRules.push({ name: 'FRSKY_OSD', groups: ['peripherals'], maxPorts: 1 }); } + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { + functionRules.push({ name: 'VTX_MSP', groups: ['peripherals'], maxPorts: 1 }); + } + for (const rule of functionRules) { rule.displayName = i18n.getMessage(`portsFunction_${rule.name}`); } diff --git a/src/js/tabs/vtx.js b/src/js/tabs/vtx.js index 2c27936c2a..82afcf7a1a 100644 --- a/src/js/tabs/vtx.js +++ b/src/js/tabs/vtx.js @@ -574,6 +574,10 @@ TABS.vtx.initialize = function (callback) { powerMinMax = {min: 1, max: 5}; break; + case VtxDeviceTypes.VTXDEV_MSP: + powerMinMax = {min: 1, max: 5}; + break; + case VtxDeviceTypes.VTXDEV_UNKNOWN: default: powerMinMax = {min: 0, max: 7}; diff --git a/src/js/utils/VtxDeviceStatus/VtxDeviceStatus.js b/src/js/utils/VtxDeviceStatus/VtxDeviceStatus.js index 015a29b158..3002cabaa2 100644 --- a/src/js/utils/VtxDeviceStatus/VtxDeviceStatus.js +++ b/src/js/utils/VtxDeviceStatus/VtxDeviceStatus.js @@ -6,6 +6,7 @@ const VtxDeviceTypes = { // 2 reserved VTXDEV_SMARTAUDIO: 3, VTXDEV_TRAMP: 4, + VTXDEV_MSP: 5, VTXDEV_UNKNOWN: 0xFF, }; diff --git a/src/js/utils/VtxDeviceStatus/VtxMspDeviceStatus.js b/src/js/utils/VtxDeviceStatus/VtxMspDeviceStatus.js new file mode 100644 index 0000000000..f999103f0f --- /dev/null +++ b/src/js/utils/VtxDeviceStatus/VtxMspDeviceStatus.js @@ -0,0 +1,19 @@ +'use strict'; + +class VtxDeviceStatusMsp extends VtxDeviceStatus { + constructor(dataView) + { + super(dataView); + + dataView.readU8(); // custom device status size + + // Read other MSP VTX device parameters here + } + + static get staticDeviceStatusType() + { + return VtxDeviceTypes.VTXDEV_MSP; + } +} + +vtxDeviceStatusFactory.registerVtxDeviceStatusClass(VtxDeviceStatusMsp);