Skip to content

Commit

Permalink
Merge branch 'master' into mmosca-github-build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca authored Dec 26, 2023
2 parents 8b9daf3 + 1c48adc commit 39910c5
Show file tree
Hide file tree
Showing 38 changed files with 1,038 additions and 8,565 deletions.
7 changes: 5 additions & 2 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,9 @@
"portsFunction_MSP_DISPLAYPORT": {
"message": "MSP DisplayPort"
},
"portsFunction_SBUS_OUTPUT": {
"message": "SBus Output"
},
"pidTuning_ShowAllPIDs": {
"message": "Show all PIDs"
},
Expand Down Expand Up @@ -2220,7 +2223,7 @@
"message": "Blackbox configuration"
},
"blackboxButtonSave": {
"message": "Save and reboot"
"message": "Save and Reboot"
},
"serialLogging": {
"message": "Outboard serial logging device"
Expand Down Expand Up @@ -4452,7 +4455,7 @@
"message": "Confirm"
},
"mixerButtonSaveAndReboot": {
"message": "Save and reboot"
"message": "Save and Reboot"
},
"mixerApplyDescription": {
"message": "This action overrides all current mixer settings and replaces them with default values. There is no 'Undo' option!"
Expand Down
191 changes: 91 additions & 100 deletions js/defaults_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ helper.defaultsDialog = (function () {
key: "dterm_lpf_type",
value: "PT3"
},
{
key: "dterm_lpf2_hz",
value: 0
},
{
key: "dterm_lpf2_type",
value: "PT1"
},
{
key: "dynamic_gyro_notch_enabled",
value: "ON"
Expand Down Expand Up @@ -200,6 +192,11 @@ helper.defaultsDialog = (function () {
{
key: "failsafe_procedure",
value: "DROP"
},
// Ez Tune
{
key: "ez_filter_hz",
value: 90
}
]
},
Expand Down Expand Up @@ -270,14 +267,6 @@ helper.defaultsDialog = (function () {
key: "dterm_lpf_type",
value: "PT3"
},
{
key: "dterm_lpf2_hz",
value: 0
},
{
key: "dterm_lpf2_type",
value: "PT1"
},
{
key: "dynamic_gyro_notch_enabled",
value: "ON"
Expand Down Expand Up @@ -413,6 +402,11 @@ helper.defaultsDialog = (function () {
{
key: "failsafe_procedure",
value: "DROP"
},
// Ez Tune
{
key: "ez_filter_hz",
value: 110
}
]
},
Expand Down Expand Up @@ -461,14 +455,6 @@ helper.defaultsDialog = (function () {
key: "dterm_lpf_type",
value: "PT3"
},
{
key: "dterm_lpf2_hz",
value: 0
},
{
key: "dterm_lpf2_type",
value: "PT1"
},
{
key: "dynamic_gyro_notch_enabled",
value: "ON"
Expand Down Expand Up @@ -608,6 +594,11 @@ helper.defaultsDialog = (function () {
{
key: "failsafe_procedure",
value: "DROP"
},
// Ez Tune
{
key: "ez_filter_hz",
value: 90
}
]
},
Expand Down Expand Up @@ -794,10 +785,6 @@ helper.defaultsDialog = (function () {
key: "nav_rth_altitude",
value: 5000
},
{
key: "failsafe_mission",
value: "ON"
},
{
key: "nav_wp_radius",
value: 5000
Expand Down Expand Up @@ -1007,10 +994,6 @@ helper.defaultsDialog = (function () {
key: "nav_rth_altitude",
value: 5000
},
{
key: "failsafe_mission",
value: "ON"
},
{
key: "nav_wp_radius",
value: 5000
Expand Down Expand Up @@ -1169,86 +1152,94 @@ helper.defaultsDialog = (function () {
privateScope.setSettings = function (selectedDefaultPreset) {
var currentControlProfile = parseInt($("#profilechange").val());
var currentBatteryProfile = parseInt($("#batteryprofilechange").val());
//Save analytics
googleAnalytics.sendEvent('Setting', 'Defaults', selectedDefaultPreset.title);
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
return mspHelper.getSetting(input.key);
}).then(function () {
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
if (FC.isControlProfileParameter(input.key)) {
return privateScope.setSettingForAllControlProfiles(input.key, input.value);
} else if (FC.isBatteryProfileParameter(input.key)) {
return privateScope.setSettingForAllBatteryProfiles(input.key, input.value);
} else {
return mspHelper.setSetting(input.key, input.value);
}
}).then(function () {

// If default preset is associated to a mixer, apply the mixer as well
if (selectedDefaultPreset.mixerToApply) {
let currentMixerPreset = helper.mixer.getById(selectedDefaultPreset.mixerToApply);
var controlProfileSettings = [];
var batterySettings = [];
var miscSettings = [];

helper.mixer.loadServoRules(currentMixerPreset);
helper.mixer.loadMotorRules(currentMixerPreset);

MIXER_CONFIG.platformType = currentMixerPreset.platform;
MIXER_CONFIG.appliedMixerPreset = selectedDefaultPreset.mixerToApply;
MIXER_CONFIG.motorStopOnLow = (currentMixerPreset.motorStopOnLow === true) ? true : false;
MIXER_CONFIG.hasFlaps = (currentMixerPreset.hasFlaps === true) ? true : false;
selectedDefaultPreset.settings.forEach(input => {
if (FC.isControlProfileParameter(input.key)) {
controlProfileSettings.push(input);
} else if (FC.isBatteryProfileParameter(input.key)) {
batterySettings.push(input);
} else {
miscSettings.push(input);
}
});

SERVO_RULES.cleanup();
SERVO_RULES.inflate();
MOTOR_RULES.cleanup();
MOTOR_RULES.inflate();
//Save analytics
googleAnalytics.sendEvent('Setting', 'Defaults', selectedDefaultPreset.title);

var settingsChainer = MSPChainerClass();
var chain = [];

mspHelper.saveMixerConfig(function() {
mspHelper.sendServoMixer(function () {
mspHelper.sendMotorMixer(function () {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [currentControlProfile], false, function() {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, privateScope.finalize(selectedDefaultPreset));
});
});
});
});

} else {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [currentControlProfile], false, function() {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, privateScope.finalize(selectedDefaultPreset));
});
}
})
miscSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
};

privateScope.setSettingForAllControlProfiles = function (key, value) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [0], false, function () {
mspHelper.setSetting(key, value, function() {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [1], false, function () {
mspHelper.setSetting(key, value, function() {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [2], false, function () {
mspHelper.setSetting(key, value);
});
});
for (var i = 0; i < 3; i++ ) {
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [i], false, callback);
});
controlProfileSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
});
return;
};
}

privateScope.setSettingForAllBatteryProfiles = function (key, value) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [0], false, function () {
mspHelper.setSetting(key, value, function() {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [1], false, function () {
mspHelper.setSetting(key, value, function() {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [2], false, function () {
mspHelper.setSetting(key, value);
});
});
for (var i = 0; i < 3; i++ ) {
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [i], false, callback);
});
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
}

// Set Mixers
if (selectedDefaultPreset.mixerToApply) {
let currentMixerPreset = helper.mixer.getById(selectedDefaultPreset.mixerToApply);

helper.mixer.loadServoRules(currentMixerPreset);
helper.mixer.loadMotorRules(currentMixerPreset);

MIXER_CONFIG.platformType = currentMixerPreset.platform;
MIXER_CONFIG.appliedMixerPreset = selectedDefaultPreset.mixerToApply;
MIXER_CONFIG.motorStopOnLow = (currentMixerPreset.motorStopOnLow === true) ? true : false;
MIXER_CONFIG.hasFlaps = (currentMixerPreset.hasFlaps === true) ? true : false;

SERVO_RULES.cleanup();
SERVO_RULES.inflate();
MOTOR_RULES.cleanup();
MOTOR_RULES.inflate();

chain = chain.concat([
mspHelper.saveMixerConfig,
mspHelper.sendServoMixer,
mspHelper.sendMotorMixer
]);
}

chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [currentControlProfile], false, callback);
});
return;
};

chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, callback);
});

settingsChainer.setChain(chain);
settingsChainer.setExitPoint(function () {
privateScope.finalize(selectedDefaultPreset);
});

settingsChainer.execute();
}

privateScope.onPresetClick = function (event) {
savingDefaultsModal = new jBox('Modal', {
Expand Down
8 changes: 3 additions & 5 deletions js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ var FC = {
i2cError: 0,
activeSensors: 0,
mode: [],
mixer_profile: 0,
profile: 0,
battery_profile: 0,
mixer_profile: -1,
profile: -1,
battery_profile: -1,
uid: [0, 0, 0],
accelerometerTrims: [0, 0],
armingFlags: 0,
Expand Down Expand Up @@ -1439,8 +1439,6 @@ var FC = {
'max_angle_inclination_pit',
'dterm_lpf_hz',
'dterm_lpf_type',
'dterm_lpf2_hz',
'dterm_lpf2_type',
'yaw_lpf_hz',
'fw_iterm_throw_limit',
'fw_reference_airspeed',
Expand Down
8 changes: 7 additions & 1 deletion js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,16 @@ GUI_control.prototype.updateStatusBar = function() {
$('span.arming-flags').text(activeArmFlags.length ? activeArmFlags.join(', ') : '-');
};

GUI_control.prototype.updateProfileChange = function() {
GUI_control.prototype.updateProfileChange = function(refresh) {
$('#mixerprofilechange').val(CONFIG.mixer_profile);
$('#profilechange').val(CONFIG.profile);
$('#batteryprofilechange').val(CONFIG.battery_profile);
if (refresh) {
GUI.log(chrome.i18n.getMessage('loadedMixerProfile', [CONFIG.mixer_profile + 1]));
GUI.log(chrome.i18n.getMessage('pidTuning_LoadedProfile', [CONFIG.profile + 1]));
GUI.log(chrome.i18n.getMessage('loadedBatteryProfile', [CONFIG.battery_profile + 1]));
updateActivatedTab();
}
};

GUI_control.prototype.fillSelect = function ($element, values, currentValue, unit) {
Expand Down
Loading

0 comments on commit 39910c5

Please sign in to comment.