1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 08:15:22 +03:00

Merge pull request #488 from mikeller/updates_for_api_1.33_from_cleanflight

Updates for api 1.33 from cleanflight
This commit is contained in:
Michael Keller 2017-05-07 09:54:28 +12:00 committed by GitHub
commit 09713b954b
57 changed files with 7846 additions and 1536 deletions

387
_locales/en/messages.json Executable file → Normal file
View file

@ -73,6 +73,9 @@
"tabSetup": {
"message": "Setup"
},
"tabSetupOSD": {
"message": "OSD Setup"
},
"tabConfiguration": {
"message": "Configuration"
},
@ -100,6 +103,9 @@
"tabOsd": {
"message": "OSD"
},
"tabPower": {
"message": "Power & Battery"
},
"tabGPS": {
"message": "GPS"
},
@ -161,10 +167,13 @@
"message": "No configuration received within <span style=\"color: red\">10 seconds</span>, communication <span style=\"color: red\">failed</span>"
},
"firmwareVersionNotSupported": {
"message": "This firmware version is <span style=\"color: red\">not supported</span>. Please upgrade to firmware that supports api version <strong>$1</strong> or higher. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention."
"message": "This firmware version is <span style=\"color: red\">not supported</span>. Please upgrade to firmware that supports api version <strong>$1</strong> or higher. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention.<br />Alternatively download and use an old version of the configurator if you are not ready to upgrade."
},
"firmwareTypeNotSupported": {
"message": "Non - Betaflight firmware is <span style=\"color: red\">not supported</span>. Please note that this tool is designed to support the advanced features of the Betaflight firmware, and does not support use with other types of firmware, except for in CLI mode."
"message": "Non - Cleanflight/Betaflight firmware is <span style=\"color: red\">not supported</span>, except for CLI mode."
},
"firmwareUpgradeRequired": {
"message": "The firmware on this device needs upgrading to a newer version. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention.<br />Alternatively download and use an old version of the configurator if you are not ready to upgrade."
},
"tabSwitchConnectionRequired": {
@ -556,6 +565,9 @@
"featureOSD": {
"message": "On Screen Display"
},
"featureVTX": {
"message": "Video Transmitter"
},
"featureFAILSAFE": {
"message": "Enable Failsafe Stage 2"
},
@ -667,44 +679,8 @@
"configurationThrottleMinimumCommandHelp": {
"message": "This is the value that is sent to the ESCs when the craft is disarmed. Set this to a value that has the motors stopped (1000 for most ESCs)."
},
"configurationBatteryVoltage": {
"message": "Battery Voltage"
},
"configurationBatteryCurrent": {
"message": "Battery Current"
},
"configurationBatteryMeterType": {
"message": "Battery Meter Type"
},
"configurationBatteryMinimum": {
"message": "Minimum Cell Voltage"
},
"configurationBatteryMaximum": {
"message": "Maximum Cell Voltage"
},
"configurationBatteryWarning": {
"message": "Warning Cell Voltage"
},
"configurationBatteryScale": {
"message": "Voltage Scale"
},
"configurationCurrentMeterType": {
"message": "Current Meter Type"
},
"configurationCurrent": {
"message": "Current Sensor"
},
"configurationCurrentScale": {
"message": "Scale the output voltage to milliamps [1/10th mV/A]"
},
"configurationCurrentOffset": {
"message": "Offset in millivolt steps"
},
"configurationBatteryMultiwiiCurrent": {
"message": "Enable support for legacy Multiwii MSP current output"
},
"configuration3d": {
"message": "3D"
"message": "3D ESC/Motor Features"
},
"configuration3dDeadbandLow": {
"message": "3D Deadband Low"
@ -742,6 +718,12 @@
"configurationGPSubxSbas": {
"message": "Ground Assistance Type"
},
"configurationGPSAutoBaud": {
"message": "Auto Baud"
},
"configurationGPSAutoConfig": {
"message": "Auto Config"
},
"configurationGPSHelp": {
"message": "<strong>Note:</strong> Remember to configure a Serial Port (via Ports tab) when using GPS feature."
},
@ -756,10 +738,10 @@
},
"portsIdentifier": {
"message": "Port Identifier"
"message": "Identifier"
},
"portsConfiguration": {
"message": "Configuration"
"message": "Configuration/MSP"
},
"portsSerialRx": {
"message": "Serial Rx"
@ -812,6 +794,18 @@
"portsFunction_TELEMETRY_SMARTPORT": {
"message": "SmartPort"
},
"portsFunction_TELEMETRY_IBUS": {
"message": "iBUS"
},
"portsFunction_TELEMETRY_JETIXBUS": {
"message": "JETIXBUS"
},
"portsFunction_TELEMETRY_CRSF": {
"message": "CRSF"
},
"portsFunction_TELEMETRY_SRXL": {
"message": "SRXL"
},
"portsFunction_ESC_SENSOR": {
"message": "ESC"
},
@ -827,9 +821,6 @@
"portsFunction_IRC_TRAMP": {
"message": "IRC Tramp"
},
"portsFunction_TELEMETRY_IBUS": {
"message": "iBUS Telemetry"
},
"pidTuningUpgradeFirmwareToChangePidController": {
"message": "<span style=\"color: red\">Changing PID controller disabled - you can change it via the CLI.</span> You have firmware with API version <span style=\"color: red\">$1</span>, but this functionality requires requires <span style=\"color: #ffbb00\">$2</span>."
},
@ -860,9 +851,6 @@
"receiverRcInterpolationIntervalHelp": {
"message": "Interpolation interval for manual RC interpolation mode in milliseconds"
},
"receiverRcInterpolation": {
"message": "RC Interpolation"
},
"receiverRcInterpolationOff": {
"message": "Off"
},
@ -984,11 +972,23 @@
"receiverThrottleExpo": {
"message": "Throttle EXPO"
},
"receiverMidRc": {
"message": "Center value for RC channels"
"receiverStickMin": {
"message": "Stick Min"
},
"receiverMidRcHelp": {
"message": "This is the center value <span style=\"font-weight: bold\">for all RC channels</span>. Set this to the value that your transmitter sends when the stick is centered for a channel. To adjust the thrust at throttle mid position, change the 'Trottle MID' value on the PID Tuning tab."
"receiverHelpStickMin": {
"message": "The value (in us) used to determine if a stick is low."
},
"receiverStickCenter": {
"message": "Stick Center"
},
"receiverHelpStickCenter": {
"message": "The value (in us) used to determine if a stick is centered."
},
"receiverStickMax": {
"message": "Stick Max"
},
"receiverHelpStickMax": {
"message": "The value (in us) used to determine if a stick is high."
},
"receiverDeadband": {
"message": "RC Deadband"
@ -996,12 +996,18 @@
"receiverHelpDeadband": {
"message": "These are values (in us) by how much RC input can be different before it's considered valid. For transmitters with jitter on outputs, this value can be increased if rc inputs twitch while idle."
},
"receiverHelpYawDeadband": {
"message": "These are values (in us) by how much RC input can be different before it's considered valid. For transmitters with jitter on outputs, this value can be increased if rc inputs twitch while idle. <strong>This setting is for Yaw only.</strong>"
},
"receiverYawDeadband": {
"message": "Yaw Deadband"
},
"receiverHelpYawDeadband": {
"message": "These are values (in us) by how much RC input can be different before it's considered valid. For transmitters with jitter on outputs, this value can be increased if rc inputs twitch while idle. <strong>This setting is for Yaw only.</strong>"
},
"recevier3dDeadbandThrottle": {
"message": "3D Throttle Deadband"
},
"receiverHelp3dDeadbandThrottle": {
"message": "These are values (in us). To widen the neutral zone increased the value. <strong>This setting is for 3D throttle only.</strong>"
},
"receiverChannelMap": {
"message": "Channel Map"
},
@ -1185,24 +1191,48 @@
"transponderNotSupported": {
"message": "Your flight controller's firmware does not support transponder functionality."
},
"transponderHelp": {
"message": "Configure your transponder code here. Note: Only valid codes will be recognised by race timing systems. Valid transponder codes can be obtained from <a href=\"http://seriouslypro.com/transponder-codes\" target=\"_blank\">Seriously Pro</a>."
},
"transponderInformation": {
"message": "Transponders systems allow race organizers to time your laps. The transponder is fitted to your aircraft and when your aircraft passes the timing gate the track-side receiver registers your code and records your laptime. When fitting an IR based transponder your should ensure that it points outward from your aircraft towards the track-side receivers and that the light beam is not obstructed by your airframe, battery-straps, cables, propellers, etc."
},
"transponderConfiguration": {
"message": "Configuration"
"transponderConfigurationType": {
"message": "Transponder type"
},
"transponderData": {
"transponderType0": {
"message": "None"
},
"transponderType1": {
"message": "iLap"
},
"transponderType2": {
"message": "aRCiTimer"
},
"transponderConfiguration1": {
"message": "Configuration iLap"
},
"transponderConfiguration2": {
"message": "Configuration aRCiTimer"
},
"transponderData1": {
"message": "Data"
},
"transponderDataHelp": {
"transponderData2": {
"message": "Transponder ID"
},
"transponderDataHelp1": {
"message": "Hexadecimal digits only, 0-9, A-F"
},
"transponderHelp1": {
"message": "Configure your transponder code here. Note: Only valid codes will be recognised by race timing systems. Valid transponder codes can be obtained from <a href=\"http://seriouslypro.com/transponder-codes\" target=\"_blank\">Seriously Pro</a>."
},
"transponderHelp2": {
"message": "For more information please visit <a href=\"http://www.arcitimer.com/\" title=\"aRCiTimer\" target=\"_blank\">aRCiTimer site</a>"
},
"transponderButtonSave": {
"message": "Save"
},
"transponderButtonSaveReboot": {
"message": "Save and Reboot"
},
"transponderDataInvalid": {
"message": "Transponder data is <span style=\"color: red\">invalid</span>"
},
@ -1258,6 +1288,12 @@
"motorsGyroscopeReset": {
"message": "[Reset]"
},
"motorsGyroscope": {
"message": "Gyroscope - "
},
"motorsGyroscopeReset": {
"message": "[Reset]"
},
"gpsHead": {
"message": "GPS"
},
@ -1861,6 +1897,226 @@
"failsafeKillSwitchHelp": {
"message": "Set this option to make the failsafe switch, configured in the modes tab, act as a direct kill switch, bypassing the selected failsafe procedure. <strong>Note:</strong> Arming is blocked with the failsafe kill switch in the ON position"
},
"powerButtonSave": {
"message": "Save"
},
"powerFirmwareUpgradeRequired": {
"message": "Firmware upgrade <span style=\"color: red\">required</span>. Battery/Amperage/Voltage configurations using API &lt; 1.22.0 is not supported."
},
"powerBatteryVoltageMeterSource": {
"message": "Voltage Meter Source"
},
"powerBatteryCurrentMeterSource": {
"message": "Current Meter Source"
},
"powerBatteryMinimum": {
"message": "Minimum Cell Voltage"
},
"powerBatteryMaximum": {
"message": "Maximum Cell Voltage"
},
"powerBatteryWarning": {
"message": "Warning Cell Voltage"
},
"powerVoltageHead": {
"message": "Voltage"
},
"powerVoltageValue": {
"message": "$1 V"
},
"powerAmperageValue": {
"message": "$1 A"
},
"powerVoltageId10": {
"message": "Battery"
},
"powerVoltageId20": {
"message": "5V"
},
"powerVoltageId30": {
"message": "9V"
},
"powerVoltageId40": {
"message": "12V"
},
"powerVoltageId50": {
"message": "ESC Combined"
},
"powerVoltageId60": {
"message": "ESC Motor 1"
},
"powerVoltageId61": {
"message": "ESC Motor 2"
},
"powerVoltageId62": {
"message": "ESC Motor 3"
},
"powerVoltageId63": {
"message": "ESC Motor 4"
},
"powerVoltageId64": {
"message": "ESC Motor 5"
},
"powerVoltageId65": {
"message": "ESC Motor 6"
},
"powerVoltageId66": {
"message": "ESC Motor 7"
},
"powerVoltageId67": {
"message": "ESC Motor 8"
},
"powerVoltageId68": {
"message": "ESC Motor 9"
},
"powerVoltageId69": {
"message": "ESC Motor 10"
},
"powerVoltageId70": {
"message": "ESC Motor 11"
},
"powerVoltageId71": {
"message": "ESC Motor 12"
},
"powerVoltageId80": {
"message": "Cell 1"
},
"powerVoltageId81": {
"message": "Cell 2"
},
"powerVoltageId82": {
"message": "Cell 3"
},
"powerVoltageId83": {
"message": "Cell 4"
},
"powerVoltageId84": {
"message": "Cell 5"
},
"powerVoltageId85": {
"message": "Cell 6"
},
"powerVoltageScale": {
"message": "Scale"
},
"powerVoltageDivider": {
"message": "Divider Value"
},
"powerVoltageMultiplier": {
"message": "Multiplier Value"
},
"powerAmperageHead": {
"message": "Amperage"
},
"powerAmperageId10": {
"message": "Battery"
},
"powerAmperageId50": {
"message": "ESC Combined"
},
"powerAmperageId60": {
"message": "ESC Motor 1"
},
"powerAmperageId61": {
"message": "ESC Motor 2"
},
"powerAmperageId62": {
"message": "ESC Motor 3"
},
"powerAmperageId63": {
"message": "ESC Motor 4"
},
"powerAmperageId64": {
"message": "ESC Motor 5"
},
"powerAmperageId65": {
"message": "ESC Motor 6"
},
"powerAmperageId66": {
"message": "ESC Motor 7"
},
"powerAmperageId67": {
"message": "ESC Motor 8"
},
"powerAmperageId68": {
"message": "ESC Motor 9"
},
"powerAmperageId69": {
"message": "ESC Motor 10"
},
"powerAmperageId70": {
"message": "ESC Motor 11"
},
"powerAmperageId71": {
"message": "ESC Motor 12"
},
"powerAmperageId80": {
"message": "Virtual"
},
"powerMahValue": {
"message": "$1 mAh"
},
"powerAmperageScale": {
"message": "Scale the output voltage to milliamps [1/10th mV/A]"
},
"powerAmperageOffset": {
"message": "Offset in millivolt steps"
},
"powerBatteryHead": {
"message": "Battery"
},
"powerBatteryConnected": {
"message": "Connected"
},
"powerBatteryConnectedValueYes": {
"message": "Yes (Cells: $1)"
},
"powerBatteryConnectedValueNo": {
"message": "No"
},
"powerBatteryVoltage": {
"message": "Voltage"
},
"powerBatteryCurrentDrawn": {
"message": "mAh used"
},
"powerBatteryAmperage": {
"message": "Amperage"
},
"powerBatteryCapacity": {
"message": "Capacity (mAh)"
},
"osdSetupHead": {
"message": "Info"
},
"osdSetupVideoMode": {
"message": "Video Mode"
},
"osdSetupCameraConnected": {
"message": "Camera Connected"
},
"osdSetupCameraConnectedValueYes": {
"message": "Yes"
},
"osdSetupCameraConnectedValueNo": {
"message": "No"
},
"osdSetupResetText": {
"message": "Reset OSD to default"
},
"osdSetupButtonReset": {
"message": "Reset Settings"
},
"mainHelpArmed": {
"message": "Motor Arming"
},
@ -1942,10 +2198,13 @@
"pidTuningRatesTip": {
"message": "Play with the rates and see how those affect the stick curve"
},
"configurationMisc": {
"message": "Misc"
"configurationCamera": {
"message": "Camera"
},
"configurationVesselName": {
"configurationPersonalization": {
"message": "Personalization"
},
"craftName": {
"message": "Craft name"
},
"configurationFpvCamAngleDegrees": {

2337
css/font-awesome/css/font-awesome.css vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load diff

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -19,7 +19,7 @@ function startApplication() {
// save connectionId in separate variable before createdWindow.contentWindow is destroyed
var connectionId = createdWindow.contentWindow.serial.connectionId,
valid_connection = createdWindow.contentWindow.CONFIGURATOR.connectionValid,
mincommand = createdWindow.contentWindow.MISC.mincommand;
mincommand = createdWindow.contentWindow.MOTOR_CONFIG.mincommand;
if (connectionId && valid_connection) {
// code below is handmade MSP message (without pretty JS wrapper), it behaves exactly like MSP.send_message

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-99 43 85 56.7" style="enable-background:new -99 43 85 56.7;" xml:space="preserve">
<style type="text/css">
.st0{fill:#838281;}
</style>
<g>
<path class="st0" d="M-21.5,60h-2.6v-7c0-1.8-1.5-3.3-3.3-3.3h-63.6c-1.8,0-3.3,1.5-3.3,3.3v37.9c0,1.8,1.5,3.3,3.3,3.3h63.6
c1.8,0,3.3-1.5,3.3-3.3v-6.7h2.6c1.8,0,3.3-1.5,3.3-3.3V63.3C-18.2,61.4-19.7,60-21.5,60L-21.5,60z M-30.6,87.6h-57V56.3h57V87.6z
M-30.6,87.6"/>
<path class="st0" d="M-61.4,61.9L-61.4,61.9l-17.1,15.6l15.8-6.7l5.9,11.2l17.1-15.6L-55.5,73L-61.4,61.9z M-61.4,61.9"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 828 B

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-99 43 85 56.7" style="enable-background:new -99 43 85 56.7;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<g>
<path class="st0" d="M-21.5,60h-2.6v-7c0-1.8-1.5-3.3-3.3-3.3h-63.6c-1.8,0-3.3,1.5-3.3,3.3v37.9c0,1.8,1.5,3.3,3.3,3.3h63.6
c1.8,0,3.3-1.5,3.3-3.3v-6.7h2.6c1.8,0,3.3-1.5,3.3-3.3V63.3C-18.2,61.4-19.7,60-21.5,60L-21.5,60z M-30.6,87.6h-57V56.3h57V87.6z
M-30.6,87.6"/>
<path class="st0" d="M-61.4,61.9L-61.4,61.9l-17.1,15.6l15.8-6.7l5.9,11.2l17.1-15.6L-55.5,73L-61.4,61.9z M-61.4,61.9"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 828 B

View file

@ -35,7 +35,7 @@ var Features = function (config) {
);
}
if (semver.gte(config.apiVersion, "1.15.0")) {
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
features.push(
{bit: 8, group: 'rxFailsafe', name: 'FAILSAFE', haveTip: true}
);
@ -45,21 +45,21 @@ var Features = function (config) {
);
}
if (semver.gte(config.apiVersion, "1.16.0")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
features.push(
{bit: 21, group: 'other', name: 'TRANSPONDER', haveTip: true}
);
}
if (config.flightControllerVersion !== '') {
if (semver.gte(config.flightControllerVersion, "2.8.0")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
features.push(
{bit: 22, group: 'other', name: 'AIRMODE'}
);
}
if (semver.gte(config.flightControllerVersion, "2.8.0")) {
if (!semver.gte(config.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
features.push(
{bit: 23, group: 'pidTuning', name: 'SUPEREXPO_RATES'}
);
@ -70,13 +70,14 @@ var Features = function (config) {
}
}
if (semver.gte(config.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
features.push(
{bit: 18, group: 'other', name: 'OSD'}
{bit: 18, group: 'other', name: 'OSD'},
{bit: 24, group: 'other', name: 'VTX'}
);
}
if (semver.gte(config.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
features.push(
{bit: 27, group: 'other', name: 'ESC_SENSOR'}
)

View file

@ -92,7 +92,7 @@ RateCurve.prototype.rcCommandRawToDegreesPerSecond = function (rcData, rate, rcR
var expoPower;
var rcRateConstant;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
expoPower = 3;
rcRateConstant = 200;
} else {

View file

@ -22,9 +22,7 @@ function configuration_backup(callback) {
];
function update_profile_specific_data_list() {
if (semver.lt(CONFIG.apiVersion, "1.12.0")) {
profileSpecificData.push(MSPCodes.MSP_CHANNEL_FORWARDING);
} else {
if (semver.gt(CONFIG.apiVersion, "1.12.0")) {
profileSpecificData.push(MSPCodes.MSP_SERVO_MIX_RULES);
}
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
@ -71,7 +69,7 @@ function configuration_backup(callback) {
});
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
configuration.profiles[fetchingProfile].RCdeadband = jQuery.extend(true, {}, RC_deadband);
configuration.profiles[fetchingProfile].RCdeadband = jQuery.extend(true, {}, RC_DEADBAND_CONFIG);
}
codeKey = 0;
fetchingProfile++;
@ -89,9 +87,7 @@ function configuration_backup(callback) {
}
var uniqueData = [
MSPCodes.MSP_MISC,
MSPCodes.MSP_RX_MAP,
MSPCodes.MSP_BF_CONFIG,
MSPCodes.MSP_CF_SERIAL_CONFIG,
MSPCodes.MSP_LED_STRIP_CONFIG,
MSPCodes.MSP_LED_COLORS
@ -103,7 +99,7 @@ function configuration_backup(callback) {
uniqueData.push(MSPCodes.MSP_ARMING_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSPCodes.MSP_3D);
uniqueData.push(MSPCodes.MSP_MOTOR_3D_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSPCodes.MSP_SENSOR_ALIGNMENT);
@ -128,9 +124,7 @@ function configuration_backup(callback) {
fetch_unique_data_item();
});
} else {
configuration.MISC = jQuery.extend(true, {}, MISC);
configuration.RCMAP = jQuery.extend(true, [], RC_MAP);
configuration.BF_CONFIG = jQuery.extend(true, {}, BF_CONFIG);
configuration.SERIAL_CONFIG = jQuery.extend(true, {}, SERIAL_CONFIG);
configuration.LED_STRIP = jQuery.extend(true, [], LED_STRIP);
configuration.LED_COLORS = jQuery.extend(true, [], LED_COLORS);
@ -143,7 +137,7 @@ function configuration_backup(callback) {
configuration.ARMING_CONFIG = jQuery.extend(true, {}, ARMING_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
configuration._3D = jQuery.extend(true, {}, _3D);
configuration.MOTOR_3D_CONFIG = jQuery.extend(true, {}, MOTOR_3D_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
configuration.SENSOR_ALIGNMENT = jQuery.extend(true, {}, SENSOR_ALIGNMENT);
@ -151,6 +145,10 @@ function configuration_backup(callback) {
configuration.FAILSAFE_CONFIG = jQuery.extend(true, {}, FAILSAFE_CONFIG);
configuration.RXFAIL_CONFIG = jQuery.extend(true, [], RXFAIL_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
configuration.RSSI_CONFIG = jQuery.extend(true, {}, RSSI_CONFIG);
configuration.FEATURE_CONFIG = jQuery.extend(true, {}, FEATURE_CONFIG);
}
save();
}
@ -163,13 +161,17 @@ function configuration_backup(callback) {
function save() {
var chosenFileEntry = null;
var prefix = 'betaflight_backup';
var prefix = 'backup';
var suffix = 'json';
var filename = generateFilename(prefix, suffix);
var accepts = [{
extensions: [suffix]
}];
// create or load the file
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: filename, accepts: [{ extensions: [suffix] }]}, function (fileEntry) {
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: filename, accepts: accepts}, function (fileEntry) {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
return;
@ -328,7 +330,7 @@ function configuration_restore(callback) {
if (!compareVersions(migratedVersion, '0.59.1')) {
// variable was renamed
configuration.MISC.rssi_channel = configuration.MISC.rssi_aux_channel;
configuration.RSSI_CONFIG.channel = configuration.MISC.rssi_aux_channel;
configuration.MISC.rssi_aux_channel = undefined;
migratedVersion = '0.59.1';
@ -527,11 +529,11 @@ function configuration_restore(callback) {
if (compareVersions(migratedVersion, '0.66.0') && !compareVersions(configuration.apiVersion, '1.14.0')) {
// api 1.14 exposes 3D configuration
if (configuration._3D == undefined) {
configuration._3D = {
if (configuration.MOTOR_3D_CONFIG == undefined) {
configuration.MOTOR_3D_CONFIG = {
deadband3d_low: 1406,
deadband3d_high: 1514,
neutral3d: 1460,
neutral: 1460,
deadband3d_throttle: 50
};
}
@ -566,9 +568,9 @@ function configuration_restore(callback) {
configuration.RX_CONFIG = {
serialrx_provider: 0,
spektrum_sat_bind: 0,
midrc: 1500,
mincheck: 1100,
maxcheck: 1900,
stick_center: 1500,
stick_min: 1100,
stick_max: 1900,
rx_min_usec: 885,
rx_max_usec: 2115
};
@ -607,8 +609,8 @@ function configuration_restore(callback) {
if (compareVersions(migratedVersion, '1.2.0')) {
// old version of the configurator incorrectly had a 'disabled' option for GPS SBAS mode.
if (MISC.gps_ubx_sbas < 0) {
MISC.gps_ubx_sbas = 0;
if (GPS_CONFIG.ublox_sbas < 0) {
GPS_CONFIG.ublox_sbas = 0;
}
migratedVersion = '1.2.0';
@ -681,7 +683,7 @@ function configuration_restore(callback) {
SERVO_RULES = configuration.profiles[profile].ServoRules;
MODE_RANGES = configuration.profiles[profile].ModeRanges;
ADJUSTMENT_RANGES = configuration.profiles[profile].AdjustmentRanges;
RC_deadband = configuration.profiles[profile].RCdeadband;
RC_DEADBAND_CONFIG = configuration.profiles[profile].RCdeadband;
}
function upload_using_specific_commands() {
@ -729,9 +731,7 @@ function configuration_restore(callback) {
var codeKey = 0;
var uniqueData = [
MSPCodes.MSP_SET_MISC,
MSPCodes.MSP_SET_RX_MAP,
MSPCodes.MSP_SET_BF_CONFIG,
MSPCodes.MSP_SET_CF_SERIAL_CONFIG
];
@ -741,30 +741,41 @@ function configuration_restore(callback) {
uniqueData.push(MSPCodes.MSP_SET_ARMING_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSPCodes.MSP_SET_3D);
uniqueData.push(MSPCodes.MSP_SET_MOTOR_3D_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSPCodes.MSP_SET_SENSOR_ALIGNMENT);
uniqueData.push(MSPCodes.MSP_SET_RX_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_FAILSAFE_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
uniqueData.push(MSPCodes.MSP_SET_FEATURE_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_MOTOR_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_GPS_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_COMPASS_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_RSSI_CONFIG);
}
}
function load_objects() {
MISC = configuration.MISC;
RC_MAP = configuration.RCMAP;
BF_CONFIG = configuration.BF_CONFIG;
SERIAL_CONFIG = configuration.SERIAL_CONFIG;
LED_STRIP = configuration.LED_STRIP;
LED_COLORS = configuration.LED_COLORS;
LED_MODE_COLORS = configuration.LED_MODE_COLORS;
ARMING_CONFIG = configuration.ARMING_CONFIG;
FC_CONFIG = configuration.FC_CONFIG;
_3D = configuration._3D;
MOTOR_3D_CONFIG = configuration.MOTOR_3D_CONFIG;
SENSOR_ALIGNMENT = configuration.SENSOR_ALIGNMENT;
RX_CONFIG = configuration.RX_CONFIG;
FAILSAFE_CONFIG = configuration.FAILSAFE_CONFIG;
RXFAIL_CONFIG = configuration.RXFAIL_CONFIG;
FEATURE_CONFIG = configuration.FEATURE_CONFIG;
MOTOR_CONFIG = configuration.MOTOR_CONFIG;
GPS_CONFIG = configuration.GPS_CONFIG;
COMPASS_CONFIG = configuration.COMPASS_CONFIG;
RSSI_CONFIG = configuration.RSSI_CONFIG;
}
function send_unique_data_item() {

418
js/fc.js
View file

@ -2,7 +2,9 @@
// define all the global variables that are uses to hold FC state
var CONFIG;
var BF_CONFIG;
var FEATURE_CONFIG;
var MIXER_CONFIG;
var BOARD_ALIGNMENT_CONFIG;
var LED_STRIP;
var LED_COLORS;
var LED_MODE_COLORS;
@ -24,15 +26,25 @@ var MOTOR_DATA;
var SERVO_DATA;
var GPS_DATA;
var ANALOG;
var VOLTAGE_METERS;
var VOLTAGE_METER_CONFIGS;
var CURRENT_METERS;
var CURRENT_METER_CONFIGS;
var BATTERY_STATE;
var BATTERY_CONFIG;
var ARMING_CONFIG;
var FC_CONFIG;
var MISC;
var _3D;
var MISC; // DEPRECATED
var MOTOR_CONFIG;
var GPS_CONFIG;
var COMPASS_CONFIG;
var RSSI_CONFIG;
var MOTOR_3D_CONFIG;
var DATAFLASH;
var SDCARD;
var BLACKBOX;
var TRANSPONDER;
var RC_deadband;
var RC_DEADBAND_CONFIG;
var SENSOR_ALIGNMENT;
var RX_CONFIG;
var FAILSAFE_CONFIG;
@ -45,47 +57,50 @@ var SENSOR_CONFIG;
var FC = {
resetState: function() {
CONFIG = {
apiVersion: "0.0.0",
apiVersion: "0.0.0",
flightControllerIdentifier: '',
flightControllerVersion: '',
version: 0,
buildInfo: '',
multiType: 0,
msp_version: 0, // not specified using semantic versioning
capability: 0,
cycleTime: 0,
i2cError: 0,
activeSensors: 0,
mode: 0,
profile: 0,
uid: [0, 0, 0],
accelerometerTrims: [0, 0],
name: '',
numProfiles: 3,
rateProfile: 0
flightControllerVersion: '',
version: 0,
buildInfo: '',
multiType: 0,
msp_version: 0, // not specified using semantic versioning
capability: 0,
cycleTime: 0,
i2cError: 0,
activeSensors: 0,
mode: 0,
profile: 0,
uid: [0, 0, 0],
accelerometerTrims: [0, 0],
name: '',
numProfiles: 3,
rateProfile: 0,
boardType: 0,
};
BF_CONFIG = {
mixerConfiguration: 0,
features: new Features(CONFIG),
board_align_roll: 0,
board_align_pitch: 0,
board_align_yaw: 0,
currentscale: 0,
currentoffset: 0,
currentmetertype: 0,
batterycapacity: 0,
FEATURE_CONFIG = {
features: 0,
};
MIXER_CONFIG = {
mixer: 0,
};
LED_STRIP = [];
LED_COLORS = [];
LED_MODE_COLORS = [];
BOARD_ALIGNMENT_CONFIG = {
roll: 0,
pitch: 0,
yaw: 0,
};
LED_STRIP = [];
LED_COLORS = [];
LED_MODE_COLORS = [];
PID = {
controller: 0
controller: 0
};
PID_names = [];
PID_names = [];
PIDs = new Array(10);
for (var i = 0; i < 10; i++) {
PIDs[i] = new Array(3);
@ -96,219 +111,248 @@ var FC = {
// defaults
// roll, pitch, yaw, throttle, aux 1, ... aux n
RC = {
active_channels: 0,
channels: new Array(32)
active_channels: 0,
channels: new Array(32),
};
RC_tuning = {
RC_RATE: 0,
RC_EXPO: 0,
roll_pitch_rate: 0, // pre 1.7 api only
roll_rate: 0,
pitch_rate: 0,
yaw_rate: 0,
dynamic_THR_PID: 0,
throttle_MID: 0,
throttle_EXPO: 0,
dynamic_THR_breakpoint: 0,
RC_YAW_EXPO: 0,
rcYawRate: 0
RC_RATE: 0,
RC_EXPO: 0,
roll_pitch_rate: 0, // pre 1.7 api only
roll_rate: 0,
pitch_rate: 0,
yaw_rate: 0,
dynamic_THR_PID: 0,
throttle_MID: 0,
throttle_EXPO: 0,
dynamic_THR_breakpoint: 0,
RC_YAW_EXPO: 0,
rcYawRate: 0,
};
AUX_CONFIG = [];
AUX_CONFIG_IDS = [];
AUX_CONFIG = [];
AUX_CONFIG_IDS = [];
MODE_RANGES = [];
ADJUSTMENT_RANGES = [];
MODE_RANGES = [];
ADJUSTMENT_RANGES = [];
SERVO_CONFIG = [];
SERVO_RULES = [];
SERVO_CONFIG = [];
SERVO_RULES = [];
SERIAL_CONFIG = {
ports: [],
ports: [],
// pre 1.6 settings
mspBaudRate: 0,
gpsBaudRate: 0,
gpsPassthroughBaudRate: 0,
cliBaudRate: 0,
mspBaudRate: 0,
gpsBaudRate: 0,
gpsPassthroughBaudRate: 0,
cliBaudRate: 0,
};
SENSOR_DATA = {
gyroscope: [0, 0, 0],
accelerometer: [0, 0, 0],
magnetometer: [0, 0, 0],
altitude: 0,
sonar: 0,
kinematics: [0.0, 0.0, 0.0],
debug: [0, 0, 0, 0]
gyroscope: [0, 0, 0],
accelerometer: [0, 0, 0],
magnetometer: [0, 0, 0],
altitude: 0,
sonar: 0,
kinematics: [0.0, 0.0, 0.0],
debug: [0, 0, 0, 0],
};
MOTOR_DATA = new Array(8);
SERVO_DATA = new Array(8);
MOTOR_DATA = new Array(8);
SERVO_DATA = new Array(8);
GPS_DATA = {
fix: 0,
numSat: 0,
lat: 0,
lon: 0,
alt: 0,
speed: 0,
ground_course: 0,
distanceToHome: 0,
ditectionToHome: 0,
update: 0,
fix: 0,
numSat: 0,
lat: 0,
lon: 0,
alt: 0,
speed: 0,
ground_course: 0,
distanceToHome: 0,
ditectionToHome: 0,
update: 0,
// baseflight specific gps stuff
chn: [],
svid: [],
quality: [],
cno: []
chn: [],
svid: [],
quality: [],
cno: []
};
ANALOG = {
voltage: 0,
mAhdrawn: 0,
rssi: 0,
amperage: 0,
last_received_timestamp: Date.now()
voltage: 0,
mAhdrawn: 0,
rssi: 0,
amperage: 0,
last_received_timestamp: Date.now() // FIXME this code lies, it's never been received at this point
};
VOLTAGE_METERS = [];
VOLTAGE_METER_CONFIGS = [];
CURRENT_METERS = [];
CURRENT_METER_CONFIGS = [];
BATTERY_STATE = {};
BATTERY_CONFIG = {
vbatmincellvoltage: 0,
vbatmaxcellvoltage: 0,
vbatwarningcellvoltage: 0,
capacity: 0,
voltageMeterSource: 0,
currentMeterSource: 0,
};
ARMING_CONFIG = {
auto_disarm_delay: 0,
disarm_kill_switch: 0
auto_disarm_delay: 0,
disarm_kill_switch: 0,
};
FC_CONFIG = {
loopTime: 0
loopTime: 0
};
MISC = {
minthrottle: 0,
maxthrottle: 0,
mincommand: 0,
failsafe_throttle: 0,
gps_type: 0,
gps_baudrate: 0,
gps_ubx_sbas: 0,
multiwiicurrentoutput: 0,
rssi_channel: 0,
placeholder2: 0,
mag_declination: 0, // not checked
vbatscale: 0,
vbatmincellvoltage: 0,
vbatmaxcellvoltage: 0,
vbatwarningcellvoltage: 0,
batterymetertype: 1, // 1=ADC, 2=ESC
// DEPRECATED = only used to store values that are written back to the fc as-is, do NOT use for any other purpose
failsafe_throttle: 0,
gps_baudrate: 0,
multiwiicurrentoutput: 0,
placeholder2: 0,
vbatscale: 0,
vbatmincellvoltage: 0,
vbatmaxcellvoltage: 0,
vbatwarningcellvoltage: 0,
};
MOTOR_CONFIG = {
minthrottle: 0,
maxthrottle: 0,
mincommand: 0,
};
GPS_CONFIG = {
provider: 0,
ublox_sbas: 0,
auto_config: 0,
auto_baud: 0,
};
COMPASS_CONFIG = {
mag_declination: 0,
};
_3D = {
deadband3d_low: 0,
deadband3d_high: 0,
neutral3d: 0,
deadband3d_throttle: 0
RSSI_CONFIG = {
channel: 0,
};
MOTOR_3D_CONFIG = {
deadband3d_low: 0,
deadband3d_high: 0,
neutral: 0,
};
DATAFLASH = {
ready: false,
supported: false,
sectors: 0,
totalSize: 0,
usedSize: 0
ready: false,
supported: false,
sectors: 0,
totalSize: 0,
usedSize: 0
};
SDCARD = {
supported: false,
state: 0,
filesystemLastError: 0,
freeSizeKB: 0,
totalSizeKB: 0,
supported: false,
state: 0,
filesystemLastError: 0,
freeSizeKB: 0,
totalSizeKB: 0,
};
BLACKBOX = {
supported: false,
blackboxDevice: 0,
blackboxRateNum: 1,
blackboxRateDenom: 1
supported: false,
blackboxDevice: 0,
blackboxRateNum: 1,
blackboxRateDenom: 1,
};
TRANSPONDER = {
supported: false,
data: []
supported: false,
data: [],
provider: 0,
providers: [],
};
RC_deadband = {
deadband: 0,
yaw_deadband: 0,
alt_hold_deadband: 0
RC_DEADBAND_CONFIG = {
deadband: 0,
yaw_deadband: 0,
alt_hold_deadband: 0,
deadband3d_throttle: 0,
};
SENSOR_ALIGNMENT = {
align_gyro: 0,
align_acc: 0,
align_mag: 0
align_gyro: 0,
align_acc: 0,
align_mag: 0,
};
PID_ADVANCED_CONFIG = {
gyro_sync_denom: 0,
pid_process_denom: 0,
use_unsyncedPwm: 0,
fast_pwm_protocol: 0,
motor_pwm_rate: 0,
digitalIdlePercent: 0,
gyroUse32kHz: 0
gyro_sync_denom: 0,
pid_process_denom: 0,
use_unsyncedPwm: 0,
fast_pwm_protocol: 0,
motor_pwm_rate: 0,
digitalIdlePercent: 0,
gyroUse32kHz: 0,
};
FILTER_CONFIG = {
gyro_soft_lpf_hz: 0,
dterm_lpf_hz: 0,
yaw_lpf_hz: 0,
gyro_soft_notch_hz_1: 0,
gyro_soft_notch_cutoff_1: 0,
dterm_notch_hz: 0,
dterm_notch_cutoff: 0,
gyro_soft_notch_hz_2: 0,
gyro_soft_notch_cutoff_2: 0
gyro_soft_lpf_hz: 0,
dterm_lpf_hz: 0,
yaw_lpf_hz: 0,
gyro_soft_notch_hz_1: 0,
gyro_soft_notch_cutoff_1: 0,
dterm_notch_hz: 0,
dterm_notch_cutoff: 0,
gyro_soft_notch_hz_2: 0,
gyro_soft_notch_cutoff_2: 0,
};
ADVANCED_TUNING = {
rollPitchItermIgnoreRate: 0,
yawItermIgnoreRate: 0,
yaw_p_limit: 0,
deltaMethod: 0,
vbatPidCompensation: 0,
ptermSetpointWeight: 0,
dtermSetpointWeight: 0,
toleranceBand: 0,
toleranceBandReduction: 0,
itermThrottleGain: 0,
pidMaxVelocity: 0,
pidMaxVelocityYaw: 0,
levelAngleLimit: 0,
levelSensitivity: 0
rollPitchItermIgnoreRate: 0,
yawItermIgnoreRate: 0,
yaw_p_limit: 0,
deltaMethod: 0,
vbatPidCompensation: 0,
ptermSetpointWeight: 0,
dtermSetpointWeight: 0,
toleranceBand: 0,
toleranceBandReduction: 0,
itermThrottleGain: 0,
pidMaxVelocity: 0,
pidMaxVelocityYaw: 0,
levelAngleLimit: 0,
levelSensitivity: 0,
};
SENSOR_CONFIG = {
acc_hardware: 0,
baro_hardware: 0,
mag_hardware: 0
acc_hardware: 0,
baro_hardware: 0,
mag_hardware: 0,
};
RX_CONFIG = {
serialrx_provider: 0,
maxcheck: 0,
midrc: 0,
mincheck: 0,
spektrum_sat_bind: 0,
rx_min_usec: 0,
rx_max_usec: 0,
rcInterpolation: 0,
rcInterpolationInterval:0,
airModeActivateThreshold: 0,
rxSpiProtocol: 0,
rxSpiId: 0,
rxSpiRfChannelCount: 0,
fpvCamAngleDegrees: 0
serialrx_provider: 0,
stick_max: 0,
stick_center: 0,
stick_min: 0,
spektrum_sat_bind: 0,
rx_min_usec: 0,
rx_max_usec: 0,
rcInterpolation: 0,
rcInterpolationInterval: 0,
airModeActivateThreshold: 0,
rxSpiProtocol: 0,
rxSpiId: 0,
rxSpiRfChannelCount: 0,
fpvCamAngleDegrees: 0,
};
FAILSAFE_CONFIG = {
@ -317,7 +361,7 @@ var FC = {
failsafe_throttle: 0,
failsafe_kill_switch: 0,
failsafe_throttle_low_delay: 0,
failsafe_procedure: 0
failsafe_procedure: 0.
};
RXFAIL_CONFIG = [];

View file

@ -1,3 +1,4 @@
'use strict';
var TABS = {}; // filled by individual tab js file
@ -12,15 +13,18 @@ var GUI_control = function () {
this.operating_system;
this.interval_array = [];
this.timeout_array = [];
this.defaultAllowedTabsWhenDisconnected = [
'landing',
'firmware_flasher',
'help'
];
this.defaultAllowedTabsWhenConnected = [
this.defaultAllowedFCTabsWhenConnected = [
'setup',
'failsafe',
'transponder',
'osd',
'power',
'adjustments',
'auxiliary',
'cli',
@ -36,7 +40,13 @@ var GUI_control = function () {
'receiver',
'sensors',
'servos',
'setup'
];
this.defaultAllowedOSDTabsWhenConnected = [
'setup_osd',
'osd',
'power',
'sensors',
'transponder',
];
this.allowedTabs = this.defaultAllowedTabsWhenDisconnected;

View file

@ -47,7 +47,7 @@ var Model = function (wrapper, canvas) {
this.renderer.setSize(this.wrapper.width() * 2, this.wrapper.height() * 2);
// load the model including materials
var model_file = useWebGLRenderer ? mixerList[BF_CONFIG.mixerConfiguration - 1].model : 'fallback';
var model_file = useWebGLRenderer ? mixerList[MIXER_CONFIG.mixer - 1].model : 'fallback';
// Temporary workaround for 'custom' model until akfreak's custom model is merged.
if (model_file == 'custom') { model_file = 'fallback'; }

View file

@ -148,6 +148,9 @@ var MSP = {
this.listeners = [];
},
send_message: function (code, data, callback_sent, callback_msp, callback_onerror) {
if (code === undefined) {
debugger;
}
var bufferOut,
bufView;

View file

@ -11,21 +11,26 @@ var MSPCodes = {
MSP_NAME: 10,
MSP_SET_NAME: 11,
MSP_CHANNEL_FORWARDING: 32,
MSP_SET_CHANNEL_FORWARDING: 33,
MSP_BATTERY_CONFIG: 32,
MSP_SET_BATTERY_CONFIG: 33,
MSP_MODE_RANGES: 34,
MSP_SET_MODE_RANGE: 35,
MSP_FEATURE_CONFIG: 36,
MSP_SET_FEATURE_CONFIG: 37,
MSP_BOARD_ALIGNMENT_CONFIG: 38,
MSP_SET_BOARD_ALIGNMENT_CONFIG: 39,
MSP_CURRENT_METER_CONFIG: 40,
MSP_SET_CURRENT_METER_CONFIG: 41,
MSP_MIXER_CONFIG: 42,
MSP_SET_MIXER_CONFIG: 43,
MSP_RX_CONFIG: 44,
MSP_SET_RX_CONFIG: 45,
MSP_LED_COLORS: 46,
MSP_SET_LED_COLORS: 47,
MSP_LED_STRIP_CONFIG: 48,
MSP_SET_LED_STRIP_CONFIG: 49,
MSP_RSSI_CONFIG: 50,
MSP_SET_RSSI_CONFIG: 51,
MSP_ADJUSTMENT_RANGES: 52,
MSP_SET_ADJUSTMENT_RANGE: 53,
MSP_CF_SERIAL_CONFIG: 54,
@ -39,8 +44,8 @@ var MSPCodes = {
MSP_SET_ARMING_CONFIG: 62,
MSP_RX_MAP: 64,
MSP_SET_RX_MAP: 65,
MSP_BF_CONFIG: 66,
MSP_SET_BF_CONFIG: 67,
MSP_BF_CONFIG: 66, // DEPRECATED
MSP_SET_BF_CONFIG: 67, // DEPRECATED
MSP_SET_REBOOT: 68,
MSP_BF_BUILD_INFO: 69, // Not used
MSP_DATAFLASH_SUMMARY: 70,
@ -71,9 +76,9 @@ var MSPCodes = {
MSP_SET_PID_ADVANCED: 95,
MSP_SENSOR_CONFIG: 96,
MSP_SET_SENSOR_CONFIG: 97,
// MSP_SPECIAL_PARAMETERS: 98, removed
//MSP_SET_SPECIAL_PARAMETERS: 99, removed
MSP_IDENT: 100, // Not used
//MSP_SPECIAL_PARAMETERS: 98, // DEPRECATED
//MSP_SET_SPECIAL_PARAMETERS: 99, // DEPRECATED
//MSP_IDENT: 100, // DEPRECTED
MSP_STATUS: 101,
MSP_RAW_IMU: 102,
MSP_SERVO: 103,
@ -86,19 +91,25 @@ var MSPCodes = {
MSP_ANALOG: 110,
MSP_RC_TUNING: 111,
MSP_PID: 112,
MSP_BOX: 113, // Not used
MSP_MISC: 114,
MSP_MOTOR_PINS: 115, // Not used
//MSP_BOX: 113, // DEPRECATED
MSP_MISC: 114, // DEPRECATED
MSP_BOXNAMES: 116,
MSP_PIDNAMES: 117,
MSP_WP: 118, // Not used
MSP_BOXIDS: 119,
MSP_SERVO_CONFIGURATIONS: 120,
MSP_3D: 124,
MSP_MOTOR_3D_CONFIG: 124,
MSP_RC_DEADBAND: 125,
MSP_SENSOR_ALIGNMENT: 126,
MSP_LED_STRIP_MODECOLOR: 127,
MSP_VOLTAGE_METERS: 128,
MSP_CURRENT_METERS: 129,
MSP_BATTERY_STATE: 130,
MSP_MOTOR_CONFIG: 131,
MSP_GPS_CONFIG: 132,
MSP_COMPASS_CONFIG: 133,
MSP_STATUS_EX: 150,
MSP_UID: 160,
@ -109,22 +120,25 @@ var MSPCodes = {
MSP_SET_RAW_RC: 200,
MSP_SET_RAW_GPS: 201, // Not used
MSP_SET_PID: 202,
MSP_SET_BOX: 203,
//MSP_SET_BOX: 203, // DEPRECATED
MSP_SET_RC_TUNING: 204,
MSP_ACC_CALIBRATION: 205,
MSP_MAG_CALIBRATION: 206,
MSP_SET_MISC: 207,
MSP_SET_MISC: 207, // DEPRECATED
MSP_RESET_CONF: 208,
MSP_SET_WP: 209, // Not used
MSP_SELECT_SETTING: 210,
MSP_SET_HEAD: 211, // Not used
MSP_SET_HEADING: 211, // Not used
MSP_SET_SERVO_CONFIGURATION: 212,
MSP_SET_MOTOR: 214,
MSP_SET_3D: 217,
MSP_SET_MOTOR_3D_CONFIG: 217,
MSP_SET_RC_DEADBAND: 218,
MSP_SET_RESET_CURR_PID: 219,
MSP_SET_SENSOR_ALIGNMENT: 220,
MSP_SET_LED_STRIP_MODECOLOR: 221,
MSP_SET_MOTOR_CONFIG: 222,
MSP_SET_GPS_CONFIG: 223,
MSP_SET_COMPASS_CONFIG: 224,
MSP_SET_ACC_TRIM: 239,
MSP_ACC_TRIM: 240,

View file

@ -52,6 +52,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
var data = dataHandler.dataView; // DataView (allowing us to view arrayBuffer as struct/union)
var code = dataHandler.code;
if (code === 0) {
debugger;
}
var crcError = dataHandler.crcError;
if (!crcError) {
if (!dataHandler.unsupported) switch (code) {
@ -75,7 +78,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
CONFIG.mode = data.readU32();
CONFIG.profile = data.readU8();
CONFIG.cpuload = data.readU16();
if (semver.gt(CONFIG.flightControllerVersion, "2.9.1")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
CONFIG.numProfiles = data.readU8();
CONFIG.rateProfile = data.readU8();
@ -154,6 +157,92 @@ MspHelper.prototype.process_data = function(dataHandler) {
ANALOG.rssi = data.readU16(); // 0-1023
ANALOG.amperage = data.read16() / 100; // A
ANALOG.last_received_timestamp = Date.now();
break;
case MSPCodes.MSP_VOLTAGE_METERS:
VOLTAGE_METERS = [];
var voltageMeterLength = 2;
for (var i = 0; i < (data.byteLength / voltageMeterLength); i++) {
var voltageMeter = {};
voltageMeter.id = data.readU8();
voltageMeter.voltage = data.readU8() / 10.0;
VOLTAGE_METERS.push(voltageMeter)
}
break;
case MSPCodes.MSP_CURRENT_METERS:
CURRENT_METERS = [];
var currentMeterLength = 5;
for (var i = 0; i < (data.byteLength / currentMeterLength); i++) {
var currentMeter = {};
currentMeter.id = data.readU8();
currentMeter.mAhDrawn = data.readU16(); // mAh
currentMeter.amperage = data.readU16() / 1000; // A
CURRENT_METERS.push(currentMeter);
}
break;
case MSPCodes.MSP_BATTERY_STATE:
BATTERY_STATE.cellCount = data.readU8();
BATTERY_STATE.capacity = data.readU16(); // mAh
BATTERY_STATE.voltage = data.readU8() / 10.0; // V
BATTERY_STATE.mAhDrawn = data.readU16(); // mAh
BATTERY_STATE.amperage = data.readU16() / 100; // A
break;
case MSPCodes.MSP_VOLTAGE_METER_CONFIG:
VOLTAGE_METER_CONFIGS = [];
var voltage_meter_count = data.readU8();
for (var i = 0; i < voltage_meter_count; i++) {
var subframe_length = data.readU8();
if (subframe_length != 5) {
for (var j = 0; j < subframe_length; j++) {
data.readU8();
}
} else {
var voltageMeterConfig = {};
voltageMeterConfig.id = data.readU8();
voltageMeterConfig.sensorType = data.readU8();
voltageMeterConfig.vbatscale = data.readU8();
voltageMeterConfig.vbatresdivval = data.readU8();
voltageMeterConfig.vbatresdivmultiplier = data.readU8();
VOLTAGE_METER_CONFIGS.push(voltageMeterConfig);
}
}
break;
case MSPCodes.MSP_CURRENT_METER_CONFIG:
var offset = 0;
CURRENT_METER_CONFIGS = [];
var current_meter_count = data.readU8();
for (var i = 0; i < current_meter_count; i++) {
var currentMeterConfig = {};
var subframe_length = data.readU8();
if (subframe_length != 6) {
for (var j = 0; j < subframe_length; j++) {
data.readU8();
}
} else {
currentMeterConfig.id = data.readU8();
currentMeterConfig.sensorType = data.readU8();
currentMeterConfig.scale = data.readU16();
currentMeterConfig.offset = data.readU16();
CURRENT_METER_CONFIGS.push(currentMeterConfig);
}
}
break;
case MSPCodes.MSP_BATTERY_CONFIG:
BATTERY_CONFIG.vbatmincellvoltage = data.readU8() / 10; // 10-50
BATTERY_CONFIG.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
BATTERY_CONFIG.vbatwarningcellvoltage = data.readU8() / 10; // 10-50
BATTERY_CONFIG.capacity = data.readU16();
BATTERY_CONFIG.voltageMeterSource = data.readU8();
BATTERY_CONFIG.currentMeterSource = data.readU8();
break;
case MSPCodes.MSP_RC_TUNING:
RC_tuning.RC_RATE = parseFloat((data.readU8() / 100).toFixed(2));
@ -178,7 +267,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
if (semver.gte(CONFIG.apiVersion, "1.10.0")) {
RC_tuning.RC_YAW_EXPO = parseFloat((data.readU8() / 100).toFixed(2));
if (semver.gte(CONFIG.flightControllerVersion, "2.9.1")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
RC_tuning.rcYawRate = parseFloat((data.readU8() / 100).toFixed(2));
} else {
RC_tuning.rcYawRate = 0;
@ -210,46 +299,50 @@ MspHelper.prototype.process_data = function(dataHandler) {
break;
case MSPCodes.MSP_MISC: // 22 bytes
RX_CONFIG.midrc = data.readU16();
MISC.minthrottle = data.readU16(); // 0-2000
MISC.maxthrottle = data.readU16(); // 0-2000
MISC.mincommand = data.readU16(); // 0-2000
MOTOR_CONFIG.minthrottle = data.readU16(); // 0-2000
MOTOR_CONFIG.maxthrottle = data.readU16(); // 0-2000
MOTOR_CONFIG.mincommand = data.readU16(); // 0-2000
MISC.failsafe_throttle = data.readU16(); // 1000-2000
MISC.gps_type = data.readU8();
GPS_CONFIG.provider = data.readU8();
MISC.gps_baudrate = data.readU8();
MISC.gps_ubx_sbas = data.readU8();
GPS_CONFIG.ublox_sbas = data.readU8();
MISC.multiwiicurrentoutput = data.readU8();
MISC.rssi_channel = data.readU8();
RSSI_CONFIG.channel = data.readU8();
MISC.placeholder2 = data.readU8();
if (semver.lt(CONFIG.apiVersion, "1.18.0"))
MISC.mag_declination = data.read16() / 10; // -1800-1800
COMPASS_CONFIG.mag_declination = data.read16() / 10; // -1800-1800
else
MISC.mag_declination = data.read16() / 100; // -18000-18000
MISC.vbatscale = data.readU8(); // 10-200
COMPASS_CONFIG.mag_declination = data.read16() / 100; // -18000-18000
MISC.vbatscale = data.readU8(); // was MISC.vbatscale - 10-200
MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50
MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50
break;
case MSPCodes.MSP_MOTOR_CONFIG:
MOTOR_CONFIG.minthrottle = data.readU16(); // 0-2000
MOTOR_CONFIG.maxthrottle = data.readU16(); // 0-2000
MOTOR_CONFIG.mincommand = data.readU16(); // 0-2000
break;
case MSPCodes.MSP_VOLTAGE_METER_CONFIG:
MISC.vbatscale = data.readU8(); // 10-200
MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50
MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50
if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
MISC.batterymetertype = data.readU8();
case MSPCodes.MSP_COMPASS_CONFIG:
COMPASS_CONFIG.mag_declination = data.read16() / 100; // -18000-18000
break;
case MSPCodes.MSP_GPS_CONFIG:
GPS_CONFIG.provider = data.readU8();
GPS_CONFIG.ublox_sbas = data.readU8();
if (semver.gte(CONFIG.apiVersion, "1.34.0")) {
GPS_CONFIG.auto_config = data.readU8();
GPS_CONFIG.auto_baud = data.readU8();
}
break;
case MSPCodes.MSP_CURRENT_METER_CONFIG:
BF_CONFIG.currentscale = data.read16();
BF_CONFIG.currentoffset = data.read16();
BF_CONFIG.currentmetertype = data.readU8();
BF_CONFIG.batterycapacity = data.readU16();
case MSPCodes.MSP_RSSI_CONFIG:
RSSI_CONFIG.channel = data.readU8();
break;
case MSPCodes.MSP_3D:
_3D.deadband3d_low = data.readU16();
_3D.deadband3d_high = data.readU16();
_3D.neutral3d = data.readU16();
case MSPCodes.MSP_MOTOR_3D_CONFIG:
MOTOR_3D_CONFIG.deadband3d_low = data.readU16();
MOTOR_3D_CONFIG.deadband3d_high = data.readU16();
MOTOR_3D_CONFIG.neutral = data.readU16();
if (semver.lt(CONFIG.apiVersion, "1.17.0")) {
_3D.deadband3d_throttle = data.readU16();
RC_DEADBAND_CONFIG.deadband3d_throttle = data.readU16();
}
break;
case MSPCodes.MSP_BOXNAMES:
@ -296,8 +389,24 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SERVO_CONFIGURATIONS:
SERVO_CONFIG = []; // empty the array as new data is coming in
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
if (data.byteLength % 12 == 0) {
for (var i = 0; i < data.byteLength; i += 12) {
var arr = {
'min': data.readU16(),
'max': data.readU16(),
'middle': data.readU16(),
'rate': data.read8(),
'angleAtMin': -90,
'angleAtMax': 90,
'indexOfChannelToForward': data.readU8(),
'reversedInputSources': data.readU32()
};
if (semver.gte(CONFIG.apiVersion, "1.12.0")) {
SERVO_CONFIG.push(arr);
}
}
} else if (semver.gte(CONFIG.apiVersion, "1.12.0")) {
if (data.byteLength % 14 == 0) {
for (var i = 0; i < data.byteLength; i += 14) {
var arr = {
@ -341,12 +450,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
break;
case MSPCodes.MSP_RC_DEADBAND:
RC_deadband.deadband = data.readU8();
RC_deadband.yaw_deadband = data.readU8();
RC_deadband.alt_hold_deadband = data.readU8();
RC_DEADBAND_CONFIG.deadband = data.readU8();
RC_DEADBAND_CONFIG.yaw_deadband = data.readU8();
RC_DEADBAND_CONFIG.alt_hold_deadband = data.readU8();
if (semver.gte(CONFIG.apiVersion, "1.17.0")) {
_3D.deadband3d_throttle = data.readU16();
RC_DEADBAND_CONFIG.deadband3d_throttle = data.readU16();
}
break;
case MSPCodes.MSP_SENSOR_ALIGNMENT:
@ -355,7 +464,6 @@ MspHelper.prototype.process_data = function(dataHandler) {
SENSOR_ALIGNMENT.align_mag = data.readU8();
break;
case MSPCodes.MSP_DISPLAYPORT:
console.log('Received \'MSP_DISPLAYPORT\' message, ignored.');
break;
case MSPCodes.MSP_SET_RAW_RC:
break;
@ -371,8 +479,17 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_MAG_CALIBRATION:
console.log('Mag calibration executed');
break;
case MSPCodes.MSP_SET_MISC:
console.log('MISC Configuration saved');
case MSPCodes.MSP_SET_MOTOR_CONFIG:
console.log('Motor Configuration saved');
break;
case MSPCodes.MSP_SET_GPS_CONFIG:
console.log('GPS Configuration saved');
break;
case MSPCodes.MSP_SET_RSSI_CONFIG:
console.log('RSSI Configuration saved');
break;
case MSPCodes.MSP_SET_FEATURE_CONFIG:
console.log('Features saved');
break;
case MSPCodes.MSP_RESET_CONF:
console.log('Settings Reset');
@ -387,7 +504,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
console.log('Settings Saved in EEPROM');
break;
case MSPCodes.MSP_SET_CURRENT_METER_CONFIG:
console.log('Current Settings saved');
console.log('Amperage Settings saved');
break;
case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
console.log('Voltage config saved');
@ -433,21 +550,23 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_RX_MAP:
console.log('RCMAP saved');
break;
case MSPCodes.MSP_BF_CONFIG:
BF_CONFIG.mixerConfiguration = data.readU8();
BF_CONFIG.features.setMask(data.readU32());
RX_CONFIG.serialrx_provider = data.readU8();
BF_CONFIG.board_align_roll = data.read16(); // -180 - 360
BF_CONFIG.board_align_pitch = data.read16(); // -180 - 360
BF_CONFIG.board_align_yaw = data.read16(); // -180 - 360
BF_CONFIG.currentscale = data.read16();
BF_CONFIG.currentoffset = data.read16();
updateTabList(BF_CONFIG.features);
case MSPCodes.MSP_MIXER_CONFIG:
MIXER_CONFIG.mixer = data.readU8();
break;
case MSPCodes.MSP_SET_BF_CONFIG:
case MSPCodes.MSP_FEATURE_CONFIG:
FEATURE_CONFIG.features.setMask(data.readU32());
updateTabList(FEATURE_CONFIG.features);
break;
case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG:
BOARD_ALIGNMENT_CONFIG.roll = data.read16(); // -180 - 360
BOARD_ALIGNMENT_CONFIG.pitch = data.read16(); // -180 - 360
BOARD_ALIGNMENT_CONFIG.yaw = data.read16(); // -180 - 360
break;
case MSPCodes.MSP_SET_REBOOT:
console.log('Reboot request accepted');
break;
@ -491,6 +610,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
CONFIG.boardIdentifier = identifier;
CONFIG.boardVersion = data.readU16();
if (semver.gte(CONFIG.apiVersion, "1.35.0")) {
CONFIG.boardType = data.readU8();
} else {
CONFIG.boardType = 0;
}
break;
case MSPCodes.MSP_NAME:
@ -582,22 +707,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
break;
case MSPCodes.MSP_CHANNEL_FORWARDING:
for (var i = 0; i < data.byteLength && i < SERVO_CONFIG.length; i ++) {
var channelIndex = data.readU8();
if (channelIndex < 255) {
SERVO_CONFIG[i].indexOfChannelToForward = channelIndex;
} else {
SERVO_CONFIG[i].indexOfChannelToForward = undefined;
}
}
break;
case MSPCodes.MSP_RX_CONFIG:
RX_CONFIG.serialrx_provider = data.readU8();
RX_CONFIG.maxcheck = data.readU16();
RX_CONFIG.midrc = data.readU16();
RX_CONFIG.mincheck = data.readU16();
RX_CONFIG.stick_max = data.readU16();
RX_CONFIG.stick_center = data.readU16();
RX_CONFIG.stick_min = data.readU16();
RX_CONFIG.spektrum_sat_bind = data.readU8();
RX_CONFIG.rx_min_usec = data.readU16();
RX_CONFIG.rx_max_usec = data.readU16();
@ -685,7 +799,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
ADVANCED_TUNING.yaw_p_limit = data.readU16();
ADVANCED_TUNING.deltaMethod = data.readU8();
ADVANCED_TUNING.vbatPidCompensation = data.readU8();
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
ADVANCED_TUNING.ptermSetpointWeight = data.readU8();
ADVANCED_TUNING.dtermSetpointWeight = data.readU8();
ADVANCED_TUNING.toleranceBand = data.readU8();
@ -875,9 +989,38 @@ MspHelper.prototype.process_data = function(dataHandler) {
console.log("Blackbox config saved");
break;
case MSPCodes.MSP_TRANSPONDER_CONFIG:
TRANSPONDER.supported = (data.readU8() & 1) != 0;
var bytesRemaining = data.byteLength;
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
var providerCount = data.readU8();
bytesRemaining--;
TRANSPONDER.supported = providerCount > 0;
TRANSPONDER.providers = [];
for (var i = 0; i < providerCount; i++) {
var provider = {
id: data.readU8(),
dataLength: data.readU8()
};
bytesRemaining -= 2;
TRANSPONDER.providers.push(provider);
}
TRANSPONDER.provider = data.readU8();
bytesRemaining--;
} else {
TRANSPONDER.supported = (data.readU8() & 1) != 0;
bytesRemaining--;
// only ILAP was supported prior to 1.33.0
TRANSPONDER.providers = [{
id: 1, // ILAP
dataLength: 6
}];
TRANSPONDER.provider = TRANSPONDER.providers[0].id;
}
TRANSPONDER.data = [];
var bytesRemaining = data.byteLength - 1;
for (var i = 0; i < bytesRemaining; i++) {
TRANSPONDER.data.push(data.readU8());
}
@ -907,9 +1050,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_RESET_CURR_PID:
console.log('Current PID profile reset');
break;
case MSPCodes.MSP_SET_3D:
case MSPCodes.MSP_SET_MOTOR_3D_CONFIG:
console.log('3D settings saved');
break;
case MSPCodes.MSP_SET_MIXER_CONFIG:
console.log('Mixer config saved');
break;
case MSPCodes.MSP_SET_RC_DEADBAND:
console.log('Rc controls settings saved');
break;
@ -985,16 +1131,17 @@ MspHelper.prototype.crunch = function(code) {
var buffer = [];
var self = this;
switch (code) {
case MSPCodes.MSP_SET_BF_CONFIG:
var featureMask = BF_CONFIG.features.getMask();
buffer.push8(BF_CONFIG.mixerConfiguration)
.push32(featureMask)
.push8(RX_CONFIG.serialrx_provider)
.push16(BF_CONFIG.board_align_roll)
.push16(BF_CONFIG.board_align_pitch)
.push16(BF_CONFIG.board_align_yaw)
.push16(BF_CONFIG.currentscale)
.push16(BF_CONFIG.currentoffset);
case MSPCodes.MSP_SET_FEATURE_CONFIG:
var featureMask = FEATURE_CONFIG.features.getMask();
buffer.push32(featureMask);
break;
case MSPCodes.MSP_SET_MIXER_CONFIG:
buffer.push8(MIXER_CONFIG.mixer)
break;
case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG:
buffer.push16(BOARD_ALIGNMENT_CONFIG.roll)
.push16(BOARD_ALIGNMENT_CONFIG.pitch)
.push16(BOARD_ALIGNMENT_CONFIG.yaw);
break;
case MSPCodes.MSP_SET_PID_CONTROLLER:
buffer.push8(PID.controller);
@ -1024,7 +1171,7 @@ MspHelper.prototype.crunch = function(code) {
}
if (semver.gte(CONFIG.apiVersion, "1.10.0")) {
buffer.push8(Math.round(RC_tuning.RC_YAW_EXPO * 100));
if (semver.gte(CONFIG.flightControllerVersion, "2.9.1")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
buffer.push8(Math.round(RC_tuning.rcYawRate * 100));
}
}
@ -1047,46 +1194,74 @@ MspHelper.prototype.crunch = function(code) {
break;
case MSPCodes.MSP_SET_MISC:
buffer.push16(RX_CONFIG.midrc)
.push16(MISC.minthrottle)
.push16(MISC.maxthrottle)
.push16(MISC.mincommand)
.push16(MOTOR_CONFIG.minthrottle)
.push16(MOTOR_CONFIG.maxthrottle)
.push16(MOTOR_CONFIG.mincommand)
.push16(MISC.failsafe_throttle)
.push8(MISC.gps_type)
.push8(GPS_CONFIG.provider)
.push8(MISC.gps_baudrate)
.push8(MISC.gps_ubx_sbas)
.push8(GPS_CONFIG.ublox_sbas)
.push8(MISC.multiwiicurrentoutput)
.push8(MISC.rssi_channel)
.push8(RSSI_CONFIG.channel)
.push8(MISC.placeholder2);
if (semver.lt(CONFIG.apiVersion, "1.18.0")) {
buffer.push16(Math.round(MISC.mag_declination * 10));
buffer.push16(Math.round(COMPASS_CONFIG.mag_declination * 10));
} else {
buffer.push16(Math.round(MISC.mag_declination * 100));
buffer.push16(Math.round(COMPASS_CONFIG.mag_declination * 100));
}
buffer.push8(MISC.vbatscale)
.push8(Math.round(MISC.vbatmincellvoltage * 10))
.push8(Math.round(MISC.vbatmaxcellvoltage * 10))
.push8(Math.round(MISC.vbatwarningcellvoltage * 10));
break;
case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
buffer.push8(MISC.vbatscale)
.push8(Math.round(MISC.vbatmincellvoltage * 10))
.push8(Math.round(MISC.vbatmaxcellvoltage * 10))
.push8(Math.round(MISC.vbatwarningcellvoltage * 10));
if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
buffer.push8(MISC.batterymetertype);
}
case MSPCodes.MSP_SET_MOTOR_CONFIG:
buffer.push16(MOTOR_CONFIG.minthrottle)
.push16(MOTOR_CONFIG.maxthrottle)
.push16(MOTOR_CONFIG.mincommand);
break;
case MSPCodes.MSP_SET_GPS_CONFIG:
buffer.push8(GPS_CONFIG.provider)
.push8(GPS_CONFIG.ublox_sbas);
if (semver.gte(CONFIG.apiVersion, "1.34.0")) {
buffer.push8(GPS_CONFIG.auto_config)
.push8(GPS_CONFIG.auto_baud);
}
break;
case MSPCodes.MSP_SET_CURRENT_METER_CONFIG:
buffer.push16(BF_CONFIG.currentscale)
.push16(BF_CONFIG.currentoffset)
.push8(BF_CONFIG.currentmetertype)
.push16(BF_CONFIG.batterycapacity)
case MSPCodes.MSP_SET_COMPASS_CONFIG:
buffer.push16(Math.round(COMPASS_CONFIG.mag_declination * 100));
break;
case MSPCodes.MSP_SET_RSSI_CONFIG:
buffer.push8(RSSI_CONFIG.channel);
break;
case MSPCodes.MSP_SET_BATTERY_CONFIG:
buffer.push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10))
.push8(Math.round(BATTERY_CONFIG.vbatmaxcellvoltage * 10))
.push8(Math.round(BATTERY_CONFIG.vbatwarningcellvoltage * 10))
.push16(BATTERY_CONFIG.capacity)
.push8(BATTERY_CONFIG.voltageMeterSource)
.push8(BATTERY_CONFIG.currentMeterSource);
break;
// FIXME - Needs updating before it can be used.
// case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
// buffer.push8(MISC.vbatscale)
// .push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10))
// .push8(Math.round(BATTERY_CONFIG.vbatmaxcellvoltage * 10))
// .push8(Math.round(BATTERY_CONFIG.vbatwarningcellvoltage * 10));
// if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
// buffer.push8(BATTERY_CONFIG.voltageMeterSource);
// }
// break;
// case MSPCodes.MSP_SET_CURRENT_METER_CONFIG:
// buffer.push16(BF_CONFIG.currentscale)
// .push16(BF_CONFIG.currentoffset)
// .push8(BATTERY_CONFIG.currentMeterSource)
// .push16(BF_CONFIG.batterycapacity)
// break;
case MSPCodes.MSP_SET_RX_CONFIG:
buffer.push8(RX_CONFIG.serialrx_provider)
.push16(RX_CONFIG.maxcheck)
.push16(RX_CONFIG.midrc)
.push16(RX_CONFIG.mincheck)
.push16(RX_CONFIG.stick_max)
.push16(RX_CONFIG.stick_center)
.push16(RX_CONFIG.stick_min)
.push8(RX_CONFIG.spektrum_sat_bind)
.push16(RX_CONFIG.rx_min_usec)
.push16(RX_CONFIG.rx_max_usec);
@ -1116,6 +1291,9 @@ MspHelper.prototype.crunch = function(code) {
break;
case MSPCodes.MSP_SET_TRANSPONDER_CONFIG:
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
buffer.push8(TRANSPONDER.provider); //
}
for (var i = 0; i < TRANSPONDER.data.length; i++) {
buffer.push8(TRANSPONDER.data[i]);
}
@ -1156,21 +1334,21 @@ MspHelper.prototype.crunch = function(code) {
}
break;
case MSPCodes.MSP_SET_3D:
buffer.push16(_3D.deadband3d_low)
.push16(_3D.deadband3d_high)
.push16(_3D.neutral3d);
case MSPCodes.MSP_SET_MOTOR_3D_CONFIG:
buffer.push16(MOTOR_3D_CONFIG.deadband3d_low)
.push16(MOTOR_3D_CONFIG.deadband3d_high)
.push16(MOTOR_3D_CONFIG.neutral);
if (semver.lt(CONFIG.apiVersion, "1.17.0")) {
buffer.push16(_3D.deadband3d_throttle);
buffer.push16(RC_DEADBAND_CONFIG.deadband3d_throttle);
}
break;
case MSPCodes.MSP_SET_RC_DEADBAND:
buffer.push8(RC_deadband.deadband)
.push8(RC_deadband.yaw_deadband)
.push8(RC_deadband.alt_hold_deadband);
buffer.push8(RC_DEADBAND_CONFIG.deadband)
.push8(RC_DEADBAND_CONFIG.yaw_deadband)
.push8(RC_DEADBAND_CONFIG.alt_hold_deadband);
if (semver.gte(CONFIG.apiVersion, "1.17.0")) {
buffer.push16(_3D.deadband3d_throttle);
buffer.push16(RC_DEADBAND_CONFIG.deadband3d_throttle);
}
break;
@ -1209,7 +1387,7 @@ MspHelper.prototype.crunch = function(code) {
}
break;
case MSPCodes.MSP_SET_PID_ADVANCED:
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
buffer.push16(ADVANCED_TUNING.rollPitchItermIgnoreRate)
.push16(ADVANCED_TUNING.yawItermIgnoreRate)
.push16(ADVANCED_TUNING.yaw_p_limit)
@ -1284,7 +1462,7 @@ MspHelper.prototype.setRawRx = function(channels) {
MspHelper.prototype.dataflashRead = function(address, blockSize, onDataCallback) {
var outData = [address & 0xFF, (address >> 8) & 0xFF, (address >> 16) & 0xFF, (address >> 24) & 0xFF];
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
outData = outData.concat([blockSize & 0xFF, (blockSize >> 8) & 0xFF]);
}
@ -1295,7 +1473,7 @@ MspHelper.prototype.dataflashRead = function(address, blockSize, onDataCallback)
var headerSize = 4;
var dataSize = response.data.buffer.byteLength - headerSize;
var dataCompressionType = 0;
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
headerSize = headerSize + 3;
dataSize = response.data.readU16();
dataCompressionType = response.data.readU8();
@ -1355,9 +1533,12 @@ MspHelper.prototype.sendServoConfigurations = function(onCompleteCallback) {
.push16(servoConfiguration.min)
.push16(servoConfiguration.max)
.push16(servoConfiguration.middle)
.push8(servoConfiguration.rate)
.push8(servoConfiguration.angleAtMin)
.push8(servoConfiguration.angleAtMax);
.push8(servoConfiguration.rate);
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
buffer.push8(servoConfiguration.angleAtMin)
.push8(servoConfiguration.angleAtMax);
}
var out = servoConfiguration.indexOfChannelToForward;
if (out == undefined) {

View file

@ -1,6 +1,7 @@
'use strict';
var serial = {
connected: false,
connectionId: false,
openRequested: false,
openCanceled: false,
@ -38,6 +39,7 @@ var serial = {
}
if (connectionInfo && !self.openCanceled) {
self.connected = true;
self.connectionId = connectionInfo.connectionId;
self.bitrate = connectionInfo.bitrate;
self.bytesReceived = 0;
@ -187,6 +189,7 @@ var serial = {
console.log('onConnectedCallback', result)
if(result == 0) {
self.connected = true;
chrome.sockets.tcp.setNoDelay(createInfo.socketId, true, function (noDelayResult){
if (chrome.runtime.lastError) {
console.error('setNoDelay', chrome.runtime.lastError.message);
@ -221,7 +224,6 @@ var serial = {
});
console.log(self.logHead + 'Connection opened with ID: ' + createInfo.socketId + ', url: ' + self.connectionIP + ':' + self.connectionPort);
if (callback) callback(createInfo);
});
} else {
@ -235,6 +237,7 @@ var serial = {
},
disconnect: function (callback) {
var self = this;
self.connected = false;
if (self.connectionId) {
self.emptyOutputBuffer();
@ -300,9 +303,27 @@ var serial = {
// store inside separate variables in case array gets destroyed
var data = self.outputBuffer[0].data,
callback = self.outputBuffer[0].callback;
if (!self.connected) {
console.log('attempting to send when disconnected');
if (callback) callback({
bytesSent: 0,
error: 'undefined'
});
return;
}
var sendFn = (self.connectionType == 'serial') ? chrome.serial.send : chrome.sockets.tcp.send;
sendFn(self.connectionId, data, function (sendInfo) {
if (sendInfo === undefined) {
console.log('undefined send error');
if (callback) callback({
bytesSent: 0,
error: 'undefined'
});
return;
}
// tcp send error
if (self.connectionType == 'tcp' && sendInfo.resultCode < 0) {
var error = 'system_error';

View file

@ -61,12 +61,11 @@ $(document).ready(function () {
GUI.tab_switch_cleanup();
GUI.tab_switch_in_progress = false;
var wasConnected = CONFIGURATOR.connectionValid;
serial.disconnect(onClosed);
var wasConnected = CONFIGURATOR.connectionValid;
GUI.connected_to = false;
CONFIGURATOR.connectionValid = false;
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
MSP.disconnect_cleanup();
PortUsage.reset();
@ -74,7 +73,7 @@ $(document).ready(function () {
// Reset various UI elements
$('span.i2c-error').text(0);
$('span.cycle-time').text(0);
if (CONFIG.flightControllerVersion !== '' && semver.gte(CONFIG.flightControllerVersion, "3.0.0"))
if (semver.gte(CONFIG.apiVersion, "1.20.0"))
$('span.cpu-load').text('');
// unlock port select & baud
@ -211,7 +210,7 @@ function onOpen(openInfo) {
// continue as usually
CONFIGURATOR.connectionValid = true;
GUI.allowedTabs = GUI.defaultAllowedTabsWhenConnected.slice();
GUI.allowedTabs = GUI.defaultAllowedFCTabsWhenConnected.slice();
if (semver.lt(CONFIG.apiVersion, "1.4.0")) {
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('led_strip'), 1);
}
@ -263,31 +262,47 @@ function onConnect() {
GUI.timeout_remove('connecting'); // kill connecting timer
$('div#connectbutton a.connect_state').text(chrome.i18n.getMessage('disconnect')).addClass('active');
$('div#connectbutton a.connect').addClass('active');
$('#tabs ul.mode-disconnected').hide();
$('#tabs ul.mode-connected-cli').show();
// show only appropriate tabs
$('#tabs ul.mode-connected li').hide();
$('#tabs ul.mode-connected li').filter(function (index) {
var classes = $(this).attr("class").split(/\s+/);
var found = false;
$.each(GUI.allowedTabs, function (index, value) {
var tabName = "tab_" + value;
if ($.inArray(tabName, classes) >= 0) {
found = true;
}
});
if (CONFIG.boardType == 0) {
if (classes.indexOf("osd-required") >= 0) {
found = false;
}
}
return found;
}).show();
if (CONFIG.flightControllerVersion !== '') {
BF_CONFIG.features = new Features(CONFIG);
FEATURE_CONFIG.features = new Features(CONFIG);
$('#tabs ul.mode-connected').show();
if (semver.gte(CONFIG.flightControllerVersion, "2.9.1")) {
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false);
} else {
MSP.send_message(MSPCodes.MSP_STATUS, false, false);
if (semver.gte(CONFIG.flightControllerVersion, "2.4.0")) {
CONFIG.numProfiles = 2;
$('.tab-pid_tuning select[name="profile"] .profile3').hide();
} else {
CONFIG.numProfiles = 3;
$('.tab-pid_tuning select[name="rate_profile"]').hide();
}
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false);
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_BATTERY_CONFIG, false, false);
}
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false);
MSP.send_message(MSPCodes.MSP_DATAFLASH_SUMMARY, false, false);
startLiveDataRefreshTimer();
if (CONFIG.boardType == 0 || CONFIG.boardType == 2) {
startLiveDataRefreshTimer();
}
}
var sensor_state = $('#sensor-status');
@ -324,6 +339,10 @@ function onClosed(result) {
battery.hide();
MSP.clearListeners();
CONFIGURATOR.connectionValid = false;
CONFIGURATOR.cliValid = false;
CONFIGURATOR.cliActive = false;
}
function read_serial(info) {
@ -359,7 +378,7 @@ function sensor_status(sensors_detected) {
$('.accicon', e_sensor_status).removeClass('active');
}
if (true) { // Gyro status is not reported by FC
if (CONFIG.boardType == 0 || CONFIG.boardType == 2) { // Gyro status is not reported by FC
$('.gyro', e_sensor_status).addClass('on');
$('.gyroicon', e_sensor_status).addClass('active');
} else {
@ -460,10 +479,10 @@ function update_live_status() {
if (GUI.active_tab != 'cli') {
MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false);
if (semver.gte(CONFIG.flightControllerVersion, "2.9.1"))
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false);
if (semver.gte(CONFIG.apiVersion, "1.32.0"))
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false);
else
MSP.send_message(MSPCodes.MSP_STATUS, false, false);
MSP.send_message(MSPCodes.MSP_STATUS, false, false);
MSP.send_message(MSPCodes.MSP_ANALOG, false, false);
}
@ -492,13 +511,13 @@ function update_live_status() {
}
}
if (ANALOG != undefined) {
var nbCells = Math.floor(ANALOG.voltage / MISC.vbatmaxcellvoltage) + 1;
var nbCells = Math.floor(ANALOG.voltage / BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
if (ANALOG.voltage == 0)
nbCells = 1;
var min = MISC.vbatmincellvoltage * nbCells;
var max = MISC.vbatmaxcellvoltage * nbCells;
var warn = MISC.vbatwarningcellvoltage * nbCells;
var min = BATTERY_CONFIG.vbatmincellvoltage * nbCells;
var max = BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
var warn = BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
$(".battery-status").css({
width: ((ANALOG.voltage - min) / (max - min) * 100) + "%",

View file

@ -811,6 +811,19 @@ li.active .ic_transponder {
background-image: url(images/icons/icon_osd_white.svg);
}
.ic_power {
background-image: url(images/icons/cf_icon_power_grey.svg);
background-position-y: 9px;
}
.ic_power:hover {
background-image: url(images/icons/cf_icon_power_white.svg);
}
li.active .ic_power {
background-image: url(images/icons/cf_icon_power_white.svg);
}
/* SPARE Tab-Icons */
.ic_failsafe {
background-image: url(images/icons/cf_icon_failsafe_grey.svg);
@ -1456,7 +1469,7 @@ dialog {
/* fixing padding for all Tabs*/
.tab-setup, .tab-landing, .tab-adjustments, .tab-auxiliary, .tab-cli, .tab-configuration, .tab-failsafe, .tab-onboard_logging,
.tab-firmware_flasher, .tab-gps, .tab-help, .tab-led-strip, .tab-logging, .tab-modes, .tab-motors, .tab-pid_tuning,
.tab-ports, .tab-receiver, .tab-sensors, .tab-servos, .tab-osd {
.tab-ports, .tab-receiver, .tab-sensors, .tab-servos, .tab-osd, .tab-power {
height: 100%;
position: relative;
}

View file

@ -9,6 +9,7 @@
<link type="text/css" rel="stylesheet" href="./js/libraries/flightindicators.css"/>
<link type="text/css" rel="stylesheet" href="./tabs/landing.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/setup.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/setup_osd.css" media="all" />
<link type="text/css" rel="stylesheet" href="./tabs/help.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/ports.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/configuration.css" media="all"/>
@ -27,7 +28,9 @@
<link type="text/css" rel="stylesheet" href="./tabs/auxiliary.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/failsafe.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/osd.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/power.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./tabs/transponder.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./css/font-awesome/css/font-awesome.min.css" media="all">
<link type="text/css" rel="stylesheet" href="./css/opensans_webfontkit/fonts.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./css/dropdown-lists/css/style_lists.css" media="all"/>
<link type="text/css" rel="stylesheet" href="./js/libraries/switchery/switchery.css" media="all"/>
@ -69,6 +72,7 @@
<script type="text/javascript" src="./main.js"></script>
<script type="text/javascript" src="./tabs/landing.js"></script>
<script type="text/javascript" src="./tabs/setup.js"></script>
<script type="text/javascript" src="./tabs/setup_osd.js"></script>
<script type="text/javascript" src="./tabs/help.js"></script>
<script type="text/javascript" src="./tabs/ports.js"></script>
<script type="text/javascript" src="./tabs/configuration.js"></script>
@ -87,6 +91,7 @@
<script type="text/javascript" src="./tabs/firmware_flasher.js"></script>
<script type="text/javascript" src="./tabs/failsafe.js"></script>
<script type="text/javascript" src="./tabs/osd.js"></script>
<script type="text/javascript" src="./tabs/power.js"></script>
<script type="text/javascript" src="./tabs/transponder.js"></script>
<title></title>
</head>
@ -213,9 +218,13 @@
</ul>
<ul class="mode-connected">
<li class="tab_setup"><a href="#" i18n="tabSetup" class="tabicon ic_setup" title="Setup"></a></li>
<li class="tab_setup_osd"><a href="#" i18n="tabSetupOSD" class="tabicon ic_setup" title="OSD Setup"></a></li>
<li class="tab_ports"><a href="#" i18n="tabPorts" class="tabicon ic_ports" title="Ports"></a></li>
<li class="tab_configuration"><a href="#" i18n="tabConfiguration" class="tabicon ic_config"
title="Configuration"></a></li>
<li class="tab_power"><a href="#" i18n="tabPower" class="tabicon ic_power"
title="Power &amp; Battery"></a></li>
<li class="tab_failsafe"><a href="#" i18n="tabFailsafe" class="tabicon ic_failsafe"
title="Failsafe"></a></li>
<li class="tab_pid_tuning"><a href="#" i18n="tabPidTuning" class="tabicon ic_pid"
@ -240,15 +249,15 @@
title="Tethered Logging"></a></li>
<li class="tab_onboard_logging"><a href="#" i18n="tabOnboardLogging" class="tabicon ic_data"
title="Onboard Logging"></a></li>
</ul>
<ul class="mode-connected-cli">
<li class="tab_cli"><a href="#" i18n="tabCLI" class="tabicon ic_cli" title="CLI"></a></li>
<!-- spare icons
<li class=""><a href="#"class="tabicon ic_mission">Mission (spare icon)</a></li>
<li class=""><a href="#"class="tabicon ic_advanced">Advanced (spare icon)</a></li>
<li class=""><a href="#"class="tabicon ic_wizzard">Wizzard (spare icon)</a></li>
-->
</ul>
<ul class="mode-connected mode-connected-cli">
<li class="tab_cli"><a href="#" i18n="tabCLI" class="tabicon ic_cli" title="CLI"></a></li>
</ul>
</div>
<div class="clear-both"></div>
</div>

25
main.js
View file

@ -149,9 +149,16 @@ $(document).ready(function () {
case 'osd':
TABS.osd.initialize(content_ready);
break;
case 'power':
TABS.power.initialize(content_ready);
break;
case 'setup':
TABS.setup.initialize(content_ready);
break;
case 'setup_osd':
TABS.setup_osd.initialize(content_ready);
break;
case 'configuration':
TABS.configuration.initialize(content_ready);
break;
@ -228,8 +235,8 @@ $(document).ready(function () {
chrome.storage.local.set({'permanentExpertMode': checked});
$('input[name="expertModeCheckbox"]').prop('checked', checked).change();
if (BF_CONFIG) {
updateTabList(BF_CONFIG.features);
if (FEATURE_CONFIG) {
updateTabList(FEATURE_CONFIG.features);
}
}).change();
@ -362,8 +369,8 @@ $(document).ready(function () {
}
$('input[name="expertModeCheckbox"]').change(function () {
if (BF_CONFIG) {
updateTabList(BF_CONFIG.features);
if (FEATURE_CONFIG) {
updateTabList(FEATURE_CONFIG.features);
}
}).change();
});
@ -463,7 +470,6 @@ function updateTabList(features) {
} else {
$('#tabs ul.mode-connected li.tab_transponder').hide();
}
if (features.isEnabled('OSD')) {
$('#tabs ul.mode-connected li.tab_osd').show();
} else {
@ -485,8 +491,13 @@ function generateFilename(prefix, suffix) {
var date = new Date();
var filename = prefix;
if (CONFIG && CONFIG.name && CONFIG.name.trim() !== '') {
filename = filename + '_' + CONFIG.name.trim().replace(' ', '_');
if (CONFIG) {
if (CONFIG.flightControllerIdentifier) {
filename = CONFIG.flightControllerIdentifier + '_' + filename;
}
if(CONFIG.name && CONFIG.name.trim() !== '') {
filename = filename + '_' + CONFIG.name.trim().replace(' ', '_');
}
}
filename = filename + '_' + date.getFullYear()

View file

@ -273,7 +273,7 @@ TABS.adjustments.cleanup = function (callback) {
TABS.adjustments.adjust_template = function () {
var availableFunctionCount;
if (semver.lt(CONFIG.flightControllerVersion, '3.1.0')) {
if (semver.lt(CONFIG.apiVersion, "1.31.0")) {
availableFunctionCount = 21; // Available in betaflight 2.9
} else {
availableFunctionCount = 24; // RC rate Yaw / D setpoint / D setpoint transition added to 3.1.0

View file

@ -208,7 +208,7 @@ TABS.cli.sendLine = function (line, callback) {
}
TABS.cli.cleanup = function (callback) {
if (!CONFIGURATOR.connectionValid || !CONFIGURATOR.cliValid) {
if (!(CONFIGURATOR.connectionValid && CONFIGURATOR.cliValid && CONFIGURATOR.cliActive)) {
if (callback) callback();
return;
}

View file

@ -292,7 +292,7 @@
width: 150px;
}
.tab-configuration .currentmetertype {
.tab-configuration .currentMeterSource {
border: 1px solid silver;
margin-right: 5px;
float: left;

View file

@ -121,7 +121,8 @@
</div>
</div>
<div class="clear-both"></div>
<div class="leftWrapper board">
<div class="leftWrapper board acc">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationBoardAlignment"></div>
@ -179,8 +180,6 @@
</div>
</div>
</div>
</div>
<div class="rightWrapper acc">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationAccelTrims"></div>
@ -199,50 +198,47 @@
</div>
</div>
</div>
<div class="clear-both"></div>
<div class="leftWrapper">
<div class="gui_box grey" style="margin-bottom:20px;">
<div class="rightWrapper 3d">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationReceiver"></div>
</div>
<div class="spacer_box" style="padding-bottom:15px;">
<select class="features rxMode" name="rxMode">
<!-- list generated here -->
</select>
<span i18n="configurationReceiverMode"></span>
</div>
<div class="serialRXBox spacer_box" style="padding-bottom:10px;">
<div class="note spacerbottom">
<div class="note_spacer">
<p i18n="configurationSerialRXHelp"></p>
</div>
</div>
<select class="serialRX">
<!-- list generated here -->
</select>
<span i18n="configurationSerialRX"></span>
</div>
</div>
<div class="gui_box grey" style="margin-bottom:20px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationRSSI"></div>
<div class="helpicon cf_tip" i18n_title="configurationRSSIHelp"></div>
<div class="spacer_box_title" i18n="configuration3d"></div>
</div>
<div class="spacer_box">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th i18n="configurationFeatureEnabled"></th>
<th i18n="configurationFeatureDescription"></th>
<th i18n="configurationFeatureName"></th>
</tr>
<tr>
<th i18n="configurationFeatureEnabled"></th>
<th i18n="configurationFeatureDescription"></th>
<th i18n="configurationFeatureName"></th>
</tr>
</thead>
<tbody class="features rssi">
<tbody class="features 3D">
<!-- table generated here -->
</tbody>
</table>
<div class="_3dSettings">
<div class="number">
<label> <input type="number" name="3ddeadbandlow" step="1" min="1250" max="1600" /> <span
i18n="configuration3dDeadbandLow"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="3ddeadbandhigh" step="1" min="1400" max="1750" /> <span
i18n="configuration3dDeadbandHigh"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="3dneutral" step="1" min="1400" max="1600" /> <span
i18n="configuration3dNeutral"></span>
</label>
</div>
</div>
</div>
</div>
</div>
<div class="clear-both"></div>
<div class="leftWrapper">
<div class="gui_box grey" style="margin-bottom:20px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationSystem"></div>
@ -306,6 +302,32 @@
</div>
</div>
</div>
<div class="gui_box grey miscSettings" style="margin-top:10px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationPersonalization"></div>
</div>
<div class="spacer_box">
<div class="number">
<label> <input type="text" name="craftName" maxlength="32" style="width:100px;"/> <span
i18n="craftName"></span>
</label>
</div>
</div>
</div>
<div class="gui_box grey miscSettings" style="margin-top:10px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationCamera"></div>
</div>
<div class="spacer_box">
<div class="number fpvCamAngleDegrees">
<label> <input type="number" name="fpvCamAngleDegrees" step="1" min="0" max="50" /> <span
i18n="configurationFpvCamAngleDegrees"></span>
</label>
</div>
</div>
</div>
</div>
<div class="rightWrapper featuresOther">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationFeatures"></div>
@ -331,106 +353,59 @@
</div>
</div>
</div>
<div class="rightWrapper current voltage">
<div class="gui_box grey">
<div class="clear-both"></div>
<!-- FIXME move receiver and RSSI to receiver tab -->
<div class="leftWrapper receiver">
<div class="gui_box grey" style="margin-bottom:20px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationBatteryVoltage"></div>
<div class="spacer_box_title" i18n="configurationReceiver"></div>
</div>
<div class="spacer_box">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th i18n="configurationFeatureEnabled"></th>
<th i18n="configurationFeatureDescription"></th>
<th i18n="configurationFeatureName"></th>
</tr>
</thead>
<tbody class="features batteryVoltage">
<!-- table generated here -->
</tbody>
</table>
<div class="select batterymetertype vbatmonitoring">
<label>
<select class="batterymetertype"><!-- list generated here --></select>
<span i18n="configurationBatteryMeterType"></span>
</label>
</div>
<div class="number vbatmonitoring">
<label> <input type="number" name="mincellvoltage" step="0.1" min="1" max="5" /> <span
i18n="configurationBatteryMinimum"></span>
</label>
</div>
<div class="number vbatmonitoring">
<label> <input type="number" name="maxcellvoltage" step="0.1" min="1" max="5" /> <span
i18n="configurationBatteryMaximum"></span>
</label>
</div>
<div class="number vbatmonitoring">
<label> <input type="number" name="warningcellvoltage" step="0.1" min="1" max="5" /> <span
i18n="configurationBatteryWarning"></span>
</label>
</div>
<div class="number vbatmonitoring vbatCalibration">
<label> <input type="number" name="voltagescale" step="1" min="10" max="255" /> <span
i18n="configurationBatteryScale"></span>
</label>
</div>
<div class="number vbatmonitoring">
<label> <input type="text" name="batteryvoltage" readonly class="disabled" /> <span
i18n="configurationBatteryVoltage"></span>
</label>
</div>
<div class="spacer_box" style="padding-bottom:15px;">
<select class="features rxMode" name="rxMode">
<!-- list generated here -->
</select>
<span i18n="configurationReceiverMode"></span>
</div>
</div>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationCurrent"></div>
</div>
<div class="spacer_box">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th i18n="configurationFeatureEnabled"></th>
<th i18n="configurationFeatureDescription"></th>
<th i18n="configurationFeatureName"></th>
</tr>
</thead>
<tbody class="features batteryCurrent">
<!-- table generated here -->
</tbody>
</table>
<div class="select currentMonitoring">
<label>
<select class="currentmetertype"><!-- list generated here --></select>
<span i18n="configurationCurrentMeterType"></span>
</label>
</div>
<div class="number currentMonitoring currentCalibration">
<label> <input type="number" name="currentscale" step="1" min="-16000" max="16000" /> <span
i18n="configurationCurrentScale"></span>
</label>
</div>
<div class="number currentMonitoring currentCalibration">
<label> <input type="number" name="currentoffset" step="1" min="-1600" max="16000" /> <span
i18n="configurationCurrentOffset"></span>
</label>
</div>
<div class="number currentMonitoring currentOutput">
<label>
<input type="text" name="batterycurrent" readonly class="disabled" /> <span
i18n="configurationBatteryCurrent"></span>
</label>
</div>
<div class="checkbox currentMonitoring currentOutput">
<div class="numberspacer">
<input type="checkbox" name="multiwiicurrentoutput" class="toggle" />
<div class="serialRXBox spacer_box" style="padding-bottom:10px;">
<div class="note spacerbottom">
<div class="note_spacer">
<p i18n="configurationSerialRXHelp"></p>
</div>
<label> <span i18n="configurationBatteryMultiwiiCurrent"></span>
</label>
</div>
<select class="serialRX">
<!-- list generated here -->
</select>
<span i18n="configurationSerialRX"></span>
</div>
</div>
<div class="gui_box grey gps" style="margin-top:10px;">
</div>
<div class="rightWrapper rssi">
<div class="gui_box grey" style="margin-bottom:20px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationRSSI"></div>
<div class="helpicon cf_tip" i18n_title="configurationRSSIHelp"></div>
</div>
<div class="spacer_box">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th i18n="configurationFeatureEnabled"></th>
<th i18n="configurationFeatureDescription"></th>
<th i18n="configurationFeatureName"></th>
</tr>
</thead>
<tbody class="features rssi">
<!-- table generated here -->
</tbody>
</table>
</div>
</div>
</div>
<div class="clear-both"></div>
<div class="leftWrapper gps">
<div class="gui_box grey gps">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationGPS"></div>
</div>
@ -467,6 +442,22 @@
</select>
<span i18n="configurationGPSBaudrate"></span>
</div>
<div class="select gps_auto_baud">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" name="gps_auto_baud" class="toggle" />
</div>
<label for="gps_auto_baud"> <span class="freelabel"
i18n="configurationGPSAutoBaud"></span>
</label>
</div>
<div class="select gps_auto_config">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" name="gps_auto_config" class="toggle" />
</div>
<label for="gps_auto_config"> <span class="freelabel"
i18n="configurationGPSAutoConfig"></span>
</label>
</div>
<div class="line">
<select class="gps_ubx_sbas">
<!-- list generated here -->
@ -481,67 +472,8 @@
</div>
</div>
</div>
<div class="gui_box grey" style="margin-top:10px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configuration3d"></div>
</div>
<div class="spacer_box">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th i18n="configurationFeatureEnabled"></th>
<th i18n="configurationFeatureDescription"></th>
<th i18n="configurationFeatureName"></th>
</tr>
</thead>
<tbody class="features 3D">
<!-- table generated here -->
</tbody>
</table>
<div class="_3dSettings">
<div class="number">
<label> <input type="number" name="3ddeadbandlow" step="1" min="1425" max="1500" /> <span
i18n="configuration3dDeadbandLow"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="3ddeadbandhigh" step="1" min="1500" max="1575" /> <span
i18n="configuration3dDeadbandHigh"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="3dneutral" step="1" min="1475" max="1525" /> <span
i18n="configuration3dNeutral"></span>
</label>
</div>
<div class="number" >
<label> <input type="number" name="3ddeadbandthrottle" step="1" min="0" max="1000" /> <span
i18n="configuration3dDeadbandThrottle"></span>
</label>
</div>
</div>
</div>
</div>
<div class="gui_box grey miscSettings" style="margin-top:10px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationMisc"></div>
</div>
<div class="spacer_box">
<div class="number">
<label> <input type="text" name="vesselName" maxlength="32" style="width:100px;"/> <span
i18n="configurationVesselName"></span>
</label>
</div>
<div class="number fpvCamAngleDegrees">
<label> <input type="number" name="fpvCamAngleDegrees" step="1" min="0" max="50" /> <span
i18n="configurationFpvCamAngleDegrees"></span>
</label>
</div>
</div>
</div>
</div>
<div class="clear-both"></div>
<div class="clear-both"></div>
</div>
<div class="content_toolbar">
<div class="btn save_btn">

View file

@ -12,43 +12,73 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_config() {
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, load_serial_config);
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, load_serial_config);
}
function load_serial_config() {
var next_callback = load_rc_map;
if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, next_callback);
MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, load_board_alignment_config);
}
function load_board_alignment_config() {
MSP.send_message(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG, false, false, load_rc_map);
}
function load_rc_map() {
MSP.send_message(MSPCodes.MSP_RX_MAP, false, false, load_mixer_config);
}
function load_mixer_config() {
MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_rssi_config);
}
function load_rssi_config() {
MSP.send_message(MSPCodes.MSP_RSSI_CONFIG, false, false, load_motor_config);
}
function load_motor_config() {
var next_callback = load_compass_config;
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, next_callback);
} else {
next_callback();
}
}
function load_rc_map() {
MSP.send_message(MSPCodes.MSP_RX_MAP, false, false, load_misc);
function load_compass_config() {
var next_callback = load_gps_config;
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_COMPASS_CONFIG, false, false, load_gps_config);
} else {
next_callback();
}
}
function load_misc() {
MSP.send_message(MSPCodes.MSP_MISC, false, false, load_acc_trim);
function load_gps_config() {
var next_callback = load_acc_trim;
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_GPS_CONFIG, false, false, load_acc_trim);
} else {
next_callback();
}
}
function load_acc_trim() {
MSP.send_message(MSPCodes.MSP_ACC_TRIM, false, false, load_arming_config);
MSP.send_message(MSPCodes.MSP_ACC_TRIM, false, false, load_misc);
}
function load_arming_config() {
var next_callback = load_loop_time;
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
MSP.send_message(MSPCodes.MSP_ARMING_CONFIG, false, false, next_callback);
function load_misc() {
var next_callback = load_arming_config;
if (semver.lt(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_MISC, false, false, next_callback);
} else {
next_callback();
}
}
function load_loop_time() {
function load_arming_config() {
var next_callback = load_3d;
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
MSP.send_message(MSPCodes.MSP_LOOP_TIME, false, false, next_callback);
MSP.send_message(MSPCodes.MSP_ARMING_CONFIG, false, false, next_callback);
} else {
next_callback();
}
@ -57,7 +87,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
function load_3d() {
var next_callback = load_rc_deadband;
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
MSP.send_message(MSPCodes.MSP_3D, false, false, next_callback);
MSP.send_message(MSPCodes.MSP_MOTOR_3D_CONFIG, false, false, next_callback);
} else {
next_callback();
}
@ -74,7 +104,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
function esc_protocol() {
var next_callback = sensor_config;
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, next_callback);
} else {
next_callback();
@ -83,7 +113,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
function sensor_config() {
var next_callback = load_sensor_alignment;
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, next_callback);
} else {
next_callback();
@ -100,28 +130,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_name() {
var next_callback = load_battery;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
var next_callback = load_rx_config;
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
MSP.send_message(MSPCodes.MSP_NAME, false, false, next_callback);
} else {
next_callback();
}
}
function load_battery() {
var next_callback = load_current;
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, next_callback);
} else {
next_callback();
}
}
function load_current() {
var next_callback = load_rx_config;
MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, next_callback);
}
function load_rx_config() {
var next_callback = load_html;
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
@ -131,14 +147,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
//Update Analog/Battery Data
function load_analog() {
MSP.send_message(MSPCodes.MSP_ANALOG, false, false, function () {
$('input[name="batteryvoltage"]').val([ANALOG.voltage.toFixed(1)]);
$('input[name="batterycurrent"]').val([ANALOG.amperage.toFixed(2)]);
});
}
function load_html() {
$('#content').load("./tabs/configuration.html", process_html);
}
@ -158,17 +166,17 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
mixer_list_e.change(function () {
var val = parseInt($(this).val());
BF_CONFIG.mixerConfiguration = val;
MIXER_CONFIG.mixer = val;
$('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[val - 1].image + '.svg');
});
// select current mixer configuration
mixer_list_e.val(BF_CONFIG.mixerConfiguration).change();
mixer_list_e.val(MIXER_CONFIG.mixer).change();
var features_e = $('.tab-configuration .features');
BF_CONFIG.features.generateElements(features_e);
FEATURE_CONFIG.features.generateElements(features_e);
// translate to user-selected language
localize();
@ -209,11 +217,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
'MULTISHOT'
];
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
escprotocols.push('BRUSHED');
}
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
escprotocols.push('DSHOT150');
escprotocols.push('DSHOT300');
escprotocols.push('DSHOT600');
@ -343,17 +351,17 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('input[id="magHardwareSwitch"]').prop('checked', SENSOR_CONFIG.mag_hardware !== 1);
// Only show these sections for supported FW
if (semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
if (semver.lt(CONFIG.apiVersion, "1.16.0")) {
$('.selectProtocol').hide();
$('.checkboxPwm').hide();
$('.selectPidProcessDenom').hide();
}
if (semver.lt(CONFIG.flightControllerVersion, "2.8.2")) {
if (semver.lt(CONFIG.apiVersion, "1.16.0")) {
$('.hardwareSelection').hide();
}
$('input[name="vesselName"]').val(CONFIG.name);
$('input[name="craftName"]').val(CONFIG.name);
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
@ -362,7 +370,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('div.fpvCamAngleDegrees').hide();
}
if (semver.lt(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
$('.miscSettings').hide();
}
@ -395,11 +403,20 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
gps_protocol_e.change(function () {
MISC.gps_type = parseInt($(this).val());
GPS_CONFIG.provider = parseInt($(this).val());
});
gps_protocol_e.val(MISC.gps_type);
gps_protocol_e.val(GPS_CONFIG.provider);
$('input[name="gps_auto_baud"]').prop('checked', GPS_CONFIG.auto_baud == 1);
$('input[name="gps_auto_config"]').prop('checked', GPS_CONFIG.auto_config == 1);
if (semver.gte(CONFIG.apiVersion, "1.34.0")) {
$('.select.gps_auto_baud').show();
$('.select.gps_auto_config').show();
} else {
$('.select.gps_auto_baud').hide();
$('.select.gps_auto_config').hide();
}
var gps_baudrate_e = $('select.gps_baudrate');
for (var i = 0; i < gpsBaudRates.length; i++) {
@ -423,10 +440,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
gps_ubx_sbas_e.change(function () {
MISC.gps_ubx_sbas = parseInt($(this).val());
GPS_CONFIG.ublox_sbas = parseInt($(this).val());
});
gps_ubx_sbas_e.val(MISC.gps_ubx_sbas);
gps_ubx_sbas_e.val(GPS_CONFIG.ublox_sbas);
// generate serial RX
@ -444,11 +461,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
serialRXtypes.push('IBUS');
}
if (semver.gte(CONFIG.flightControllerVersion, "2.6.0")) {
if ((CONFIG.flightControllerIdentifier === 'BTFL' && semver.gte(CONFIG.flightControllerVersion, "2.6.0")) ||
(CONFIG.flightControllerIdentifier === 'CLFL' && semver.gte(CONFIG.apiVersion, "1.31.0"))) {
serialRXtypes.push('JETIEXBUS');
}
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
serialRXtypes.push('CRSF');
}
@ -460,6 +478,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
serialRXtypes.push('TARGET_CUSTOM');
}
if (semver.gte(CONFIG.apiVersion, "1.35.0")) {
serialRXtypes.push('TARGET_CUSTOM');
}
var serialRX_e = $('select.serialRX');
for (var i = 0; i < serialRXtypes.length; i++) {
serialRX_e.append('<option value="' + i + '">' + serialRXtypes[i] + '</option>');
@ -478,16 +500,16 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('#content').scrollTop((scrollPosition) ? scrollPosition : 0);
// fill board alignment
$('input[name="board_align_roll"]').val(BF_CONFIG.board_align_roll);
$('input[name="board_align_pitch"]').val(BF_CONFIG.board_align_pitch);
$('input[name="board_align_yaw"]').val(BF_CONFIG.board_align_yaw);
$('input[name="board_align_roll"]').val(BOARD_ALIGNMENT_CONFIG.roll);
$('input[name="board_align_pitch"]').val(BOARD_ALIGNMENT_CONFIG.pitch);
$('input[name="board_align_yaw"]').val(BOARD_ALIGNMENT_CONFIG.yaw);
// fill accel trims
$('input[name="roll"]').val(CONFIG.accelerometerTrims[1]);
$('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]);
// fill magnetometer
$('input[name="mag_declination"]').val(MISC.mag_declination.toFixed(2));
$('input[name="mag_declination"]').val(COMPASS_CONFIG.mag_declination.toFixed(2));
//fill motor disarm params and FC loop time
if(semver.gte(CONFIG.apiVersion, "1.8.0")) {
@ -499,75 +521,22 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
// fill throttle
$('input[name="minthrottle"]').val(MISC.minthrottle);
$('input[name="maxthrottle"]').val(MISC.maxthrottle);
$('input[name="mincommand"]').val(MISC.mincommand);
// fill battery
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
var batteryMeterTypes = [
'Onboard ADC',
'ESC Sensor'
];
var batteryMeterType_e = $('select.batterymetertype');
for (i = 0; i < batteryMeterTypes.length; i++) {
batteryMeterType_e.append('<option value="' + i + '">' + batteryMeterTypes[i] + '</option>');
}
batteryMeterType_e.change(function () {
MISC.batterymetertype = parseInt($(this).val());
checkUpdateVbatControls();
});
batteryMeterType_e.val(MISC.batterymetertype).change();
} else {
$('div.batterymetertype').hide();
}
$('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage);
$('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage);
$('input[name="warningcellvoltage"]').val(MISC.vbatwarningcellvoltage);
$('input[name="voltagescale"]').val(MISC.vbatscale);
// fill current
var currentMeterTypes = [
'None',
'Onboard ADC',
'Virtual'
];
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
currentMeterTypes.push('ESC Sensor');
}
var currentMeterType_e = $('select.currentmetertype');
for (i = 0; i < currentMeterTypes.length; i++) {
currentMeterType_e.append('<option value="' + i + '">' + currentMeterTypes[i] + '</option>');
}
currentMeterType_e.change(function () {
BF_CONFIG.currentmetertype = parseInt($(this).val());
checkUpdateCurrentControls();
});
currentMeterType_e.val(BF_CONFIG.currentmetertype).change();
$('input[name="currentscale"]').val(BF_CONFIG.currentscale);
$('input[name="currentoffset"]').val(BF_CONFIG.currentoffset);
$('input[name="multiwiicurrentoutput"]').prop('checked', MISC.multiwiicurrentoutput !== 0);
$('input[name="minthrottle"]').val(MOTOR_CONFIG.minthrottle);
$('input[name="maxthrottle"]').val(MOTOR_CONFIG.maxthrottle);
$('input[name="mincommand"]').val(MOTOR_CONFIG.mincommand);
//fill 3D
if (semver.lt(CONFIG.apiVersion, "1.14.0")) {
$('.tab-configuration ._3d').hide();
} else {
$('input[name="3ddeadbandlow"]').val(_3D.deadband3d_low);
$('input[name="3ddeadbandhigh"]').val(_3D.deadband3d_high);
$('input[name="3dneutral"]').val(_3D.neutral3d);
$('input[name="3ddeadbandthrottle"]').val(_3D.deadband3d_throttle);
$('input[name="3ddeadbandlow"]').val(MOTOR_3D_CONFIG.deadband3d_low);
$('input[name="3ddeadbandhigh"]').val(MOTOR_3D_CONFIG.deadband3d_high);
$('input[name="3dneutral"]').val(MOTOR_3D_CONFIG.neutral);
}
// UI hooks
function checkShowDisarmDelay() {
if (BF_CONFIG.features.isEnabled('MOTOR_STOP')) {
if (FEATURE_CONFIG.features.isEnabled('MOTOR_STOP')) {
$('div.disarmdelay').show();
} else {
$('div.disarmdelay').hide();
@ -575,55 +544,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function checkShowSerialRxBox() {
if (BF_CONFIG.features.isEnabled('RX_SERIAL')) {
if (FEATURE_CONFIG.features.isEnabled('RX_SERIAL')) {
$('div.serialRXBox').show();
} else {
$('div.serialRXBox').hide();
}
}
function checkUpdateVbatControls() {
if (BF_CONFIG.features.isEnabled('VBAT')) {
$('.vbatmonitoring').show();
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
$('select.batterymetertype').show();
if (MISC.batterymetertype !== 0) {
$('.vbatCalibration').hide();
}
} else {
$('select.batterymetertype').hide();
}
} else {
$('.vbatmonitoring').hide();
}
}
function checkUpdateCurrentControls() {
if (BF_CONFIG.features.isEnabled('CURRENT_METER')) {
$('.currentMonitoring').show();
switch(BF_CONFIG.currentmetertype) {
case 0:
$('.currentCalibration').hide();
$('.currentOutput').hide();
break;
case 3:
$('.currentCalibration').hide();
}
if (BF_CONFIG.currentmetertype !== 1 && BF_CONFIG.currentmetertype !== 2) {
$('.currentCalibration').hide();
}
} else {
$('.currentMonitoring').hide();
}
}
function checkUpdateGpsControls() {
if (BF_CONFIG.features.isEnabled('GPS')) {
if (FEATURE_CONFIG.features.isEnabled('GPS')) {
$('.gpsSettings').show();
} else {
$('.gpsSettings').hide();
@ -631,7 +560,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function checkUpdate3dControls() {
if (BF_CONFIG.features.isEnabled('3D')) {
if (FEATURE_CONFIG.features.isEnabled('3D')) {
$('._3dSettings').show();
} else {
$('._3dSettings').hide();
@ -641,30 +570,22 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('input.feature', features_e).change(function () {
var element = $(this);
BF_CONFIG.features.updateData(element);
updateTabList(BF_CONFIG.features);
FEATURE_CONFIG.features.updateData(element);
updateTabList(FEATURE_CONFIG.features);
switch (element.attr('name')) {
case 'MOTOR_STOP':
checkShowDisarmDelay();
break;
case 'VBAT':
checkUpdateVbatControls();
break;
case 'CURRENT_METER':
checkUpdateCurrentControls();
break;
case 'GPS':
checkUpdateGpsControls();
break;
case '3D':
checkUpdate3dControls();
break;
default:
break;
}
@ -673,8 +594,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$(features_e).filter('select').change(function () {
var element = $(this);
BF_CONFIG.features.updateData(element);
updateTabList(BF_CONFIG.features);
FEATURE_CONFIG.features.updateData(element);
updateTabList(FEATURE_CONFIG.features);
switch (element.attr('name')) {
case 'rxMode':
@ -688,8 +609,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
checkShowDisarmDelay();
checkShowSerialRxBox();
checkUpdateVbatControls();
checkUpdateCurrentControls();
checkUpdateGpsControls();
checkUpdate3dControls();
@ -703,13 +622,13 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('a.save').click(function () {
// gather data that doesn't have automatic change event bound
BF_CONFIG.board_align_roll = parseInt($('input[name="board_align_roll"]').val());
BF_CONFIG.board_align_pitch = parseInt($('input[name="board_align_pitch"]').val());
BF_CONFIG.board_align_yaw = parseInt($('input[name="board_align_yaw"]').val());
BOARD_ALIGNMENT_CONFIG.roll = parseInt($('input[name="board_align_roll"]').val());
BOARD_ALIGNMENT_CONFIG.pitch = parseInt($('input[name="board_align_pitch"]').val());
BOARD_ALIGNMENT_CONFIG.yaw = parseInt($('input[name="board_align_yaw"]').val());
CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val());
CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());
MISC.mag_declination = parseFloat($('input[name="mag_declination"]').val());
COMPASS_CONFIG.mag_declination = parseFloat($('input[name="mag_declination"]').val());
// motor disarm
if(semver.gte(CONFIG.apiVersion, "1.8.0")) {
@ -717,24 +636,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
ARMING_CONFIG.disarm_kill_switch = $('input[id="disarmkillswitch"]').is(':checked') ? 1 : 0;
}
MISC.minthrottle = parseInt($('input[name="minthrottle"]').val());
MISC.maxthrottle = parseInt($('input[name="maxthrottle"]').val());
MISC.mincommand = parseInt($('input[name="mincommand"]').val());
MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val());
MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val());
MISC.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val());
MISC.vbatscale = parseInt($('input[name="voltagescale"]').val());
BF_CONFIG.currentscale = parseInt($('input[name="currentscale"]').val());
BF_CONFIG.currentoffset = parseInt($('input[name="currentoffset"]').val());
MISC.multiwiicurrentoutput = $('input[name="multiwiicurrentoutput"]').is(':checked') ? 1 : 0;
MOTOR_CONFIG.minthrottle = parseInt($('input[name="minthrottle"]').val());
MOTOR_CONFIG.maxthrottle = parseInt($('input[name="maxthrottle"]').val());
MOTOR_CONFIG.mincommand = parseInt($('input[name="mincommand"]').val());
if(semver.gte(CONFIG.apiVersion, "1.14.0")) {
_3D.deadband3d_low = parseInt($('input[name="3ddeadbandlow"]').val());
_3D.deadband3d_high = parseInt($('input[name="3ddeadbandhigh"]').val());
_3D.neutral3d = parseInt($('input[name="3dneutral"]').val());
_3D.deadband3d_throttle = ($('input[name="3ddeadbandthrottle"]').val());
MOTOR_3D_CONFIG.deadband3d_low = parseInt($('input[name="3ddeadbandlow"]').val());
MOTOR_3D_CONFIG.deadband3d_high = parseInt($('input[name="3ddeadbandhigh"]').val());
MOTOR_3D_CONFIG.neutral = parseInt($('input[name="3dneutral"]').val());
}
SENSOR_ALIGNMENT.align_gyro = parseInt(orientation_gyro_e.val());
@ -756,111 +665,113 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_serial_config() {
if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
MSP.send_message(MSPCodes.MSP_SET_CF_SERIAL_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CF_SERIAL_CONFIG), false, save_misc);
} else {
save_misc();
}
var next_callback = save_feature_config;
MSP.send_message(MSPCodes.MSP_SET_CF_SERIAL_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CF_SERIAL_CONFIG), false, next_callback);
}
function save_feature_config() {
var next_callback = save_misc;
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, next_callback);
}
function save_misc() {
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, save_3d);
}
function save_3d() {
var next_callback = save_rc_deadband;
if(semver.gte(CONFIG.apiVersion, "1.14.0")) {
MSP.send_message(MSPCodes.MSP_SET_3D, mspHelper.crunch(MSPCodes.MSP_SET_3D), false, next_callback);
var next_callback = save_mixer_config;
if(semver.lt(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, next_callback);
} else {
next_callback();
}
}
function save_mixer_config() {
var next_callback = save_board_alignment_config;
MSP.send_message(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG), false, next_callback);
}
function save_board_alignment_config() {
var next_callback = save_motor_config;
MSP.send_message(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG), false, next_callback);
}
function save_motor_config() {
var next_callback = save_gps_config;
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_SET_MOTOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_gps_config() {
if (semver.gte(CONFIG.apiVersion, "1.34.0")) {
GPS_CONFIG.auto_baud = $('input[name="gps_auto_baud"]').is(':checked') ? 1 : 0;
GPS_CONFIG.auto_config = $('input[name="gps_auto_config"]').is(':checked') ? 1 : 0;
}
var next_callback = save_compass_config;
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_compass_config() {
var next_callback = save_motor_3d_config;
if(semver.gte(CONFIG.apiVersion, "1.33.0")) {
MSP.send_message(MSPCodes.MSP_SET_COMPASS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_COMPASS_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_motor_3d_config() {
var next_callback = save_rc_deadband;
MSP.send_message(MSPCodes.MSP_SET_MOTOR_3D_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_3D_CONFIG), false, next_callback);
}
function save_rc_deadband() {
var next_callback = save_sensor_alignment;
if(semver.gte(CONFIG.apiVersion, "1.17.0")) {
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, next_callback);
} else {
next_callback();
}
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, next_callback);
}
function save_sensor_alignment() {
var next_callback = save_esc_protocol;
if(semver.gte(CONFIG.apiVersion, "1.15.0")) {
MSP.send_message(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT), false, next_callback);
} else {
next_callback();
}
MSP.send_message(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT), false, next_callback);
}
function save_esc_protocol() {
var next_callback = save_acc_trim;
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, next_callback);
} else {
next_callback();
}
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, next_callback);
}
function save_acc_trim() {
MSP.send_message(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM), false
, semver.gte(CONFIG.apiVersion, "1.8.0") ? save_arming_config : save_to_eeprom);
var next_callback = save_arming_config;
MSP.send_message(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM), false, next_callback);
}
function save_arming_config() {
MSP.send_message(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG), false, save_looptime_config);
MSP.send_message(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG), false, save_sensor_config);
}
function save_looptime_config() {
var next_callback = save_sensor_config;
if (semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
FC_CONFIG.loopTime = PID_ADVANCED_CONFIG.gyro_sync_denom * 125;
MSP.send_message(MSPCodes.MSP_SET_LOOP_TIME, mspHelper.crunch(MSPCodes.MSP_SET_LOOP_TIME), false, next_callback);
} else {
next_callback();
}
}
function save_sensor_config() {
SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1;
SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1;
var next_callback = save_name;
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1;
SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1;
MSP.send_message(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG), false, next_callback);
} else {
next_callback();
}
MSP.send_message(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG), false, next_callback);
}
function save_name() {
var next_callback = save_battery;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
CONFIG.name = $.trim($('input[name="vesselName"]').val());
MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, next_callback);
} else {
next_callback();
}
}
function save_battery() {
var next_callback = save_current;
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_current() {
var next_callback = save_rx_config;
MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CURRENT_METER_CONFIG), false, next_callback);
CONFIG.name = $.trim($('input[name="craftName"]').val());
MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, next_callback);
}
function save_rx_config() {
var next_callback = save_to_eeprom;
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
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();
@ -897,16 +808,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
},1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
}
}
MSP.send_message(MSPCodes.MSP_SET_BF_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BF_CONFIG), false, save_serial_config);
save_serial_config();
});
// status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
}, 250, true);
GUI.interval_add('config_load_analog', load_analog, 250, true); // 4 fps
GUI.content_ready(callback);
}
};

View file

@ -4,37 +4,14 @@
<div class="cf_doc_version_bt">
<a id="button-documentation" href="https://github.com/betaflight/betaflight/releases" target="_blank"></a>
</div>
<div class="note newpane">
<div class="note">
<div class="note_spacer">
<p i18n="failsafeFeaturesHelpNew"></p>
</p>
</div>
</div>
<div class="note oldpane">
<div class="note_spacer">
<p i18n="failsafeFeaturesHelpOld"></p>
</p>
</div>
</div>
<div class="leftWrapper">
<div class="gui_box grey oldpane">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="failsafePaneTitleOld"></div>
</div>
<div class="spacer_box">
<table>
<tbody class="featuresOld rxFailsafe">
<!-- table generated here -->
</tbody>
</table>
<div class="number">
<label> <input type="number" name="failsafe_throttle_old" min="0" max="2000" /> <span
i18n="failsafeThrottleItemOld"></span>
</label>
</div>
</div>
</div>
<div class="gui_box grey newpane">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="failsafePulsrangeTitle"></div>
<div class="helpicon cf_tip" i18n_title="failsafePulsrangeHelp"></div>
@ -52,7 +29,7 @@
</div>
</div>
</div>
<div class="gui_box grey stage1 newpane">
<div class="gui_box grey stage1">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="failsafeChannelFallbackSettingsTitle"></div>
<div class="helpicon cf_tip" i18n_title="failsafeChannelFallbackSettingsHelp"></div>
@ -65,7 +42,7 @@
</div>
</div>
<div class="rightWrapper">
<div class="gui_box grey newpane">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="failsafeStageTwoSettingsTitle"></div>
</div>

View file

@ -34,33 +34,31 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
}
function get_rc_data() {
MSP.send_message(MSPCodes.MSP_RC, false, false, load_config);
MSP.send_message(MSPCodes.MSP_RC, false, false, load_feature_config);
}
// BEGIN Support for pre API version 1.15.0
function load_config() {
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, load_misc);
function load_feature_config() {
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, load_motor_config);
}
function load_misc() {
MSP.send_message(MSPCodes.MSP_MISC, false, false, load_html);
function load_motor_config() {
MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, load_compass_config);
}
function load_compass_config() {
MSP.send_message(MSPCodes.MSP_COMPASS_CONFIG, false, false, load_gps_config);
}
function load_gps_config() {
MSP.send_message(MSPCodes.MSP_GPS_CONFIG, false, false, load_html);
}
// END (Support for pre API version 1.15.0
function load_html() {
$('#content').load("./tabs/failsafe.html", process_html);
}
var apiVersionGte1_15_0 = semver.gte(CONFIG.apiVersion, "1.15.0");
// Uncomment next line for testing older functionality on newer API version
//apiVersionGte1_15_0 = false;
if(apiVersionGte1_15_0) {
load_rx_config();
} else {
load_config();
}
load_rx_config();
function process_html() {
// fill stage 2 fields
@ -72,244 +70,221 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
}
}
// Conditionally hide the old or the new control pane's
if(apiVersionGte1_15_0) {
var oldPane = $('div.oldpane');
oldPane.prop("disabled", true);
oldPane.hide();
} else {
var newPane = $('div.newpane');
newPane.prop("disabled", true);
newPane.hide();
// FIXME cleanup oldpane html and css
var oldPane = $('div.oldpane');
oldPane.prop("disabled", true);
oldPane.hide();
// generate labels for assigned aux modes
var auxAssignment = [],
i,
element;
for (var channelIndex = 0; channelIndex < RC.active_channels - 4; channelIndex++) {
auxAssignment.push("");
}
if (apiVersionGte1_15_0) {
// generate labels for assigned aux modes
var auxAssignment = [],
i,
element;
for (var modeIndex = 0; modeIndex < AUX_CONFIG.length; modeIndex++) {
for (var channelIndex = 0; channelIndex < RC.active_channels - 4; channelIndex++) {
auxAssignment.push("");
}
var modeId = AUX_CONFIG_IDS[modeIndex];
for (var modeIndex = 0; modeIndex < AUX_CONFIG.length; modeIndex++) {
// scan mode ranges to find assignments
for (var modeRangeIndex = 0; modeRangeIndex < MODE_RANGES.length; modeRangeIndex++) {
var modeRange = MODE_RANGES[modeRangeIndex];
var modeId = AUX_CONFIG_IDS[modeIndex];
// scan mode ranges to find assignments
for (var modeRangeIndex = 0; modeRangeIndex < MODE_RANGES.length; modeRangeIndex++) {
var modeRange = MODE_RANGES[modeRangeIndex];
if (modeRange.id != modeId) {
continue;
}
var range = modeRange.range;
if (!(range.start < range.end)) {
continue; // invalid!
}
auxAssignment[modeRange.auxChannelIndex] += "<span class=\"modename\">" + AUX_CONFIG[modeIndex] + "</span>";
if (modeRange.id != modeId) {
continue;
}
}
// generate full channel list
var channelNames = [
chrome.i18n.getMessage('controlAxisRoll'),
chrome.i18n.getMessage('controlAxisPitch'),
chrome.i18n.getMessage('controlAxisYaw'),
chrome.i18n.getMessage('controlAxisThrottle')
],
fullChannels_e = $('div.activechannellist'),
aux_index = 1,
aux_assignment_index = 0;
for (i = 0; i < RXFAIL_CONFIG.length; i++) {
if (i < channelNames.length) {
fullChannels_e.append('\
<div class="number">\
<div class="channelprimary">\
<span>' + channelNames[i] + '</span>\
</div>\
<div class="cf_tip channelsetting" title="' + chrome.i18n.getMessage("failsafeChannelFallbackSettingsAuto") + '">\
<select class="aux_set" id="' + i + '">\
<option value="0">Auto</option>\
<option value="1">Hold</option>\
</select>\
</div>\
</div>\
');
} else {
fullChannels_e.append('\
<div class="number">\
<div class="channelauxiliary">\
<span class="channelname">' + chrome.i18n.getMessage("controlAxisAux" + (aux_index++)) + '</span>\
' + auxAssignment[aux_assignment_index++] + '\
</div>\
<div class="cf_tip channelsetting" title="' + chrome.i18n.getMessage("failsafeChannelFallbackSettingsHold") + '">\
<select class="aux_set" id="' + i + '">\
<option value="1">Hold</option>\
<option value="2">Set</option>\
</select>\
</div>\
<div class="auxiliary"><input type="number" name="aux_value" min="750" max="2250" id="' + i + '"/></div>\
</div>\
');
var range = modeRange.range;
if (!(range.start < range.end)) {
continue; // invalid!
}
auxAssignment[modeRange.auxChannelIndex] += "<span class=\"modename\">" + AUX_CONFIG[modeIndex] + "</span>";
}
var channel_mode_array = [];
$('.number', fullChannels_e).each(function () {
channel_mode_array.push($('select.aux_set' , this));
});
var channel_value_array = [];
$('.number', fullChannels_e).each(function () {
channel_value_array.push($('input[name="aux_value"]' , this));
});
var channelMode = $('select.aux_set');
var channelValue = $('input[name="aux_value"]');
// UI hooks
channelMode.change(function () {
var currentMode = parseInt($(this).val());
var i = parseInt($(this).prop("id"));
RXFAIL_CONFIG[i].mode = currentMode;
if (currentMode == 2) {
channel_value_array[i].prop("disabled", false);
channel_value_array[i].show();
} else {
channel_value_array[i].prop("disabled", true);
channel_value_array[i].hide();
}
});
// UI hooks
channelValue.change(function () {
var i = parseInt($(this).prop("id"));
RXFAIL_CONFIG[i].value = parseInt($(this).val());
});
// for some odd reason chrome 38+ changes scroll according to the touched select element
// i am guessing this is a bug, since this wasn't happening on 37
// code below is a temporary fix, which we will be able to remove in the future (hopefully)
$('#content').scrollTop((scrollPosition) ? scrollPosition : 0);
// fill stage 1 Valid Pulse Range Settings
$('input[name="rx_min_usec"]').val(RX_CONFIG.rx_min_usec);
$('input[name="rx_max_usec"]').val(RX_CONFIG.rx_max_usec);
// fill fallback settings (mode and value) for all channels
for (i = 0; i < RXFAIL_CONFIG.length; i++) {
channel_value_array[i].val(RXFAIL_CONFIG[i].value);
channel_mode_array[i].val(RXFAIL_CONFIG[i].mode);
channel_mode_array[i].change();
}
BF_CONFIG.features.generateElements($('.tab-failsafe .featuresNew'));
var failsafeFeature = $('input[name="FAILSAFE"]');
failsafeFeature.change(function () {
toggleStage2($(this).is(':checked'));
});
toggleStage2(BF_CONFIG.features.isEnabled('FAILSAFE'));
$('input[name="failsafe_throttle"]').val(FAILSAFE_CONFIG.failsafe_throttle);
$('input[name="failsafe_off_delay"]').val(FAILSAFE_CONFIG.failsafe_off_delay);
$('input[name="failsafe_throttle_low_delay"]').val(FAILSAFE_CONFIG.failsafe_throttle_low_delay);
$('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay);
// set stage 2 failsafe procedure
$('input[type="radio"].procedure').change(function () {
var element = $(this),
checked = element.is(':checked'),
id = element.attr('id');
switch(id) {
case 'drop':
if (checked) {
$('input[name="failsafe_throttle"]').prop("disabled", true);
$('input[name="failsafe_off_delay"]').prop("disabled", true);
}
break;
case 'land':
if (checked) {
$('input[name="failsafe_throttle"]').prop("disabled", false);
$('input[name="failsafe_off_delay"]').prop("disabled", false);
}
break;
}
});
switch(FAILSAFE_CONFIG.failsafe_procedure) {
default:
case 0:
element = $('input[id="land"]') ;
element.prop('checked', true);
element.change();
break;
case 1:
element = $('input[id="drop"]');
element.prop('checked', true);
element.change();
break;
}
// set stage 2 kill switch option
$('input[name="failsafe_kill_switch"]').prop('checked', FAILSAFE_CONFIG.failsafe_kill_switch);
} else {
BF_CONFIG.features.generateElements($('.tab-failsafe .featuresOld'));
// fill failsafe_throttle field (pre API 1.15.0)
$('input[name="failsafe_throttle_old"]').val(MISC.failsafe_throttle);
}
// generate full channel list
var channelNames = [
chrome.i18n.getMessage('controlAxisRoll'),
chrome.i18n.getMessage('controlAxisPitch'),
chrome.i18n.getMessage('controlAxisYaw'),
chrome.i18n.getMessage('controlAxisThrottle')
],
fullChannels_e = $('div.activechannellist'),
aux_index = 1,
aux_assignment_index = 0;
for (i = 0; i < RXFAIL_CONFIG.length; i++) {
if (i < channelNames.length) {
fullChannels_e.append('\
<div class="number">\
<div class="channelprimary">\
<span>' + channelNames[i] + '</span>\
</div>\
<div class="cf_tip channelsetting" title="' + chrome.i18n.getMessage("failsafeChannelFallbackSettingsAuto") + '">\
<select class="aux_set" id="' + i + '">\
<option value="0">Auto</option>\
<option value="1">Hold</option>\
</select>\
</div>\
</div>\
');
} else {
fullChannels_e.append('\
<div class="number">\
<div class="channelauxiliary">\
<span class="channelname">' + chrome.i18n.getMessage("controlAxisAux" + (aux_index++)) + '</span>\
' + auxAssignment[aux_assignment_index++] + '\
</div>\
<div class="cf_tip channelsetting" title="' + chrome.i18n.getMessage("failsafeChannelFallbackSettingsHold") + '">\
<select class="aux_set" id="' + i + '">\
<option value="1">Hold</option>\
<option value="2">Set</option>\
</select>\
</div>\
<div class="auxiliary"><input type="number" name="aux_value" min="750" max="2250" step="25" id="' + i + '"/></div>\
</div>\
');
}
}
var channel_mode_array = [];
$('.number', fullChannels_e).each(function () {
channel_mode_array.push($('select.aux_set' , this));
});
var channel_value_array = [];
$('.number', fullChannels_e).each(function () {
channel_value_array.push($('input[name="aux_value"]' , this));
});
var channelMode = $('select.aux_set');
var channelValue = $('input[name="aux_value"]');
// UI hooks
channelMode.change(function () {
var currentMode = parseInt($(this).val());
var i = parseInt($(this).prop("id"));
RXFAIL_CONFIG[i].mode = currentMode;
if (currentMode == 2) {
channel_value_array[i].prop("disabled", false);
channel_value_array[i].show();
} else {
channel_value_array[i].prop("disabled", true);
channel_value_array[i].hide();
}
});
// UI hooks
channelValue.change(function () {
var i = parseInt($(this).prop("id"));
RXFAIL_CONFIG[i].value = parseInt($(this).val());
});
// for some odd reason chrome 38+ changes scroll according to the touched select element
// i am guessing this is a bug, since this wasn't happening on 37
// code below is a temporary fix, which we will be able to remove in the future (hopefully)
$('#content').scrollTop((scrollPosition) ? scrollPosition : 0);
// fill stage 1 Valid Pulse Range Settings
$('input[name="rx_min_usec"]').val(RX_CONFIG.rx_min_usec);
$('input[name="rx_max_usec"]').val(RX_CONFIG.rx_max_usec);
// fill fallback settings (mode and value) for all channels
for (i = 0; i < RXFAIL_CONFIG.length; i++) {
channel_value_array[i].val(RXFAIL_CONFIG[i].value);
channel_mode_array[i].val(RXFAIL_CONFIG[i].mode);
channel_mode_array[i].change();
}
FEATURE_CONFIG.features.generateElements($('.tab-failsafe .featuresNew'));
var failsafeFeature = $('input[name="FAILSAFE"]');
failsafeFeature.change(function () {
toggleStage2($(this).is(':checked'));
});
toggleStage2(FEATURE_CONFIG.features.isEnabled('FAILSAFE'));
$('input[name="failsafe_throttle"]').val(FAILSAFE_CONFIG.failsafe_throttle);
$('input[name="failsafe_off_delay"]').val(FAILSAFE_CONFIG.failsafe_off_delay);
$('input[name="failsafe_throttle_low_delay"]').val(FAILSAFE_CONFIG.failsafe_throttle_low_delay);
$('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay);
// set stage 2 failsafe procedure
$('input[type="radio"].procedure').change(function () {
var element = $(this),
checked = element.is(':checked'),
id = element.attr('id');
switch(id) {
case 'drop':
if (checked) {
$('input[name="failsafe_throttle"]').prop("disabled", true);
$('input[name="failsafe_off_delay"]').prop("disabled", true);
}
break;
case 'land':
if (checked) {
$('input[name="failsafe_throttle"]').prop("disabled", false);
$('input[name="failsafe_off_delay"]').prop("disabled", false);
}
break;
}
});
switch(FAILSAFE_CONFIG.failsafe_procedure) {
default:
case 0:
element = $('input[id="land"]') ;
element.prop('checked', true);
element.change();
break;
case 1:
element = $('input[id="drop"]');
element.prop('checked', true);
element.change();
break;
}
// set stage 2 kill switch option
$('input[name="failsafe_kill_switch"]').prop('checked', FAILSAFE_CONFIG.failsafe_kill_switch);
$('a.save').click(function () {
// gather data that doesn't have automatic change event bound
BF_CONFIG.features.updateData($('input[name="FAILSAFE"]'));
FEATURE_CONFIG.features.updateData($('input[name="FAILSAFE"]'));
if(apiVersionGte1_15_0) {
RX_CONFIG.rx_min_usec = parseInt($('input[name="rx_min_usec"]').val());
RX_CONFIG.rx_max_usec = parseInt($('input[name="rx_max_usec"]').val());
RX_CONFIG.rx_min_usec = parseInt($('input[name="rx_min_usec"]').val());
RX_CONFIG.rx_max_usec = parseInt($('input[name="rx_max_usec"]').val());
FAILSAFE_CONFIG.failsafe_throttle = parseInt($('input[name="failsafe_throttle"]').val());
FAILSAFE_CONFIG.failsafe_off_delay = parseInt($('input[name="failsafe_off_delay"]').val());
FAILSAFE_CONFIG.failsafe_throttle_low_delay = parseInt($('input[name="failsafe_throttle_low_delay"]').val());
FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val());
FAILSAFE_CONFIG.failsafe_throttle = parseInt($('input[name="failsafe_throttle"]').val());
FAILSAFE_CONFIG.failsafe_off_delay = parseInt($('input[name="failsafe_off_delay"]').val());
FAILSAFE_CONFIG.failsafe_throttle_low_delay = parseInt($('input[name="failsafe_throttle_low_delay"]').val());
FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val());
if( $('input[id="land"]').is(':checked')) {
FAILSAFE_CONFIG.failsafe_procedure = 0;
} else if( $('input[id="drop"]').is(':checked')) {
FAILSAFE_CONFIG.failsafe_procedure = 1;
}
FAILSAFE_CONFIG.failsafe_kill_switch = $('input[name="failsafe_kill_switch"]').is(':checked') ? 1 : 0;
} else {
// get failsafe_throttle field value (pre API 1.15.0)
MISC.failsafe_throttle = parseInt($('input[name="failsafe_throttle_old"]').val());
if( $('input[id="land"]').is(':checked')) {
FAILSAFE_CONFIG.failsafe_procedure = 0;
} else if( $('input[id="drop"]').is(':checked')) {
FAILSAFE_CONFIG.failsafe_procedure = 1;
}
FAILSAFE_CONFIG.failsafe_kill_switch = $('input[name="failsafe_kill_switch"]').is(':checked') ? 1 : 0;
function save_failssafe_config() {
MSP.send_message(MSPCodes.MSP_SET_FAILSAFE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FAILSAFE_CONFIG), false, save_rxfail_config);
}
function save_rxfail_config() {
mspHelper.sendRxFailConfig(save_bf_config);
mspHelper.sendRxFailConfig(save_feature_config);
}
function save_bf_config() {
MSP.send_message(MSPCodes.MSP_SET_BF_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BF_CONFIG), false, save_to_eeprom);
function save_feature_config() {
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, save_to_eeprom);
}
// BEGIN pre API 1.15.0 save functions
function save_misc() {
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, save_to_eeprom);
}
// END pre API 1.15.0 save functions
function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot);
}
@ -341,11 +316,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
}
}
if(apiVersionGte1_15_0) {
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, save_failssafe_config);
} else {
MSP.send_message(MSPCodes.MSP_SET_BF_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BF_CONFIG), false, save_misc);
}
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, save_failssafe_config);
});
// translate to user-selected language

View file

@ -229,8 +229,18 @@ TABS.logging.initialize = function (callback) {
fileWriter = null;
function prepare_file() {
var prefix = 'log';
var suffix = 'csv';
var filename = generateFilename(prefix, suffix);
var accepts = [{
extensions: [suffix],
}];
// create or load the file
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: 'betaflight_data_log', accepts: [{extensions: ['csv']}]}, function(entry) {
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: filename, accepts: accepts}, function(entry) {
if (!entry) {
console.log('No file selected');
return;

View file

@ -12,40 +12,29 @@ TABS.motors.initialize = function (callback) {
self.armed = false;
self.feature3DSupported = false;
self.allowTestMode = true;
self.feature3DSupported = true;
if (GUI.active_tab != 'motors') {
GUI.active_tab = 'motors';
}
function get_arm_status() {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_config);
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_feature_config);
}
function load_config() {
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, load_3d);
function load_feature_config() {
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, load_motor_3d_config);
}
function load_3d() {
var next_callback = esc_protocol;
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 load_motor_3d_config() {
MSP.send_message(MSPCodes.MSP_MOTOR_3D_CONFIG, false, false, load_esc_protocol);
}
function esc_protocol() {
var next_callback = get_motor_data;
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, next_callback);
} else {
next_callback();
}
function load_esc_protocol() {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, load_motor_data);
}
function get_motor_data() {
update_arm_status();
function load_motor_data() {
MSP.send_message(MSPCodes.MSP_MOTOR, false, false, load_html);
}
@ -53,7 +42,7 @@ TABS.motors.initialize = function (callback) {
$('#content').load("./tabs/motors.html", process_html);
}
MSP.send_message(MSPCodes.MSP_MISC, false, false, get_arm_status);
MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, get_arm_status);
function update_arm_status() {
self.armed = bit_check(CONFIG.mode, 0);
@ -185,8 +174,10 @@ TABS.motors.initialize = function (callback) {
function process_html() {
// translate to user-selected language
localize();
update_arm_status();
self.feature3DEnabled = BF_CONFIG.features.isEnabled('3D');
self.feature3DEnabled = FEATURE_CONFIG.features.isEnabled('3D');
if (self.feature3DEnabled && !self.feature3DSupported) {
self.allowTestMode = false;
@ -201,7 +192,7 @@ TABS.motors.initialize = function (callback) {
$('#motorsEnableTestMode').prop('checked', false)
.prop('disabled', true);
update_model(BF_CONFIG.mixerConfiguration);
update_model(MIXER_CONFIG.mixer);
// Always start with default/empty sensor data array, clean slate all
initSensorData();
@ -330,19 +321,19 @@ TABS.motors.initialize = function (callback) {
');
}
$('div.sliders input').prop('min', MISC.mincommand)
.prop('max', MISC.maxthrottle);
$('div.values li:not(:last)').text(MISC.mincommand);
$('div.sliders input').prop('min', MOTOR_CONFIG.mincommand)
.prop('max', MOTOR_CONFIG.maxthrottle);
$('div.values li:not(:last)').text(MOTOR_CONFIG.mincommand);
if(self.feature3DEnabled && self.feature3DSupported) {
//Arbitrary sanity checks
//Note: values may need to be revisited
if(_3D.neutral3d > 1575 || _3D.neutral3d < 1425)
_3D.neutral3d = 1500;
if(MOTOR_3D_CONFIG.neutral > 1575 || MOTOR_3D_CONFIG.neutral < 1425)
MOTOR_3D_CONFIG.neutral = 1500;
$('div.sliders input').val(_3D.neutral3d);
$('div.sliders input').val(MOTOR_3D_CONFIG.neutral);
} else {
$('div.sliders input').val(MISC.mincommand);
$('div.sliders input').val(MOTOR_CONFIG.mincommand);
}
if(self.allowTestMode){
@ -397,9 +388,9 @@ TABS.motors.initialize = function (callback) {
// change all values to default
if (self.feature3DEnabled && self.feature3DSupported) {
$('div.sliders input').val(_3D.neutral3d);
$('div.sliders input').val(MOTOR_3D_CONFIG.neutral);
} else {
$('div.sliders input').val(MISC.mincommand);
$('div.sliders input').val(MOTOR_CONFIG.mincommand);
}
$('div.sliders input').trigger('input');
@ -411,11 +402,11 @@ TABS.motors.initialize = function (callback) {
for (var i = 0; i < number_of_valid_outputs; i++) {
if (!self.feature3DEnabled) {
if (MOTOR_DATA[i] > MISC.mincommand) {
if (MOTOR_DATA[i] > MOTOR_CONFIG.mincommand) {
motors_running = true;
}
} else {
if ((MOTOR_DATA[i] < _3D.deadband3d_low) || (MOTOR_DATA[i] > _3D.deadband3d_high)) {
if ((MOTOR_DATA[i] < MOTOR_3D_CONFIG.deadband3d_low) || (MOTOR_DATA[i] > MOTOR_3D_CONFIG.deadband3d_high)) {
motors_running = true;
}
}
@ -473,8 +464,8 @@ TABS.motors.initialize = function (callback) {
full_block_scale = 1000;
motorOffset = 1000;
} else {
full_block_scale = MISC.maxthrottle - MISC.mincommand;
motorOffset = MISC.mincommand;
full_block_scale = MOTOR_CONFIG.maxthrottle - MOTOR_CONFIG.mincommand;
motorOffset = MOTOR_CONFIG.mincommand;
}
function update_ui() {

View file

@ -4,7 +4,6 @@ var
sdcardTimer;
TABS.onboard_logging = {
available: false,
blockSize: 128,
BLOCK_SIZE: 4096,
@ -21,39 +20,17 @@ TABS.onboard_logging.initialize = function (callback) {
}
if (CONFIGURATOR.connectionValid) {
// Blackbox was introduced in 1.5.0, dataflash API was introduced in 1.8.0, BLACKBOX/SDCARD MSP APIs in 1.11.0
TABS.onboard_logging.available = semver.gte(CONFIG.flightControllerVersion, "1.5.0");
if (!TABS.onboard_logging.available) {
load_html();
return;
}
var load_name = function () {
var next_callback = load_html;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
MSP.send_message(MSPCodes.MSP_NAME, false, false, next_callback);
} else {
next_callback();
}
};
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, function() {
if (semver.gte(CONFIG.flightControllerVersion, "1.8.0")) {
MSP.send_message(MSPCodes.MSP_DATAFLASH_SUMMARY, false, false, function() {
if (semver.gte(CONFIG.flightControllerVersion, "1.11.0")) {
MSP.send_message(MSPCodes.MSP_SDCARD_SUMMARY, false, false, function() {
MSP.send_message(MSPCodes.MSP_BLACKBOX_CONFIG, false, false, function() {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, load_name);
});
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, function() {
MSP.send_message(MSPCodes.MSP_DATAFLASH_SUMMARY, false, false, function() {
MSP.send_message(MSPCodes.MSP_SDCARD_SUMMARY, false, false, function() {
MSP.send_message(MSPCodes.MSP_BLACKBOX_CONFIG, false, false, function() {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, function() {
MSP.send_message(MSPCodes.MSP_NAME, false, false, load_html);
});
} else {
load_html();
}
});
});
} else {
load_html();
}
});
});
}
@ -109,11 +86,8 @@ TABS.onboard_logging.initialize = function (callback) {
*
* The best we can do on those targets is check the BLACKBOX feature bit to identify support for Blackbox instead.
*/
if (BLACKBOX.supported || DATAFLASH.supported
|| semver.gte(CONFIG.flightControllerVersion, "1.5.0") && semver.lte(CONFIG.flightControllerVersion, "1.10.0") && BF_CONFIG.features.isEnabled('BLACKBOX')) {
if ((BLACKBOX.supported || DATAFLASH.supported) && (semver.gte(CONFIG.apiVersion, "1.33.0") || FEATURE_CONFIG.features.isEnabled('BLACKBOX'))) {
blackboxSupport = 'yes';
} else if (semver.gte(CONFIG.flightControllerVersion, "1.5.0") && semver.lte(CONFIG.flightControllerVersion, "1.10.0")) {
blackboxSupport = 'maybe';
} else {
blackboxSupport = 'no';
}
@ -175,15 +149,25 @@ TABS.onboard_logging.initialize = function (callback) {
function populateDevices(deviceSelect) {
deviceSelect.empty();
deviceSelect.append('<option value="0">' + chrome.i18n.getMessage('blackboxLoggingNone') + '</option>');
if (DATAFLASH.ready) {
deviceSelect.append('<option value="1">' + chrome.i18n.getMessage('blackboxLoggingFlash') + '</option>');
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
deviceSelect.append('<option value="0">' + chrome.i18n.getMessage('blackboxLoggingNone') + '</option>');
if (DATAFLASH.ready) {
deviceSelect.append('<option value="1">' + chrome.i18n.getMessage('blackboxLoggingFlash') + '</option>');
}
if (SDCARD.supported) {
deviceSelect.append('<option value="2">' + chrome.i18n.getMessage('blackboxLoggingSdCard') + '</option>');
}
deviceSelect.append('<option value="3">' + chrome.i18n.getMessage('blackboxLoggingSerial') + '</option>');
} else {
deviceSelect.append('<option value="0">' + chrome.i18n.getMessage('blackboxLoggingSerial') + '</option>');
if (DATAFLASH.ready) {
deviceSelect.append('<option value="1">' + chrome.i18n.getMessage('blackboxLoggingFlash') + '</option>');
}
if (SDCARD.supported) {
deviceSelect.append('<option value="2">' + chrome.i18n.getMessage('blackboxLoggingSdCard') + '</option>');
}
}
if (SDCARD.supported) {
deviceSelect.append('<option value="2">' + chrome.i18n.getMessage('blackboxLoggingSdCard') + '</option>');
}
deviceSelect.append('<option value="3">' + chrome.i18n.getMessage('blackboxLoggingSerial') + '</option>');
deviceSelect.val(BLACKBOX.blackboxDevice);
}
@ -348,7 +332,7 @@ TABS.onboard_logging.initialize = function (callback) {
function flash_save_begin() {
if (GUI.connected_to) {
if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) {
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
self.blockSize = self.VCP_BLOCK_SIZE;
} else {
self.blockSize = self.VCP_BLOCK_SIZE_3_0;
@ -408,8 +392,9 @@ TABS.onboard_logging.initialize = function (callback) {
}
function prepare_file(onComplete) {
var suffix = 'BFL';
var prefix = 'BLACKBOX_LOG';
var suffix = 'BBL';
var filename = generateFilename(prefix, suffix);

View file

@ -11,7 +11,7 @@
<p class="note">Note that some flight controllers have an onboard <a href="https://www.youtube.com/watch?v=ikKH_6SQ-Tk" target="_blank">MinimOSD</a> that can be flashed and configured with <a href="https://github.com/ShikOfTheRa/scarab-osd/releases/latest" target="_blank">scarab-osd</a>, however the MinimOSD cannot be configured through this interface.</p>
</div>
<div class="supported hide">
<div class="cf_column third_left elements">
<div class="cf_column third_left elements requires-osd-feature">
<div class="spacer_right">
<div class="gui_box grey">
<div
@ -28,7 +28,7 @@
</div>
</div>
<div class="cf_column twothird">
<div class="gui_box grey preview" style="float: left;">
<div class="gui_box grey preview requires-osd-feature" style="float: left;">
<div class="gui_box_titlebar image">
<div class="spacer_box_title">
Preview <span>(drag to change position)</span><span class="preview-logo cf_tip" title="Show or hide the logo in the preview window. This will not change any settings on the flight controller."></span>
@ -42,7 +42,7 @@
</div>
</div>
<div class="cf_column third_right" style="width: calc(100% - 377px);">
<div class="gui_box grey">
<div class="gui_box grey requires-max7456">
<div class="gui_box_titlebar">
<div class="spacer_box_title">Video
Format
@ -52,7 +52,7 @@
<div class="video-types"></div>
</div>
</div>
<div class="gui_box grey units-container" style="display:none;">
<div class="gui_box grey units-container requires-osd-feature" style="display:none;">
<div class="gui_box_titlebar">
<div class="spacer_box_title">Units
</div>
@ -61,7 +61,7 @@
<div class="units"></div>
</div>
</div>
<div class="gui_box grey alarms-container" style="display:none;">
<div class="gui_box grey alarms-container requires-osd-feature" style="display:none;">
<div class="gui_box_titlebar">
<div class="spacer_box_title">
Alarms
@ -117,10 +117,10 @@
</div>
</div>
<div class="content_toolbar supported hide" style="left:0;">
<div class="btn">
<div class="btn save">
<a class="active save" href="#" >Save</a>
</div>
<div class="btn">
<div class="btn requires-max7456">
<a class="fonts" id="fontmanager" href="#" >Font Manager</a>
</div>
</div>

View file

@ -25,6 +25,7 @@ SYM.PB_FULL = 0x8B;
SYM.PB_EMPTY = 0x8D;
SYM.PB_END = 0x8E;
SYM.PB_CLOSE = 0x8F;
SYM.BATTERY = 0x96;
var FONT = FONT || {};
@ -246,7 +247,7 @@ OSD.constants = {
name: 'MAIN_BATT_VOLTAGE',
default_position: -29,
positionable: true,
preview: FONT.symbol(SYM.VOLT) + '16.8'
preview: FONT.symbol(SYM.BATTERY) + '16.8' + FONT.symbol(SYM.VOLT)
},
RSSI_VALUE: {
name: 'RSSI_VALUE',
@ -276,7 +277,7 @@ OSD.constants = {
name: 'VTX_CHANNEL',
default_position: 1,
positionable: true,
preview: 'CH:1'
preview: 'R:2'
},
VOLTAGE_WARNING: {
name: 'VOLTAGE_WARNING',
@ -327,7 +328,7 @@ OSD.constants = {
name: 'CRAFT_NAME',
default_position: -77,
positionable: true,
preview: '[CRAFT_NAME]'
preview: 'CRAFT_NAME'
},
ALTITUDE: {
name: 'ALTITUDE',
@ -341,13 +342,13 @@ OSD.constants = {
name: 'ONTIME',
default_position: -1,
positionable: true,
preview: FONT.symbol(SYM.ON_M) + ' 4:11'
preview: FONT.symbol(SYM.ON_M) + '05:42'
},
FLYTIME: {
name: 'FLYTIME',
default_position: -1,
positionable: true,
preview: FONT.symbol(SYM.FLY_M) + ' 4:11'
preview: FONT.symbol(SYM.FLY_M) + '04:11'
},
FLYMODE: {
name: 'FLYMODE',
@ -407,7 +408,7 @@ OSD.constants = {
name: 'AVG_CELL_VOLTAGE',
default_position: 12 << 5,
positionable: true,
preview: '3.98V'
preview: FONT.symbol(SYM.BATTERY) + '3.98' + FONT.symbol(SYM.VOLT)
},
PITCH_ANGLE: {
name: 'PITCH_ANGLE',
@ -434,7 +435,7 @@ OSD.constants = {
OSD.chooseFields = function () {
var F = OSD.constants.ALL_DISPLAY_FIELDS;
// version 3.0.1
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
OSD.constants.DISPLAY_FIELDS = [
F.RSSI_VALUE,
F.MAIN_BATT_VOLTAGE,
@ -453,7 +454,7 @@ OSD.chooseFields = function () {
F.GPS_SATS,
F.ALTITUDE
];
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
F.PID_ROLL,
F.PID_PITCH,
@ -530,7 +531,7 @@ OSD.msp = {
unpack: {
position: function(bits, c) {
var display_item = {};
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
// size * y + x
display_item.position = FONT.constants.SIZES.LINE * ((bits >> 5) & 0x001F) + (bits & 0x001F);
display_item.isVisible = (bits & OSD.constants.VISIBLE) != 0;
@ -545,7 +546,7 @@ OSD.msp = {
position: function(display_item) {
var isVisible = display_item.isVisible;
var position = display_item.position;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
return (isVisible ? 0x0800 : 0) | (((position / FONT.constants.SIZES.LINE) & 0x001F) << 5) | (position % FONT.constants.SIZES.LINE);
} else {
return isVisible ? (position == -1 ? 0 : position): -1;
@ -555,7 +556,7 @@ OSD.msp = {
},
encodeOther: function() {
var result = [-1, OSD.data.video_system];
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
if (OSD.data.state.haveOsdFeature && semver.gte(CONFIG.apiVersion, "1.21.0")) {
result.push8(OSD.data.unit_mode);
// watch out, order matters! match the firmware
result.push8(OSD.data.alarms.rssi.value);
@ -575,22 +576,34 @@ OSD.msp = {
decode: function(payload) {
var view = payload.data;
var d = OSD.data;
d.compiled_in = view.readU8();
d.video_system = view.readU8();
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
d.unit_mode = view.readU8();
d.alarms = {};
d.alarms['rssi'] = { display_name: 'Rssi', value: view.readU8() };
d.alarms['cap']= { display_name: 'Capacity', value: view.readU16() };
d.alarms['time'] = { display_name: 'Minutes', value: view.readU16() };
d.alarms['alt'] = { display_name: 'Altitude', value: view.readU16() };
d.flags = view.readU8();
if (d.flags > 0) {
if (payload.length > 1) {
d.video_system = view.readU8();
if (semver.gte(CONFIG.apiVersion, "1.21.0") && bit_check(d.flags, 0)) {
d.unit_mode = view.readU8();
d.alarms = {};
d.alarms['rssi'] = { display_name: 'Rssi', value: view.readU8() };
d.alarms['cap']= { display_name: 'Capacity', value: view.readU16() };
d.alarms['time'] = { display_name: 'Minutes', value: view.readU16() };
d.alarms['alt'] = { display_name: 'Altitude', value: view.readU16() };
}
}
}
d.state = {};
d.state.haveSomeOsd = (d.flags != 0)
d.state.haveMax7456Video = bit_check(d.flags, 4) || (d.flags == 1 && semver.lt(CONFIG.apiVersion, "1.34.0"));
d.state.haveOsdFeature = bit_check(d.flags, 0) || (d.flags == 1 && semver.lt(CONFIG.apiVersion, "1.34.0"));
d.state.isOsdSlave = bit_check(d.flags, 1) && semver.gte(CONFIG.apiVersion, "1.34.0");
d.display_items = [];
// start at the offset from the other fields
while (view.offset < view.byteLength && d.display_items.length < OSD.constants.DISPLAY_FIELDS.length) {
var v = null;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
v = view.readU16();
} else {
v = view.read16();
@ -644,7 +657,7 @@ OSD.GUI.preview = {
if (overflows_line < 0) {
position += overflows_line;
}
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
// unsigned now
} else {
if (position > OSD.data.display_size.total/2) {
@ -684,15 +697,17 @@ TABS.osd.initialize = function (callback) {
// ask for the OSD config data
MSP.promise(MSPCodes.MSP_OSD_CONFIG)
.then(function(info) {
OSD.chooseFields();
// fc responsed with short message: osd unsupported
if (info.length < 4) {
OSD.msp.decode(info);
if (OSD.data.state.haveSomeOsd == 0) {
$('.unsupported').fadeIn();
return;
}
$('.supported').fadeIn();
OSD.msp.decode(info);
// show Betaflight logo in preview
var $previewLogo = $('.preview-logo').empty();
$previewLogo.append(
@ -723,7 +738,7 @@ TABS.osd.initialize = function (callback) {
});
});
if (semver.gte(CONFIG.flightControllerVersion, "3.0.1")) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
// units
$('.units-container').show();
var $unitMode = $('.units').empty();
@ -761,6 +776,14 @@ TABS.osd.initialize = function (callback) {
$alarms.append($input);
}
}
if (!OSD.data.state.haveMax7456Video) {
$('.requires-max7456').hide();
}
if (!OSD.data.state.haveOsdFeature) {
$('.requires-osd-feature').hide();
}
// display fields on/off and position
var $displayFields = $('.display-fields').empty();

View file

@ -26,7 +26,7 @@ TABS.pid_tuning.initialize = function (callback) {
}).then(function() {
return MSP.promise(MSPCodes.MSP_PID);
}).then(function() {
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
return MSP.promise(MSPCodes.MSP_PID_ADVANCED);
}
}).then(function() {
@ -34,26 +34,14 @@ TABS.pid_tuning.initialize = function (callback) {
}).then(function() {
return MSP.promise(MSPCodes.MSP_FILTER_CONFIG);
}).then(function() {
var promise = true;
if (CONFIG.flightControllerIdentifier === "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.0")) {
promise = MSP.promise(MSPCodes.MSP_BF_CONFIG);
}
return promise;
}).then(function() {
var promise = true;
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
promise = MSP.promise(MSPCodes.MSP_RC_DEADBAND);
}
return promise;
return MSP.promise(MSPCodes.MSP_RC_DEADBAND);
}).then(function() {
$('#content').load("./tabs/pid_tuning.html", process_html);
});
function pid_and_rc_to_form() {
self.setProfile();
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
self.setRateProfile();
}
@ -216,15 +204,15 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_tuning input[name="rc_expo"]').attr("rowspan", "3");
}
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
$('input[id="vbatpidcompensation"]').prop('checked', ADVANCED_TUNING.vbatPidCompensation !== 0);
}
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
$('#pid-tuning .delta select').val(ADVANCED_TUNING.deltaMethod);
}
if (semver.gte(CONFIG.flightControllerVersion, '2.9.0')) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
$('.pid_tuning input[name="rc_rate_yaw"]').val(RC_tuning.rcYawRate.toFixed(2));
$('.pid_filter input[name="gyroLowpassFrequency"]').val(FILTER_CONFIG.gyro_soft_lpf_hz);
$('.pid_filter input[name="dtermLowpassFrequency"]').val(FILTER_CONFIG.dterm_lpf_hz);
@ -235,14 +223,14 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_tuning input[name="rc_rate_yaw"]').hide();
}
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")
|| semver.gte(CONFIG.flightControllerVersion, "2.8.0") && BF_CONFIG.features.isEnabled('SUPEREXPO_RATES')) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")
|| semver.gte(CONFIG.apiVersion, "1.16.0") && FEATURE_CONFIG.features.isEnabled('SUPEREXPO_RATES')) {
$('#pid-tuning .rate').text(chrome.i18n.getMessage("pidTuningSuperRate"));
} else {
$('#pid-tuning .rate').text(chrome.i18n.getMessage("pidTuningRate"));
}
if (semver.gte(CONFIG.flightControllerVersion, '3.0.0')) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
$('.pid_filter input[name="gyroNotch1Frequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz_1);
$('.pid_filter input[name="gyroNotch1Cutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff_1);
$('.pid_filter input[name="dTermNotchFrequency"]').val(FILTER_CONFIG.dterm_notch_hz);
@ -257,7 +245,7 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_filter .newFilter').hide();
}
if (semver.gte(CONFIG.flightControllerVersion, '3.0.1')) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
$('.pid_filter input[name="gyroNotch2Frequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz_2);
$('.pid_filter input[name="gyroNotch2Cutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff_2);
} else {
@ -350,19 +338,19 @@ TABS.pid_tuning.initialize = function (callback) {
FILTER_CONFIG.dterm_lpf_hz = parseInt($('.pid_filter input[name="dtermLowpassFrequency"]').val());
FILTER_CONFIG.yaw_lpf_hz = parseInt($('.pid_filter input[name="yawLowpassFrequency"]').val());
if (semver.gte(CONFIG.flightControllerVersion, "2.8.0") && !semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
BF_CONFIG.features.updateData($('input[name="SUPEREXPO_RATES"]'));
if (semver.gte(CONFIG.apiVersion, "1.16.0") && !semver.gte(CONFIG.apiVersion, "1.20.0")) {
FEATURE_CONFIG.features.updateData($('input[name="SUPEREXPO_RATES"]'));
}
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
ADVANCED_TUNING.vbatPidCompensation = $('input[id="vbatpidcompensation"]').is(':checked') ? 1 : 0;
}
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
ADVANCED_TUNING.deltaMethod = $('#pid-tuning .delta select').val();
}
if (semver.gte(CONFIG.flightControllerVersion, '3.0.0')) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
ADVANCED_TUNING.ptermSetpointWeight = parseInt($('input[name="ptermSetpoint-number"]').val() * 100);
ADVANCED_TUNING.dtermSetpointWeight = parseInt($('input[name="dtermSetpoint-number"]').val() * 100);
@ -370,7 +358,7 @@ TABS.pid_tuning.initialize = function (callback) {
FILTER_CONFIG.gyro_soft_notch_cutoff_1 = parseInt($('.pid_filter input[name="gyroNotch1Cutoff"]').val());
FILTER_CONFIG.dterm_notch_hz = parseInt($('.pid_filter input[name="dTermNotchFrequency"]').val());
FILTER_CONFIG.dterm_notch_cutoff = parseInt($('.pid_filter input[name="dTermNotchCutoff"]').val());
if (semver.gte(CONFIG.flightControllerVersion, '3.0.1')) {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
FILTER_CONFIG.gyro_soft_notch_hz_2 = parseInt($('.pid_filter input[name="gyroNotch2Frequency"]').val());
FILTER_CONFIG.gyro_soft_notch_cutoff_2 = parseInt($('.pid_filter input[name="gyroNotch2Cutoff"]').val());
}
@ -407,7 +395,7 @@ TABS.pid_tuning.initialize = function (callback) {
$('#pid_mag').show();
showTitle = true;
}
if (BF_CONFIG.features.isEnabled('GPS')) {
if (FEATURE_CONFIG.features.isEnabled('GPS')) {
$('#pid_gps').show();
showTitle = true;
}
@ -447,7 +435,7 @@ TABS.pid_tuning.initialize = function (callback) {
}
var useLegacyCurve = false;
if (!semver.gte(CONFIG.flightControllerVersion, "2.8.0")) {
if (!semver.gte(CONFIG.apiVersion, "1.16.0")) {
useLegacyCurve = true;
}
@ -469,8 +457,8 @@ TABS.pid_tuning.initialize = function (callback) {
}
function process_html() {
if (semver.gte(CONFIG.flightControllerVersion, "2.8.0") && !semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
BF_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
if (semver.gte(CONFIG.apiVersion, "1.16.0") && !semver.gte(CONFIG.apiVersion, "1.20.0")) {
FEATURE_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
} else {
$('.tab-pid_tuning .pidTuningFeatures').hide();
}
@ -487,9 +475,9 @@ TABS.pid_tuning.initialize = function (callback) {
rc_rate_yaw: RC_tuning.rcYawRate,
rc_expo: RC_tuning.RC_EXPO,
rc_yaw_expo: RC_tuning.RC_YAW_EXPO,
superexpo: BF_CONFIG.features.isEnabled('SUPEREXPO_RATES'),
deadband: RC_deadband.deadband,
yawDeadband: RC_deadband.yaw_deadband
superexpo: FEATURE_CONFIG.features.isEnabled('SUPEREXPO_RATES'),
deadband: RC_DEADBAND_CONFIG.deadband,
yawDeadband: RC_DEADBAND_CONFIG.yaw_deadband
};
if (semver.lt(CONFIG.apiVersion, "1.7.0")) {
@ -497,11 +485,11 @@ TABS.pid_tuning.initialize = function (callback) {
self.currentRates.pitch_rate = RC_tuning.roll_pitch_rate;
}
if (semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
if (semver.lt(CONFIG.apiVersion, "1.16.0")) {
self.currentRates.rc_rate_yaw = self.currentRates.rc_rate;
}
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
self.currentRates.superexpo = true;
}
@ -566,7 +554,7 @@ TABS.pid_tuning.initialize = function (callback) {
});
});
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
$('.tab-pid_tuning select[name="rate_profile"]').change(function () {
self.currentRateProfile = parseInt($(this).val());
self.updating = true;
@ -603,7 +591,7 @@ TABS.pid_tuning.initialize = function (callback) {
$('#pid-tuning .dtermSetpoint').hide();
}
if (!semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
if (!semver.gte(CONFIG.apiVersion, "1.16.0")) {
$('#pid-tuning .delta').hide();
$('.tab-pid_tuning .note').hide();
}
@ -620,7 +608,7 @@ TABS.pid_tuning.initialize = function (callback) {
var pidController_e = $('select[name="controller"]');
if (semver.lt(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.lt(CONFIG.apiVersion, "1.31.0")) {
var pidControllerList;
@ -633,7 +621,7 @@ TABS.pid_tuning.initialize = function (callback) {
{name: "MultiWii (2.3 - hybrid)"},
{name: "Harakiri"}
]
} else if (semver.lt(CONFIG.flightControllerVersion, "3.0.0")) {
} else if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
pidControllerList = [
{name: ""},
{name: "Integer"},
@ -707,7 +695,7 @@ TABS.pid_tuning.initialize = function (callback) {
updateNeeded = true;
}
if (targetElement.attr('name') === 'rc_rate' && semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
if (targetElement.attr('name') === 'rc_rate' && semver.lt(CONFIG.apiVersion, "1.16.0")) {
self.currentRates.rc_rate_yaw = targetValue;
}
@ -823,13 +811,13 @@ TABS.pid_tuning.initialize = function (callback) {
}
});
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
$('#pid-tuning .delta select').change(function() {
self.setDirty(true);
});
}
if (semver.lt(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.lt(CONFIG.apiVersion, "1.31.0")) {
pidController_e.change(function () {
self.setDirty(true);
@ -845,7 +833,7 @@ TABS.pid_tuning.initialize = function (callback) {
Promise.resolve(true)
.then(function () {
var promise;
if (semver.gte(CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion) && semver.lt(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion) && semver.lt(CONFIG.apiVersion, "1.31.0")) {
PID.controller = pidController_e.val();
promise = MSP.promise(MSPCodes.MSP_SET_PID_CONTROLLER, mspHelper.crunch(MSPCodes.MSP_SET_PID_CONTROLLER));
}
@ -853,19 +841,11 @@ TABS.pid_tuning.initialize = function (callback) {
}).then(function () {
return MSP.promise(MSPCodes.MSP_SET_PID, mspHelper.crunch(MSPCodes.MSP_SET_PID));
}).then(function () {
if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
return MSP.promise(MSPCodes.MSP_SET_PID_ADVANCED, mspHelper.crunch(MSPCodes.MSP_SET_PID_ADVANCED));
}
return MSP.promise(MSPCodes.MSP_SET_PID_ADVANCED, mspHelper.crunch(MSPCodes.MSP_SET_PID_ADVANCED));
}).then(function () {
if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
return MSP.promise(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG));
}
return MSP.promise(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG));
}).then(function () {
return MSP.promise(MSPCodes.MSP_SET_RC_TUNING, mspHelper.crunch(MSPCodes.MSP_SET_RC_TUNING));
}).then(function () {
if (semver.gte(CONFIG.flightControllerVersion, "2.8.0")) {
return MSP.promise(MSPCodes.MSP_SET_BF_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BF_CONFIG));
}
}).then(function () {
return MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
}).then(function () {
@ -973,7 +953,7 @@ TABS.pid_tuning.setDirty = function (isDirty) {
self.dirty = isDirty;
$('.tab-pid_tuning select[name="profile"]').prop('disabled', isDirty);
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
$('.tab-pid_tuning select[name="rate_profile"]').prop('disabled', isDirty);
}
};
@ -982,7 +962,7 @@ TABS.pid_tuning.checkUpdateProfile = function (updateRateProfile) {
var self = this;
if (GUI.active_tab === 'pid_tuning') {
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")
if (semver.gte(CONFIG.apiVersion, "1.20.0")
&& CONFIG.numProfiles === 2) {
$('.tab-pid_tuning select[name="profile"] .profile3').hide();
}
@ -996,7 +976,7 @@ TABS.pid_tuning.checkUpdateProfile = function (updateRateProfile) {
}
var changedRateProfile = false;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")
if (semver.gte(CONFIG.apiVersion, "1.20.0")
&& updateRateProfile
&& self.currentRateProfile !== CONFIG.rateProfile) {
self.setRateProfile();
@ -1036,7 +1016,7 @@ TABS.pid_tuning.checkRC = function() {
};
TABS.pid_tuning.updatePidControllerParameters = function () {
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0") && semver.lt(CONFIG.flightControllerVersion, "3.1.0") && $('.tab-pid_tuning select[name="controller"]').val() === '0') {
if (semver.gte(CONFIG.apiVersion, "1.20.0") && semver.lt(CONFIG.apiVersion, "1.31.0") && $('.tab-pid_tuning select[name="controller"]').val() === '0') {
$('.pid_tuning .YAW_JUMP_PREVENTION').show();
$('#pid-tuning .delta').show();

View file

@ -72,8 +72,22 @@
display: none;
}
/* margin required when cell contents wrap */
.tab-ports .ports select {
margin-top: 5px;
margin-bottom: 5px;
}
.tab-ports .ports select[name=function-peripherals],
.tab-ports .ports select[name=function-telemetry] {
max-width: 110px;
}
.tab-ports .ports td {
text-align: center;
}
.tab-ports .ports thead td {
text-align: left;
white-space: nowrap;
padding: 5px 7px;
background-color: #828885;
@ -81,6 +95,7 @@
}
.tab-ports .ports thead td:first-child {
text-align: left;
border-top-left-radius: 5px;
border-left: 0px;
}

View file

@ -30,7 +30,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
functionRules.push(mavlinkFunctionRule);
}
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
functionRules.push({ name: 'ESC_SENSOR', groups: ['sensors'], maxPorts: 1 });
functionRules.push({ name: 'TBS_SMARTAUDIO', groups: ['peripherals'], maxPorts: 1 });
}
@ -57,7 +57,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
'250000'
];
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
mspBaudRates = mspBaudRates.concat(['500000', '1000000']);
}
@ -209,7 +209,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
var select_e;
if (column !== 'telemetry' && column !== 'sensors' && column !== 'peripherals') {
var checkboxId = 'functionCheckbox-' + portIndex + '-' + columnIndex + '-' + i;
functions_e.prepend('<span class="function"><input type="checkbox" class="togglemedium" id="' + checkboxId + '" value="' + functionName + '" /><label for="' + checkboxId + '"> ' + functionRule.displayName + '</label></span>');
functions_e.prepend('<span class="function"><input type="checkbox" class="togglemedium" id="' + checkboxId + '" value="' + functionName + '" /><label for="' + checkboxId + '"></label></span>');
if (serialPort.functions.indexOf(functionName) >= 0) {
var checkbox_e = functions_e.find('#' + checkboxId);

80
tabs/power.css Normal file
View file

@ -0,0 +1,80 @@
#tab-power-templates {
display: none;
}
.tab-power td.configuration {
padding-top: 5px;
text-align: left;
width: 50%;
padding-left: 20px;
}
.tab-power .battery-state .configuration {
border-bottom: 0px;
}
.tab-power td.value {
text-align: left;
width: 20%;
}
.tab-power .number input {
width: 50px;
padding-left: 3px;
height: 20px;
line-height: 20px;
text-align: left;
border: 1px solid silver;
border-radius: 3px;
margin-right: 11px;
font-size: 12px;
font-weight: normal;
}
.tab-power .spacer_box {
padding-bottom: 10px;
float: left;
width: calc(100% - 20px);
}
.tab-power .number,
.tab-power .select
{
margin-bottom: 5px;
clear: left;
padding-bottom: 5px;
border-bottom: 1px solid #ddd;
width: 100%;
float: left;
}
.tab-power .battery-configuration select {
border: 1px solid silver;
margin-right: 5px;
float: left;
width: 150px;
}
.tab-power .number:last-child,
.tab-power .select:last-child {
border-bottom: none;
padding-bottom: 0px;
margin-bottom: 0px;
}
.tab-power .require-support {
display: none;
}
.tab-power.supported .require-support {
display: block;
}
.tab-power .require-upgrade {
display: block;
}
.tab-power.supported .require-upgrade {
display: none;
}

167
tabs/power.html Normal file
View file

@ -0,0 +1,167 @@
<div class="tab-power toolbar_fixed_bottom">
<div class="content_wrapper initialstyle">
<!-- should be the first DIV on each tab -->
<div class="cf_column spacerbottom">
<div class="tab_title" i18n="tabPower">Power</div>
<div class="cf_doc_version_bt">
<a id="button-documentation" href="" target="_blank"></a>
</div>
</div>
<div class="require-support">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="powerBatteryHead"></div>
</div>
<div class="spacer_box battery">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
<tbody class="battery-state">
</tbody>
</table>
</div>
</div>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="powerVoltageHead"></div>
</div>
<div class="spacer_box">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
<tbody class="voltage-meters">
</tbody>
</table>
</div>
</div>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="powerAmperageHead"></div>
</div>
<div class="spacer_box">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
<tbody class="amperage-meters">
</tbody>
</table>
</div>
</div>
</div>
<div class="note require-upgrade">
<div class="note_spacer">
<p i18n="powerFirmwareUpgradeRequired"></p>
</div>
</div>
</div>
<div class="content_toolbar">
<div class="btn save_btn">
<a class="save" href="#" i18n="powerButtonSave"></a>
</div>
</div>
</div>
<div id="tab-power-templates">
<table class="voltage-meters">
<tbody>
<tr class="voltage-meter">
<td class="label"></td>
<td class="value"></td>
<td class="configuration"></td>
</tr>
</tbody>
</table>
<table class="amperage-meters">
<tbody>
<tr class="amperage-meter">
<td class="label"></td>
<td class="value"></td>
<td class="configuration"></td>
</tr>
</tbody>
</table>
<table class="battery-states">
<tbody class="battery-state">
<tr class="connection-state">
<td i18n="powerBatteryConnected"></td>
<td class="value">?</td>
<td class="configuration" rowspan="4"></td>
</tr>
<tr class="voltage">
<td i18n="powerBatteryVoltage"></td>
<td class="value"></td>
</tr>
<tr class="mah-drawn">
<td i18n="powerBatteryCurrentDrawn"></td>
<td class="value"></td>
</tr>
<tr class="amperage">
<td i18n="powerBatteryAmperage"></td>
<td class="value"></td>
</tr>
</tbody>
</table>
<div class="battery-configuration">
<div class="select vbatmonitoring">
<label>
<select class="batterymetersource"><!-- list generated here --></select>
<span i18n="powerBatteryVoltageMeterSource"></span>
</label>
</div>
<div class="select currentMonitoring">
<label>
<select class="currentmetersource"><!-- list generated here --></select>
<span i18n="powerBatteryCurrentMeterSource"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="mincellvoltage" step="0.1" min="1" max="5" /> <span
i18n="powerBatteryMinimum"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="maxcellvoltage" step="0.1" min="1" max="5" /> <span
i18n="powerBatteryMaximum"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="warningcellvoltage" step="0.1" min="1" max="5" /> <span
i18n="powerBatteryWarning"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="capacity" step="1" min="0" max="65535" /> <span
i18n="powerBatteryCapacity"></span>
</label>
</div>
</div>
<div class="voltage-configuration">
<div class="number">
<label> <input type="number" name="vbatscale" step="1" min="10" max="255" /> <span
i18n="powerVoltageScale"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="vbatresdivval" step="1" min="1" max="255" /> <span
i18n="powerVoltageDivider"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="vbatresdivmultiplier" step="1" min="1" max="255" /> <span
i18n="powerVoltageMultiplier"></span>
</label>
</div>
</div>
<div class="amperage-configuration">
<div class="number">
<label> <input type="number" name="amperagescale" step="1" min="-1000" max="1500" /> <span
i18n="powerAmperageScale"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="amperageoffset" step="1" min="0" max="3300" /> <span
i18n="powerAmperageOffset"></span>
</label>
</div>
</div>
</div>

284
tabs/power.js Normal file
View file

@ -0,0 +1,284 @@
'use strict';
TABS.power = {
supported: false,
};
TABS.power.initialize = function (callback) {
var self = this;
if (GUI.active_tab != 'power') {
GUI.active_tab = 'power';
// Disabled on merge into betaflight-configurator
//googleAnalytics.sendAppView('Power');
}
function load_status() {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_voltage_meters);
}
function load_voltage_meters() {
MSP.send_message(MSPCodes.MSP_VOLTAGE_METERS, false, false, load_current_meters);
}
function load_current_meters() {
MSP.send_message(MSPCodes.MSP_CURRENT_METERS, false, false, load_current_meter_configs);
}
function load_current_meter_configs() {
MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, load_voltage_meter_configs);
}
function load_voltage_meter_configs() {
MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, load_battery_state);
}
function load_battery_state() {
MSP.send_message(MSPCodes.MSP_BATTERY_STATE, false, false, load_battery_config);
}
function load_battery_config() {
MSP.send_message(MSPCodes.MSP_BATTERY_CONFIG, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/power.html", process_html);
}
this.supported = semver.gte(CONFIG.apiVersion, "1.33.0");
if (!this.supported) {
load_html();
} else {
load_status();
}
function update_ui() {
if (!TABS.power.supported) {
$(".tab-power").removeClass("supported");
return;
}
$(".tab-power").addClass("supported");
// voltage meters
var template = $('#tab-power-templates .voltage-meters .voltage-meter');
var destination = $('.tab-power .voltage-meters');
for (var index = 0; index < VOLTAGE_METERS.length; index++) {
var meterElement = template.clone();
$(meterElement).attr('id', 'voltage-meter-' + index);
var message = chrome.i18n.getMessage('powerVoltageId' + VOLTAGE_METERS[index].id);
$(meterElement).find('.label').text(message)
destination.append(meterElement);
}
var template = $('#tab-power-templates .voltage-configuration');
for (var index = 0; index < VOLTAGE_METER_CONFIGS.length; index++) {
var destination = $('#voltage-meter-' + index + ' .configuration');
var element = template.clone();
var attributeNames = ["vbatscale", "vbatresdivval", "vbatresdivmultiplier"];
for (let attributeName of attributeNames) {
$(element).find('input[name="' + attributeName + '"]').attr('name', attributeName + '-' + index);
}
destination.append(element);
$('input[name="vbatscale-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatscale).attr('disabled','disabled');
$('input[name="vbatresdivval-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivval).attr('disabled','disabled');
$('input[name="vbatresdivmultiplier-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivmultiplier).attr('disabled','disabled');
}
// amperage meters
var template = $('#tab-power-templates .amperage-meters .amperage-meter');
var destination = $('.tab-power .amperage-meters');
for (var index = 0; index < CURRENT_METERS.length; index++) {
var meterElement = template.clone();
$(meterElement).attr('id', 'amperage-meter-' + index);
var message = chrome.i18n.getMessage('powerAmperageId' + CURRENT_METERS[index].id);
$(meterElement).find('.label').text(message)
destination.append(meterElement);
}
var template = $('#tab-power-templates .amperage-configuration');
for (var index = 0; index < CURRENT_METER_CONFIGS.length; index++) {
var destination = $('#amperage-meter-' + index + ' .configuration');
var element = template.clone();
var attributeNames = ["amperagescale", "amperageoffset"];
for (let attributeName of attributeNames) {
$(element).find('input[name="' + attributeName + '"]').attr('name', attributeName + '-' + index);
}
destination.append(element);
$('input[name="amperagescale-' + index + '"]').val(CURRENT_METER_CONFIGS[index].scale).attr('disabled','disabled');
$('input[name="amperageoffset-' + index + '"]').val(CURRENT_METER_CONFIGS[index].offset).attr('disabled','disabled');
}
// battery
var template = $('#tab-power-templates .battery-states .battery-state');
var destination = $('.tab-power .battery-state');
var element = template.clone();
$(element).find('.connection-state').attr('id', 'battery-connection-state');
$(element).find('.voltage').attr('id', 'battery-voltage');
$(element).find('.mah-drawn').attr('id', 'battery-mah-drawn');
$(element).find('.amperage').attr('id', 'battery-amperage');
destination.append(element.children());
var template = $('#tab-power-templates .battery-configuration');
var destination = $('.tab-power .battery .configuration');
var element = template.clone();
destination.append(element);
$('input[name="mincellvoltage"]').val(BATTERY_CONFIG.vbatmincellvoltage);
$('input[name="maxcellvoltage"]').val(BATTERY_CONFIG.vbatmaxcellvoltage);
$('input[name="warningcellvoltage"]').val(BATTERY_CONFIG.vbatwarningcellvoltage);
$('input[name="capacity"]').val(BATTERY_CONFIG.capacity);
var haveFc = (semver.lt(CONFIG.apiVersion, "1.35.0") || (CONFIG.boardType == 0 || CONFIG.boardType == 2));
var batteryMeterTypes = [
'None',
'Onboard ADC',
];
if (haveFc) {
batteryMeterTypes.push('ESC Sensor');
}
var batteryMeterType_e = $('select.batterymetersource');
for (var i = 0; i < batteryMeterTypes.length; i++) {
batteryMeterType_e.append('<option value="' + i + '">' + batteryMeterTypes[i] + '</option>');
}
batteryMeterType_e.change(function () {
BATTERY_CONFIG.voltageMeterSource = parseInt($(this).val());
});
batteryMeterType_e.val(BATTERY_CONFIG.voltageMeterSource).change();
// fill current
var currentMeterTypes = [
'None',
'Onboard ADC',
];
if (haveFc) {
currentMeterTypes.push('Virtual');
currentMeterTypes.push('ESC Sensor');
}
var currentMeterType_e = $('select.currentmetersource');
for (var i = 0; i < currentMeterTypes.length; i++) {
currentMeterType_e.append('<option value="' + i + '">' + currentMeterTypes[i] + '</option>');
}
currentMeterType_e.change(function () {
BATTERY_CONFIG.currentMeterSource = parseInt($(this).val());
});
currentMeterType_e.val(BATTERY_CONFIG.currentMeterSource).change();
function get_slow_data() {
MSP.send_message(MSPCodes.MSP_VOLTAGE_METERS, false, false, function () {
for (var i = 0; i < VOLTAGE_METERS.length; i++) {
var elementName = '#voltage-meter-' + i + ' .value';
var element = $(elementName);
element.text(chrome.i18n.getMessage('powerVoltageValue', [VOLTAGE_METERS[i].voltage]));
}
});
MSP.send_message(MSPCodes.MSP_CURRENT_METERS, false, false, function () {
for (var i = 0; i < CURRENT_METERS.length; i++) {
var elementName = '#amperage-meter-' + i + ' .value';
var element = $(elementName);
element.text(chrome.i18n.getMessage('powerAmperageValue', [CURRENT_METERS[i].amperage.toFixed(2)]));
}
});
MSP.send_message(MSPCodes.MSP_BATTERY_STATE, false, false, function () {
var elementPrefix = '#battery';
var element;
element = $(elementPrefix + '-connection-state .value');
element.text(BATTERY_STATE.cellCount > 0 ? chrome.i18n.getMessage('powerBatteryConnectedValueYes', [BATTERY_STATE.cellCount]) : chrome.i18n.getMessage('powerBatteryConnectedValueNo'));
element = $(elementPrefix + '-voltage .value');
element.text(chrome.i18n.getMessage('powerVoltageValue', [BATTERY_STATE.voltage]));
element = $(elementPrefix + '-mah-drawn .value');
element.text(chrome.i18n.getMessage('powerMahValue', [BATTERY_STATE.mAhDrawn]));
element = $(elementPrefix + '-amperage .value');
element.text(chrome.i18n.getMessage('powerAmperageValue', [BATTERY_STATE.amperage]));
});
}
$('a.save').click(function () {
/* FIXME update for api 1.33.0
for (var index = 0; index < VOLTAGE_METER_CONFIGS.length; index++) {
VOLTAGE_METER_CONFIGS[index].vbatscale = parseInt($('input[name="vbatscale-' + index + '"]').val());
VOLTAGE_METER_CONFIGS[index].vbatresdivval = parseInt($('input[name="vbatresdivval-' + index + '"]').val());
VOLTAGE_METER_CONFIGS[index].vbatresdivmultiplier = parseInt($('input[name="vbatresdivmultiplier-' + index + '"]').val());
}
for (var index = 0; index < CURRENT_METER_CONFIGS.length; index++) {
CURRENT_METER_CONFIGS[index].scale = parseInt($('input[name="amperagescale-' + index + '"]').val());
CURRENT_METER_CONFIGS[index].offset = parseInt($('input[name="amperageoffset-' + index + '"]').val());
}
*/
BATTERY_CONFIG.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val());
BATTERY_CONFIG.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val());
BATTERY_CONFIG.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val());
BATTERY_CONFIG.capacity = parseInt($('input[name="capacity"]').val());
/* FIXME update for api 1.33.0
function save_voltage_config() {
MSP.sendVoltageMeterConfigs(save_amperage_config);
}
function save_amperage_config() {
MSP.sendAmperageMeterConfigs(save_battery_config);
}
*/
function save_battery_config() {
MSP.send_message(MSPCodes.MSP_SET_BATTERY_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BATTERY_CONFIG), false, save_to_eeprom);
}
function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, save_completed);
}
function save_completed() {
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
TABS.power.initialize();
}
save_battery_config();
});
GUI.interval_add('setup_data_pull_slow', get_slow_data, 200, true); // 5hz
}
function process_html() {
update_ui();
// translate to user-selected language
localize();
GUI.content_ready(callback);
}
};
TABS.power.cleanup = function (callback) {
if (callback) callback();
};

View file

@ -164,6 +164,7 @@
border-right: 1px solid silver;
}
.tab-receiver .tunings table {
width: 100%;
border-collapse: collapse;
}

View file

@ -27,45 +27,65 @@
<select class="hybrid_helper"
name="rcmap_helper">
<option value="AETR1234">Default</option>
<option value="AETR1234">Futaba / Hitec</option>
<option value="TAER1234">JR / Spektrum / Graupner</option>
<option value="AETR1234">FrSky / Futaba / Hitec</option>
<option value="TAER1234">Spektrum / Graupner / JR</option>
</select>
</div>
</div>
<div class="gui_box tunings grey" style="float: right;">
<table class="deadband" width="100%">
<table class="sticks">
<tr>
<th i18n="receiverMidRc">
</th>
<th i18n="receiverDeadband">
</th>
<th i18n="receiverYawDeadband">
</th>
<th i18n="receiverStickMin"></th>
<th i18n="receiverStickCenter"></th>
<th i18n="receiverStickMax"></th>
</tr>
<tr>
<td>
<div class="numberspacer">
<input type="number" name="midrc" min="1200" max="1700" />
<div class="helpicon cf_tip" i18n_title="receiverMidRcHelp"></div>
<div class="cf_tip" i18n_title="receiverHelpStickMin">
<input type="number" name="stick_min" min="1000" max="1200" />
</div>
</td>
<td>
<div>
<div class="cf_tip" i18n_title="receiverHelpStickCenter">
<input type="number" name="stick_center" min="1401" max="1599" />
</div>
</td>
<td>
<div class="cf_tip" i18n_title="receiverHelpStickMax">
<input type="number" name="stick_max" min="1800" max="2000" />
</div>
</td>
</tr>
</table>
</div>
<div class="gui_box tunings grey" style="float: right;">
<table class="deadband">
<tr>
<th i18n="receiverDeadband"></th>
<th i18n="receiverYawDeadband"></th>
<th i18n="recevier3dDeadbandThrottle"></th>
</tr>
<tr>
<td>
<div class="cf_tip" i18n_title="receiverHelpDeadband">
<input type="number" name="deadband" step="1" min="0" max="32" />
<div class="helpicon cf_tip" i18n_title="receiverHelpDeadband"></div>
</div>
</td>
<td>
<div>
<div class="cf_tip" i18n_title="receiverHelpYawDeadband">
<input type="number" name="yaw_deadband" step="1" min="0" max="100" />
<div class="helpicon cf_tip" i18n_title="receiverHelpYawDeadband"></div>
</div>
</td>
</td>
<td>
<div class="cf_tip" i18n_title="receiverHelp3dDeadbandThrottle">
<input type="number" name="3ddeadbandthrottle" step="1" min="0" max="1000" />
</div>
</td>
</tr>
</table>
</div>
<div class="gui_box grey tunings topspacer rcInterpolation">
<table class="rcInterpolation" width="100%">
<table class="rcInterpolation">
<tr>
<th colspan="2" i18n="receiverRcInterpolation"></th>
</tr>

View file

@ -15,24 +15,19 @@ TABS.receiver.initialize = function (callback) {
}
function get_rc_data() {
MSP.send_message(MSPCodes.MSP_RC, false, false, get_rc_tuning_data);
MSP.send_message(MSPCodes.MSP_RC, false, false, get_rssi_config);
}
function get_rc_tuning_data() {
MSP.send_message(MSPCodes.MSP_RC_TUNING, false, false, get_bt_config_data);
function get_rssi_config() {
MSP.send_message(MSPCodes.MSP_RSSI_CONFIG, false, false, get_rc_tuning);
}
function get_bt_config_data() {
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, get_rc_map);
function get_rc_tuning() {
MSP.send_message(MSPCodes.MSP_RC_TUNING, false, false, get_rc_map);
}
function get_rc_map() {
MSP.send_message(MSPCodes.MSP_RX_MAP, false, false, load_config);
}
// Fetch features so we can check if RX_MSP is enabled:
function load_config() {
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, load_rc_configs);
MSP.send_message(MSPCodes.MSP_RX_MAP, false, false, load_rc_configs);
}
function load_rc_configs() {
@ -46,7 +41,7 @@ TABS.receiver.initialize = function (callback) {
function load_rx_config() {
var next_callback = load_html;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, next_callback);
} else {
next_callback();
@ -57,7 +52,7 @@ TABS.receiver.initialize = function (callback) {
$('#content').load("./tabs/receiver.html", process_html);
}
MSP.send_message(MSPCodes.MSP_MISC, false, false, get_rc_data);
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, get_rc_data);
function process_html() {
// translate to user-selected language
@ -74,9 +69,9 @@ TABS.receiver.initialize = function (callback) {
if (semver.lt(CONFIG.apiVersion, "1.15.0")) {
$('.deadband').hide();
} else {
$('.deadband input[name="midrc"]').val(RX_CONFIG.midrc);
$('.deadband input[name="yaw_deadband"]').val(RC_deadband.yaw_deadband);
$('.deadband input[name="deadband"]').val(RC_deadband.deadband);
$('.deadband input[name="yaw_deadband"]').val(RC_DEADBAND_CONFIG.yaw_deadband);
$('.deadband input[name="deadband"]').val(RC_DEADBAND_CONFIG.deadband);
$('.deadband input[name="3ddeadbandthrottle"]').val(RC_DEADBAND_CONFIG.deadband3d_throttle);
$('.deadband input[name="deadband"]').change(function () {
this.deadband = parseInt($(this).val());
@ -84,10 +79,17 @@ TABS.receiver.initialize = function (callback) {
$('.deadband input[name="yaw_deadband"]').change(function () {
this.yawDeadband = parseInt($(this).val());
}).change();
}
if (semver.lt(CONFIG.apiVersion, "1.15.0")) {
$('.sticks').hide();
} else {
$('.sticks input[name="stick_min"]').val(RX_CONFIG.stick_min);
$('.sticks input[name="stick_center"]').val(RX_CONFIG.stick_center);
$('.sticks input[name="stick_max"]').val(RX_CONFIG.stick_max);
}
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
$('select[name="rcInterpolation-select"]').val(RX_CONFIG.rcInterpolation);
$('input[name="rcInterpolationInterval-number"]').val(RX_CONFIG.rcInterpolationInterval);
@ -226,7 +228,7 @@ TABS.receiver.initialize = function (callback) {
rssi_channel_e.append('<option value="' + i + '">' + i + '</option>');
}
$('select[name="rssi_channel"]').val(MISC.rssi_channel);
$('select[name="rssi_channel"]').val(RSSI_CONFIG.channel);
var rateHeight = TABS.receiver.rateChartHeight;
@ -237,9 +239,12 @@ TABS.receiver.initialize = function (callback) {
$('a.update').click(function () {
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
RX_CONFIG.midrc = parseInt($('.deadband input[name="midrc"]').val());
RC_deadband.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val());
RC_deadband.deadband = parseInt($('.deadband input[name="deadband"]').val());
RX_CONFIG.stick_max = parseInt($('.sticks input[name="stick_max"]').val());
RX_CONFIG.stick_center = parseInt($('.sticks input[name="stick_center"]').val());
RX_CONFIG.stick_min = parseInt($('.sticks input[name="stick_min"]').val());
RC_DEADBAND_CONFIG.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val());
RC_DEADBAND_CONFIG.deadband = parseInt($('.deadband input[name="deadband"]').val());
RC_DEADBAND_CONFIG.deadband3d_throttle = ($('.deadband input[name="3ddeadbandthrottle"]').val());
}
// catch rc map
@ -251,15 +256,16 @@ TABS.receiver.initialize = function (callback) {
}
// catch rssi aux
MISC.rssi_channel = parseInt($('select[name="rssi_channel"]').val());
RSSI_CONFIG.channel = parseInt($('select[name="rssi_channel"]').val());
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
RX_CONFIG.rcInterpolation = parseInt($('select[name="rcInterpolation-select"]').val());
RX_CONFIG.rcInterpolationInterval = parseInt($('input[name="rcInterpolationInterval-number"]').val());
}
function save_misc() {
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, save_rc_configs);
function save_rssi_config() {
MSP.send_message(MSPCodes.MSP_SET_RSSI_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RSSI_CONFIG), false, save_rc_configs);
}
function save_rc_configs() {
@ -273,7 +279,7 @@ TABS.receiver.initialize = function (callback) {
function save_rx_config() {
var next_callback = save_to_eeprom;
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
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();
@ -286,7 +292,7 @@ TABS.receiver.initialize = function (callback) {
});
}
MSP.send_message(MSPCodes.MSP_SET_RX_MAP, mspHelper.crunch(MSPCodes.MSP_SET_RX_MAP), false, save_misc);
MSP.send_message(MSPCodes.MSP_SET_RX_MAP, mspHelper.crunch(MSPCodes.MSP_SET_RX_MAP), false, save_rssi_config);
});
$("a.sticks").click(function() {
@ -316,7 +322,7 @@ TABS.receiver.initialize = function (callback) {
});
// Only show the MSP control sticks if the MSP Rx feature is enabled
$(".sticks_btn").toggle(BF_CONFIG.features.isEnabled('RX_MSP'));
$(".sticks_btn").toggle(FEATURE_CONFIG.features.isEnabled('RX_MSP'));
$('select[name="rx_refresh_rate"]').change(function () {
var plot_update_rate = parseInt($(this).val(), 10);
@ -361,7 +367,7 @@ TABS.receiver.initialize = function (callback) {
}
// Remove old data from array
while (RX_plot_data[0].length > 300) {
while (RX_plot_data.length > 300) {
for (var i = 0; i < RX_plot_data.length; i++) {
RX_plot_data[i].shift();
}
@ -447,11 +453,19 @@ TABS.receiver.initModelPreview = function () {
this.model = new Model($('.model_preview'), $('.model_preview canvas'));
this.useSuperExpo = false;
if (semver.gte(CONFIG.flightControllerVersion, '2.8.0')) {
this.useSuperExpo = BF_CONFIG.features.isEnabled('SUPEREXPO_RATES');
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
this.useSuperExpo = FEATURE_CONFIG.features.isEnabled('SUPEREXPO_RATES');
}
this.rateCurve = new RateCurve(CONFIG.flightControllerIdentifier !== 'BTFL' || semver.lt(CONFIG.flightControllerVersion, '2.8.0'));
var useOldRateCurve = false;
if (CONFIG.flightControllerIdentifier == 'CLFL' && semver.lt(CONFIG.apiVersion, '2.0.0')) {
useOldRateCurve = true;
}
if (CONFIG.flightControllerIdentifier == 'BTFL' && semver.lt(CONFIG.flightControllerVersion, '2.8.0')) {
useOldRateCurve = true;
}
this.rateCurve = new RateCurve(useOldRateCurve);
$(window).on('resize', $.proxy(this.model.resize, this.model));
};
@ -485,7 +499,7 @@ TABS.receiver.cleanup = function (callback) {
};
TABS.receiver.updateRcInterpolationParameters = function () {
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
if ($('select[name="rcInterpolation-select"]').val() === '3') {
$('.tab-receiver .rcInterpolationInterval').show();
} else {

View file

@ -185,17 +185,26 @@ TABS.sensors.initialize = function (callback) {
// disable graphs for sensors that are missing
var checkboxes = $('.tab-sensors .info .checkboxes input');
if (!have_sensor(CONFIG.activeSensors, 'acc')) {
checkboxes.eq(1).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'mag')) {
checkboxes.eq(2).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'baro')) {
checkboxes.eq(3).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'sonar')) {
checkboxes.eq(4).prop('disabled', true);
checkboxes.parent().show();
if (CONFIG.boardType == 0 || CONFIG.boardType == 2) {
if (!have_sensor(CONFIG.activeSensors, 'acc')) {
checkboxes.eq(1).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'mag')) {
checkboxes.eq(2).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'baro')) {
checkboxes.eq(3).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'sonar')) {
checkboxes.eq(4).prop('disabled', true);
}
} else {
for (var i = 0; i <= 4; i++) {
checkboxes.eq(i).prop('disabled', true);
checkboxes.eq(i).parent().hide();
}
}
$('.tab-sensors .info .checkboxes input').change(function () {

View file

@ -12,8 +12,6 @@
<th i18n="servosMid"></th>
<th i18n="servosMin"></th>
<th i18n="servosMax"></th>
<th class="wide" i18n="servosAngleAtMin"></th>
<th class="wide" i18n="servosAngleAtMax"></th>
<th class="short">CH1</th>
<th class="short">CH2</th>
<th class="short">CH3</th>

View file

@ -13,17 +13,7 @@ TABS.servos.initialize = function (callback) {
}
function get_servo_mix_rules() {
MSP.send_message(MSPCodes.MSP_SERVO_MIX_RULES, false, false, get_channel_forwarding);
}
function get_channel_forwarding() {
var nextFunction = get_rc_data;
if (semver.lt(CONFIG.apiVersion, "1.12.0")) {
MSP.send_message(MSPCodes.MSP_CHANNEL_FORWARDING, false, false, nextFunction);
} else {
nextFunction();
}
MSP.send_message(MSPCodes.MSP_SERVO_MIX_RULES, false, false, get_rc_data);
}
function get_rc_data() {
@ -76,8 +66,6 @@ TABS.servos.initialize = function (callback) {
<td class="middle"><input type="number" min="500" max="2500" value="' + SERVO_CONFIG[obj].middle + '" /></td>\
<td class="min"><input type="number" min="500" max="2500" value="' + SERVO_CONFIG[obj].min +'" /></td>\
<td class="max"><input type="number" min="500" max="2500" value="' + SERVO_CONFIG[obj].max +'" /></td>\
<td class="angleAtMin"><input type="number" min="-90" max="0" value="' + (-SERVO_CONFIG[obj].angleAtMin) +'" /></td>\
<td class="angleAtMax"><input type="number" min="0" max="90" value="' + SERVO_CONFIG[obj].angleAtMax +'" /></td>\
' + servoCheckbox + '\
<td class="direction">\
</td>\
@ -131,8 +119,6 @@ TABS.servos.initialize = function (callback) {
SERVO_CONFIG[info.obj].middle = parseInt($('.middle input', this).val());
SERVO_CONFIG[info.obj].min = parseInt($('.min input', this).val());
SERVO_CONFIG[info.obj].max = parseInt($('.max input', this).val());
SERVO_CONFIG[info.obj].angleAtMin = -parseInt($('.angleAtMin input', this).val());
SERVO_CONFIG[info.obj].angleAtMax = parseInt($('.angleAtMax input', this).val());
var val = parseInt($('.direction select', this).val());
SERVO_CONFIG[info.obj].rate = val;

View file

@ -12,15 +12,11 @@ TABS.setup.initialize = function (callback) {
}
function load_status() {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_config);
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_mixer_config);
}
function load_config() {
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, load_misc_data);
}
function load_misc_data() {
MSP.send_message(MSPCodes.MSP_MISC, false, false, load_html);
function load_mixer_config() {
MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_html);
}
function load_html() {

0
tabs/setup_osd.css Normal file
View file

44
tabs/setup_osd.html Normal file
View file

@ -0,0 +1,44 @@
<div class="tab-setup-osd">
<div class="content_wrapper initialstyle">
<!-- should be the first DIV on each tab -->
<div class="cf_column full spacerbottom">
<div class="tab_title" i18n="tabSetupOSD">OSD</div>
<div class="cf_doc_version_bt">
<a id="button-documentation" href="" target="_blank"></a>
</div>
<div class="cf_column fourth buttonarea">
<div class="spacer_right">
<div class="default_btn">
<a class="resetSettings" href="#" i18n="osdSetupButtonReset"></a>
</div>
</div>
</div>
<div class="threefourth_right osdinfo">
<div class="cell_osd">
<span i18n="osdSetupResetText"></span>
</div>
</div>
</div>
<div class="gui_box grey info">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="osdSetupHead"></div>
</div>
<div class="spacer_box">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
<tbody>
<tr>
<td i18n="osdSetupVideoMode"></td>
<td class="video-mode"></td>
</tr>
<tr>
<td i18n="osdSetupCameraConnected"></td>
<td class="camera-connected"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

71
tabs/setup_osd.js Normal file
View file

@ -0,0 +1,71 @@
'use strict';
TABS.setup_osd = {
};
TABS.setup_osd.initialize = function (callback) {
var self = this;
if (GUI.active_tab != 'setup_osd') {
GUI.active_tab = 'setup_osd';
// Disabled on merge into betaflight-configurator
//googleAnalytics.sendAppView('Setup OSD');
}
function load_status() {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/setup_osd.html", process_html);
}
load_status();
function process_html() {
$('.tab-setup-osd .info').hide(); // requires an MSP update
var osdVideoModes = [
'AUTO',
'NTSC',
'PAL'
];
// translate to user-selected language
localize();
$('a.resetSettings').click(function () {
MSP.send_message(MSPCodes.MSP_RESET_CONF, false, false, function () {
GUI.log(chrome.i18n.getMessage('initialSetupSettingsRestored'));
GUI.tab_switch_cleanup(function () {
TABS.setup_osd.initialize();
});
});
});
function get_slow_data() {
/* FIXME requires MSP update
MSP.send_message(MSPCodes.MSP_OSD_VIDEO_STATUS, false, false, function () {
var element;
element = $('.video-mode');
var osdVideoMode = osdVideoModes[OSD_VIDEO_STATE.video_mode];
element.text(osdVideoMode);
element = $('.camera-connected');
element.text(OSD_VIDEO_STATE.camera_connected ? chrome.i18n.getMessage('osdSetupCameraConnectedValueYes') : chrome.i18n.getMessage('osdSetupCameraConnectedValueNo'));
});
*/
}
GUI.interval_add('setup_data_pull_slow', get_slow_data, 250, true); // 4 fps
GUI.content_ready(callback);
}
};
TABS.setup_osd.cleanup = function (callback) {
if (callback) callback();
};

View file

@ -1,3 +1,7 @@
#tab-transponder-templates {
display: none;
}
.tab-transponder .spacer_box {
padding-bottom: 10px;
float: left;
@ -73,3 +77,11 @@
.tab-transponder.transponder-supported .require-transponder-supported {
display: block;
}
.textspacer-small {
margin-bottom: 15px;
}
.tab-transponder select {
min-width: 100px;
}

View file

@ -1,10 +1,12 @@
<div class="tab-transponder toolbar_fixed_bottom">
<div class="content_wrapper">
<div class="tab_title" i18n="tabTransponder">Transponder</div>
<div class="cf_doc_version_bt">
<a id="button-documentation" href="https://github.com/betaflight/betaflight/releases" target="_blank"></a>
</div>
<div class="require-transponder-unsupported note">
<div class="note_spacer">
<p i18n="transponderNotSupported"></p>
@ -12,41 +14,67 @@
</div>
<div class="require-transponder-supported">
<div class="note" style="margin-bottom: 20px;">
<div class="note_spacer">
<p i18n="transponderHelp"></p>
</div>
</div>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="transponderConfiguration"></div>
<div class="spacer_box_title" i18n="transponderConfigurationType"></div>
</div>
<div class="spacer_box">
<div class="text transponderData">
<div class="textspacer" >
<input type="text" name="data" spellcheck="false"/>
<div class="radio transponderType">
<div class="textspacer-small">
<select id="transponder_type_select">
</select>
</div>
<label for="failsafe_feature_new"><span i18n="transponderData"></span>
</label>
<div class="helpicon cf_tip" i18n_title="transponderDataHelp"></div>
</div>
<div id="transponderHelpBox">
<div class="clear-both"></div>
<div class="note">
<div class="note_spacer">
<p id="transponderHelp"></p>
</div>
</div>
</div>
</div>
</div>
<div class="clear-both"></div>
<div id="transponder-configuration" class="gui_box grey">
</div>
</div>
<div class="clear-both"></div>
<div class="note">
<div class="note_spacer">
<p i18n="transponderInformation"></p>
</div>
</div>
</div>
<div class="content_toolbar require-transponder-supported">
<div class="btn save_btn">
<div class="btn save_btn save_no_reboot">
<a class="save" href="#" i18n="transponderButtonSave"></a>
</div>
<div class="btn save_btn save_reboot" style="display: none">
<a class="save reboot" href="#" i18n="transponderButtonSaveReboot"></a>
</div>
</div>
</div>
<div id="tab-transponder-templates">
<div id="transponder-configuration-template">
<div class="gui_box_titlebar">
<div class="spacer_box_title"></div>
</div>
<div class="spacer_box">
<div class="text"><span class="dataHelp"></span>
<div class="input_block textspacer">
</div>
</div>
</div>
</div>
</div>

View file

@ -1,20 +1,56 @@
'use strict';
TABS.transponder = {
available: false
};
TABS.transponder.initialize = function (callback, scrollPosition) {
var self = this;
TABS.transponder.initialize = function(callback, scrollPosition) {
if (GUI.active_tab != 'transponder') {
let _persistentInputValues = {};
let dataTypes = {
NONE: 0,
TEXT: 1,
LIST: 2,
};
// CONFIGURATION HERE FOR ADD NEW TRANSPONDER
let transponderConfigurations = {
0: {
dataType: dataTypes.NONE // empty
}, //NONE
1: {
dataType: dataTypes.TEXT //<input type="text">
}, //ilap
2: {
dataType: dataTypes.LIST, // <select>...</select>
dataOptions: {
'ID 1': 'E00370FC0FFE07E0FF',
'ID 2': '007C003EF800FC0FFE',
'ID 3': 'F8811FF8811FFFC7FF',
'ID 4': '007C003EF81F800FFE',
'ID 5': 'F00FFF00FFF00FF0FF',
'ID 6': '007CF0C1071F7C00F0',
'ID 7': 'E003F03F00FF03F0C1',
'ID 8': '00FC0FFE071F3E00FE',
'ID 9': 'E083BFF00F9E38C0FF',
}
}, //arcitimer
};
/////////////////////////////////////////////
if ( GUI.active_tab != 'transponder' ) {
GUI.active_tab = 'transponder';
// Disabled on merge into betaflight-configurator
//googleAnalytics.sendAppView('Transponder');
}
// transponder supported added in MSP API Version 1.16.0
TABS.transponder.available = semver.gte(CONFIG.apiVersion, "1.16.0");
if (!TABS.transponder.available) {
if ( CONFIG ) {
TABS.transponder.available = semver.gte(CONFIG.apiVersion, "1.16.0");
}
//////////////
if ( !TABS.transponder.available ) {
load_html();
return;
}
@ -23,13 +59,14 @@ TABS.transponder.initialize = function (callback, scrollPosition) {
$('#content').load("./tabs/transponder.html", process_html);
}
// get the transponder data and a flag to see if transponder support is enabled on the FC
MSP.send_message(MSPCodes.MSP_TRANSPONDER_CONFIG, false, false, load_html);
//HELPERS
// Convert a hex string to a byte array
function hexToBytes(hex) {
for (var bytes = [], c = 0; c < hex.length; c += 2)
bytes.push(~parseInt(hex.substr(c, 2), 16));
var bytes = [];
for ( let c = 0; c < hex.length; c += 2 ) {
bytes.push(~parseInt(hex.substr(c, 2), 16));
}
return bytes;
}
@ -37,68 +74,202 @@ TABS.transponder.initialize = function (callback, scrollPosition) {
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n;
}
// Convert a byte array to a hex string
function bytesToHex(bytes) {
for (var hex = [], i = 0; i < bytes.length; i++) {
hex.push(pad(((~bytes[i]) & 0xFF).toString(16),2));
var hex = [];
for ( let i = 0; i < bytes.length; i++ ) {
hex.push(pad(((~bytes[i]) & 0xFF).toString(16), 2));
}
return hex.join("").toUpperCase();
}
function process_html() {
// translate to user-selected language
localize();
$(".tab-transponder")
.toggleClass("transponder-supported", TABS.transponder.available && TRANSPONDER.supported);
if (TABS.transponder.available) {
var data = bytesToHex(TRANSPONDER.data);
$('input[name="data"]').val(data);
$('input[name="data"]').prop('maxLength', data.length);
$('a.save').click(function () {
// gather data that doesn't have automatic change event bound
var dataString = $('input[name="data"]').val();
var expectedLength = TRANSPONDER.data.length;
var hexRegExp = new RegExp('[0-9a-fA-F]{' + (expectedLength * 2) + '}', 'gi');
if (!dataString.match(hexRegExp)) {
GUI.log(chrome.i18n.getMessage('transponderDataInvalid'));
return;
/////////////
function fillByTransponderProviders(transponderProviders, transponderProviderID, toggleTransponderType) {
let transponderTypeSelect = $('#transponder_type_select');
transponderTypeSelect.attr('data-defaultValue', transponderProviderID);
transponderTypeSelect.off('change').change(toggleTransponderType);
transponderTypeSelect.html('');
//build radio buttons
transponderTypeSelect.append(
$('<option>').attr('value', 0).html(chrome.i18n.getMessage("transponderType0")) // NONE
);
for ( let transponderProvidersKey in transponderProviders ) {
let transponderProvider = transponderProviders[transponderProvidersKey];
if ( transponderProvider.hasOwnProperty('id') ) {
transponderTypeSelect.append(
$('<option>').attr('value', transponderProvider.id).html(chrome.i18n.getMessage("transponderType" + transponderProvider.id))
);
}
}
transponderTypeSelect.val(transponderProviderID);
}
function buildDataBlockForTransponderProviders(transponderProvider, data, clearValue) {
var clearValue = clearValue || false;
$('#transponderConfiguration').html('');
$('#transponderConfiguration').hide();
$('#transponderHelpBox').hide();
if ( !transponderProvider ) {
return;
}
let template = $('#transponder-configuration-template').clone();
template.find('.spacer_box_title').html(chrome.i18n.getMessage("transponderData" + transponderProvider.id));
template.find('.dataHelp').html(chrome.i18n.getMessage("transponderDataHelp" + transponderProvider.id));
if ( chrome.i18n.getMessage("transponderHelp" + transponderProvider.id).length ) {
$('#transponderHelp').html(chrome.i18n.getMessage("transponderHelp" + transponderProvider.id));
$('#transponderHelpBox').show();
}
let transponderConfiguration = transponderConfigurations[transponderProvider.id];
let dataInput = null;
switch ( transponderConfiguration.dataType ) {
case dataTypes.TEXT:
dataInput = $('<input>').attr('type', 'text').attr('maxlength', parseInt(transponderProvider.dataLength) * 2);
if ( !clearValue ) {
dataInput.val(data);
} else {
dataInput.val(_persistentInputValues[transponderProvider.id] || '');
}
break;
case dataTypes.LIST:
dataInput = $('<select>');
for ( let dataOptionsKey in transponderConfiguration.dataOptions ) {
let dataOptions = transponderConfiguration.dataOptions[dataOptionsKey];
dataInput.append($('<option>').val(dataOptions).html(dataOptionsKey));
}
if ( dataInput.find("option[value='" + data + "']").length > 0 && !clearValue ) {
dataInput.val(data);
} else {
dataInput.val(_persistentInputValues[transponderProvider.id] || '');
}
break;
default:
return;
}
if ( !clearValue ) {
_persistentInputValues[transponderProvider.id] = data;
}
let changedInputValue = function() {
let dataString = $(this).val();
let hexRegExp = new RegExp('[0-9a-fA-F]{' + (transponderProvider.dataLength * 2) + '}', 'gi');
if ( !dataString.match(hexRegExp) ) {
TRANSPONDER.data = [];
} else {
TRANSPONDER.data = hexToBytes(dataString);
//
// send data to FC
//
function save_transponder_config() {
}
_persistentInputValues[transponderProvider.id] = dataString;
};
dataInput.change(changedInputValue).keyup(changedInputValue);
template.find('.input_block').html(dataInput);
$('#transponder-configuration').html(template.show());
}
/**
* this function is called from select click scope
*/
function toggleTransponderType() {
TRANSPONDER.provider = $(this).val();
let defaultProvider = $(this).attr('data-defaultValue');
if ( defaultProvider == $(this).val() ) {
$('.save_reboot').hide();
$('.save_no_reboot').show();
} else {
$('.save_no_reboot').hide();
$('.save_reboot').show();
}
let clearValue = true;
buildDataBlockForTransponderProviders(TRANSPONDER.providers.find(function(provider) {
return provider.id == TRANSPONDER.provider;
}), bytesToHex(TRANSPONDER.data), clearValue);
}
MSP.send_message(MSPCodes.MSP_TRANSPONDER_CONFIG, false, false, load_html);
function process_html() {
$(".tab-transponder").toggleClass("transponder-supported", TABS.transponder.available && TRANSPONDER.supported);
localize();
if ( TABS.transponder.available && TRANSPONDER.providers.length > 0 ) {
fillByTransponderProviders(TRANSPONDER.providers, TRANSPONDER.provider, toggleTransponderType);
buildDataBlockForTransponderProviders(TRANSPONDER.providers.find(function(provider) {
return provider.id == TRANSPONDER.provider;
}), bytesToHex(TRANSPONDER.data));
$('a.save').click(function() {
let _this = this;
function save_transponder_data() {
MSP.send_message(MSPCodes.MSP_SET_TRANSPONDER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_TRANSPONDER_CONFIG), false, save_to_eeprom);
}
function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(chrome.i18n.getMessage('transponderEepromSaved'));
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function() {
GUI.log(chrome.i18n.getMessage('transponderEepromSaved'));
if ( $(_this).hasClass('reboot') ) {
GUI.tab_switch_cleanup(function() {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
});
}
});
}
save_transponder_config();
if ( TRANSPONDER.data.length !== TRANSPONDER.providers.find(function(provider) {
return provider.id == TRANSPONDER.provider;
}).dataLength ) {
GUI.log(chrome.i18n.getMessage('transponderDataInvalid'));
} else {
save_transponder_data();
}
});
}
// status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
}, 250, true);
function reinitialize() {
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
if ( BOARD.find_board_definition(CONFIG.boardIdentifier).vcp ) {
$('a.connect').click();
GUI.timeout_add('start_connection', function start_connection() {
$('a.connect').click();
}, 2500);
} else {
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
MSP.send_message(MSPCodes.MSP_IDENT, false, false, function() {
GUI.log(chrome.i18n.getMessage('deviceReady'));
TABS.configuration.initialize(false, $('#content').scrollTop());
});
}, 1500);
}
}
GUI.content_ready(callback);
}
};
TABS.transponder.cleanup = function (callback) {
if (callback) callback();
TABS.transponder.cleanup = function(callback) {
if ( callback ) callback();
};