mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-25 01:05:12 +03:00
first cut of presets
This commit is contained in:
parent
6462e6c695
commit
35baf4302b
8 changed files with 335 additions and 1 deletions
|
@ -1894,5 +1894,14 @@
|
|||
},
|
||||
"armingCheckFail": {
|
||||
"message": "<span class=\"arming-state-fail\">FAIL</span>"
|
||||
},
|
||||
"tabPresets": {
|
||||
"message": "Presets"
|
||||
},
|
||||
"presetsPreset": {
|
||||
"message": "Preset"
|
||||
},
|
||||
"presetsDescription": {
|
||||
"message": "Description"
|
||||
}
|
||||
}
|
|
@ -37,7 +37,8 @@ var GUI_control = function () {
|
|||
'sensors',
|
||||
'servos',
|
||||
'setup',
|
||||
'osd'
|
||||
'osd',
|
||||
'profiles'
|
||||
];
|
||||
this.allowedTabs = this.defaultAllowedTabsWhenDisconnected;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
<link type="text/css" rel="stylesheet" href="./tabs/failsafe.css" media="all" />
|
||||
<link type="text/css" rel="stylesheet" href="./tabs/transponder.css" media="all" />
|
||||
<link type="text/css" rel="stylesheet" href="./tabs/osd.css" media="all" />
|
||||
<link type="text/css" rel="stylesheet" href="./tabs/profiles.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" />
|
||||
|
@ -88,6 +89,7 @@
|
|||
<script type="text/javascript" src="./tabs/failsafe.js"></script>
|
||||
<script type="text/javascript" src="./tabs/transponder.js"></script>
|
||||
<script type="text/javascript" src="./tabs/osd.js"></script>
|
||||
<script type="text/javascript" src="./tabs/profiles.js"></script>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -221,6 +223,7 @@
|
|||
</ul>
|
||||
<ul class="mode-connected">
|
||||
<li class="tab_setup"><a href="#" data-i18n="tabSetup" class="tabicon ic_setup" title="Setup"></a></li>
|
||||
<li class="tab_profiles"><a href="#" data-i18n="tabPresets" class="tabicon ic_adjust" title="Presets"></a></li>
|
||||
<li class="tab_ports"><a href="#" data-i18n="tabPorts" class="tabicon ic_ports" title="Ports"></a></li>
|
||||
<li class="tab_configuration"><a href="#" data-i18n="tabConfiguration" class="tabicon ic_config" title="Configuration"></a></li>
|
||||
<li class="tab_failsafe"><a href="#" data-i18n="tabFailsafe" class="tabicon ic_failsafe" title="Failsafe"></a></li>
|
||||
|
|
3
main.js
3
main.js
|
@ -148,6 +148,9 @@ $(document).ready(function () {
|
|||
case 'configuration':
|
||||
TABS.configuration.initialize(content_ready);
|
||||
break;
|
||||
case 'profiles':
|
||||
TABS.profiles.initialize(content_ready);
|
||||
break;
|
||||
case 'pid_tuning':
|
||||
TABS.pid_tuning.initialize(content_ready);
|
||||
break;
|
||||
|
|
|
@ -51,6 +51,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
}
|
||||
|
||||
//FIXME duplicate
|
||||
function loadINAVPidConfig() {
|
||||
var next_callback = loadSensorConfig;
|
||||
if (semver.gt(CONFIG.flightControllerVersion, "1.3.0")) {
|
||||
|
|
27
tabs/profiles.css
Normal file
27
tabs/profiles.css
Normal file
|
@ -0,0 +1,27 @@
|
|||
#presets-list option {
|
||||
padding: 0.4em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.preset__head {
|
||||
color: #37a8db;
|
||||
}
|
||||
|
||||
.preset__description {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.preset__features {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.preset__feature {
|
||||
list-style: disc;
|
||||
color: #37a8db;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.preset__feature-text {
|
||||
color: #000000;
|
||||
margin-left: -0.5em;
|
||||
}
|
40
tabs/profiles.html
Normal file
40
tabs/profiles.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
<div class="tab-configuration tab-profiles toolbar_fixed_bottom">
|
||||
<div class="content_wrapper">
|
||||
<div class="tab_title" data-i18n="tabPresets">Presets</div>
|
||||
|
||||
<div class="leftWrapper">
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" data-i18n="presetsPreset"></div>
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
<div class="select">
|
||||
<select id="presets-list" class="full-width" size="8">
|
||||
<!-- list generated here -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rightWrapper">
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" data-i18n="presetsDescription"></div>
|
||||
</div>
|
||||
<div class="spacer_box preset">
|
||||
<h2 id="preset-name" class="preset__head"></h2>
|
||||
<p id="preset-description" class="preset__description"></p>
|
||||
<ul id="preset-features" class="preset__features"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
<div class="content_toolbar">
|
||||
<div class="btn save_btn">
|
||||
<a id="save-button" class="save" href="#" data-i18n="configurationButtonSave"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
250
tabs/profiles.js
Normal file
250
tabs/profiles.js
Normal file
|
@ -0,0 +1,250 @@
|
|||
'use strict';
|
||||
|
||||
function elementHelper(group, field, value) {
|
||||
return {
|
||||
group: group,
|
||||
field: field,
|
||||
value: value
|
||||
}
|
||||
}
|
||||
|
||||
var availablePresets = [
|
||||
{
|
||||
name: '5" Racer',
|
||||
description: "210-250 class racer with F3/F4 CPU on 4S battery",
|
||||
features: [
|
||||
"4S battery",
|
||||
"2000KV - 2600KV motors",
|
||||
"5 inch propellers",
|
||||
"400g-650g weight",
|
||||
"F3 or F4 CPU",
|
||||
"MPU6000 gyro",
|
||||
"No GPS capabilities"
|
||||
],
|
||||
settings: [
|
||||
elementHelper("INAV_PID_CONFIG", "asynchronousMode", 2),
|
||||
elementHelper("FC_CONFIG", "loopTime", 1000),
|
||||
elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0),
|
||||
elementHelper("ADVANCED_CONFIG", "gyroSync", 1),
|
||||
elementHelper("ADVANCED_CONFIG", "gyroSyncDenominator", 4),
|
||||
elementHelper("FILTER_CONFIG", "gyroSoftLpfHz", 90),
|
||||
elementHelper("FILTER_CONFIG", "dtermLpfHz", 80),
|
||||
elementHelper("RC_tuning", "roll_rate", 800),
|
||||
elementHelper("RC_tuning", "pitch_rate", 800),
|
||||
elementHelper("RC_tuning", "yaw_rate", 650)
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "600mm Flying Wing",
|
||||
description: "Small flying wing on multirotor racer parts",
|
||||
features: [
|
||||
"3S-4S battery",
|
||||
"300g-500g weight"
|
||||
],
|
||||
settings: [
|
||||
elementHelper("PIDs", 0, [15, 30, 15]), //ROLL PIDs
|
||||
elementHelper("PIDs", 1, [15, 40, 15]), //PITCH PIDs
|
||||
elementHelper("RC_tuning", "roll_rate", 400),
|
||||
elementHelper("RC_tuning", "pitch_rate", 150)
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
TABS.profiles = {};
|
||||
|
||||
TABS.profiles.initialize = function (callback, scrollPosition) {
|
||||
|
||||
var currentPreset,
|
||||
currentPresetId;
|
||||
|
||||
if (GUI.active_tab != 'profiles') {
|
||||
GUI.active_tab = 'profiles';
|
||||
googleAnalytics.sendAppView('Presets');
|
||||
}
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_IDENT, false, false, loadINAVPidConfig);
|
||||
|
||||
//FIXME duplicate
|
||||
function loadINAVPidConfig() {
|
||||
var next_callback = loadLoopTime;
|
||||
if (semver.gt(CONFIG.flightControllerVersion, "1.3.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_INAV_PID, false, false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function loadLoopTime() {
|
||||
MSP.send_message(MSPCodes.MSP_LOOP_TIME, false, false, loadAdvancedConfig);
|
||||
}
|
||||
|
||||
function loadAdvancedConfig() {
|
||||
var next_callback = loadFilterConfig;
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.3.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function loadFilterConfig() {
|
||||
var next_callback = loadRcTuningData;
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.4.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_FILTER_CONFIG, false, false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function loadRcTuningData() {
|
||||
MSP.send_message(MSPCodes.MSP_RC_TUNING, false, false, loadPidData);
|
||||
}
|
||||
|
||||
function loadPidData() {
|
||||
MSP.send_message(MSPCodes.MSP_PID, false, false, loadHtml);
|
||||
}
|
||||
|
||||
function loadHtml() {
|
||||
$('#content').load("./tabs/profiles.html", processHtml);
|
||||
}
|
||||
|
||||
function extractPresetNames(presets) {
|
||||
|
||||
var retVal = {};
|
||||
|
||||
for (var i in presets) {
|
||||
if (presets.hasOwnProperty(i)) {
|
||||
retVal[i] = presets[i].name;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
function fillPresetDescription(preset) {
|
||||
console.log(preset);
|
||||
|
||||
var $features = $('#preset-features');
|
||||
|
||||
$('#preset-name').html(preset.name);
|
||||
$('#preset-description').html(preset.description);
|
||||
|
||||
$features.find('*').remove();
|
||||
|
||||
for (var i in preset.features) {
|
||||
if (preset.features.hasOwnProperty(i)) {
|
||||
$features.append('<li class="preset__feature"><span class="preset__feature-text">' + preset.features[i] + "</span></li>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function processHtml() {
|
||||
|
||||
var $presetList = $('#presets-list');
|
||||
|
||||
GUI.fillSelect($presetList, extractPresetNames(availablePresets));
|
||||
|
||||
$presetList.change(function () {
|
||||
currentPresetId = $presetList.val();
|
||||
currentPreset = availablePresets[currentPresetId];
|
||||
fillPresetDescription(currentPreset);
|
||||
});
|
||||
|
||||
localize();
|
||||
|
||||
$('#content').scrollTop((scrollPosition) ? scrollPosition : 0);
|
||||
|
||||
$('#save-button').click(function () {
|
||||
|
||||
var setting;
|
||||
|
||||
//Iterate over settings saved in preset
|
||||
for(var i in currentPreset.settings) {
|
||||
if (currentPreset.settings.hasOwnProperty(i)) {
|
||||
setting = currentPreset.settings[i];
|
||||
//Apply setting
|
||||
window[setting.group][setting.field] = setting.value;
|
||||
}
|
||||
}
|
||||
|
||||
saveINAVPidConfig();
|
||||
});
|
||||
|
||||
//FIXME duplicate from configuration.js
|
||||
function saveINAVPidConfig() {
|
||||
var next_callback = saveLooptimeConfig;
|
||||
if(semver.gt(CONFIG.flightControllerVersion, "1.3.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_INAV_PID, mspHelper.crunch(MSPCodes.MSP_SET_INAV_PID), false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME duplicate from configuration.js
|
||||
function saveLooptimeConfig() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_LOOP_TIME, mspHelper.crunch(MSPCodes.MSP_SET_LOOP_TIME), false, saveAdvancedConfig);
|
||||
}
|
||||
|
||||
//FIXME Duplicate
|
||||
function saveAdvancedConfig() {
|
||||
var next_callback = saveFilterConfig;
|
||||
if(semver.gte(CONFIG.flightControllerVersion, "1.3.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME duplicate
|
||||
function saveFilterConfig() {
|
||||
var next_callback = savePids;
|
||||
if(semver.gte(CONFIG.flightControllerVersion, "1.4.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG), false, next_callback);
|
||||
} else {
|
||||
next_callback();
|
||||
}
|
||||
}
|
||||
|
||||
function savePids() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_PID, mspHelper.crunch(MSPCodes.MSP_SET_PID), false, saveRcTuning);
|
||||
}
|
||||
|
||||
function saveRcTuning() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_RC_TUNING, mspHelper.crunch(MSPCodes.MSP_SET_RC_TUNING), false, saveToEeprom);
|
||||
}
|
||||
|
||||
//FIXME duplicate from configuration.js
|
||||
function saveToEeprom() {
|
||||
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot);
|
||||
}
|
||||
|
||||
function reboot() {
|
||||
//noinspection JSUnresolvedVariable
|
||||
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
|
||||
});
|
||||
}
|
||||
|
||||
function reinitialize() {
|
||||
//noinspection JSUnresolvedVariable
|
||||
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||
GUI.handleReconnect($('.tab_profiles a'));
|
||||
}
|
||||
|
||||
GUI.interval_add('status_pull', function status_pull() {
|
||||
MSP.send_message(MSPCodes.MSP_STATUS);
|
||||
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
|
||||
}
|
||||
}, 250, true);
|
||||
GUI.content_ready(callback);
|
||||
}
|
||||
};
|
||||
|
||||
TABS.profiles.cleanup = function (callback) {
|
||||
if (callback) callback();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue