mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-19 14:25:13 +03:00
Mixer tab, first elements
This commit is contained in:
parent
48c67874f9
commit
4f48ecff1b
8 changed files with 270 additions and 20 deletions
|
@ -1241,6 +1241,9 @@
|
|||
"servosEepromSave": {
|
||||
"message": "EEPROM <span style=\"color: #37a8db\">saved</span>"
|
||||
},
|
||||
"mixerSaved": {
|
||||
"message": "Mixer <span style=\"color: #37a8db\">saved</span>"
|
||||
},
|
||||
"gpsHead": {
|
||||
"message": "GPS"
|
||||
},
|
||||
|
@ -2003,6 +2006,9 @@
|
|||
"LevBtn": {
|
||||
"message": "Level calibration"
|
||||
},
|
||||
"tabMixer": {
|
||||
"message": "Mixer"
|
||||
},
|
||||
"tabPresets": {
|
||||
"message": "Presets"
|
||||
},
|
||||
|
@ -2464,5 +2470,17 @@
|
|||
},
|
||||
"servoMixerAdd": {
|
||||
"message": "Add new mixer rule"
|
||||
},
|
||||
"platformType": {
|
||||
"message": "Platform type"
|
||||
},
|
||||
"platformConfiguration": {
|
||||
"message": "Platform configuration"
|
||||
},
|
||||
"platformHasFlaps": {
|
||||
"message": "Has flaps"
|
||||
},
|
||||
"mixerPreset": {
|
||||
"message": "Mixer preset"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ var GUI_control = function () {
|
|||
'osd',
|
||||
'profiles',
|
||||
'advanced_tuning',
|
||||
'mission_control'
|
||||
'mission_control',
|
||||
'mixer'
|
||||
];
|
||||
this.allowedTabs = this.defaultAllowedTabsWhenDisconnected;
|
||||
|
||||
|
|
111
js/model.js
111
js/model.js
|
@ -60,23 +60,6 @@ const mixerList = [
|
|||
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0)
|
||||
]
|
||||
}, // 1
|
||||
{
|
||||
id: 2,
|
||||
name: 'Quad +',
|
||||
model: 'quad_x',
|
||||
image: 'quad_p',
|
||||
hasCustomServoMixer: false,
|
||||
enabled: true,
|
||||
legacy: true,
|
||||
platform: PLATFORM_MULTIROTOR,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 1.0, -1.0), // REAR
|
||||
new MotorMixRule(1.0, -1.0, 0.0, 1.0), // RIGHT
|
||||
new MotorMixRule(1.0, 1.0, 0.0, 1.0), // LEFT
|
||||
new MotorMixRule(1.0, 0.0, -1.0, -1.0) // FRONT
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 2
|
||||
{
|
||||
id: 3,
|
||||
name: 'Quad X',
|
||||
|
@ -94,6 +77,23 @@ const mixerList = [
|
|||
],
|
||||
servoMixer: []
|
||||
}, // 3
|
||||
{
|
||||
id: 2,
|
||||
name: 'Quad +',
|
||||
model: 'quad_x',
|
||||
image: 'quad_p',
|
||||
hasCustomServoMixer: false,
|
||||
enabled: true,
|
||||
legacy: true,
|
||||
platform: PLATFORM_MULTIROTOR,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 1.0, -1.0), // REAR
|
||||
new MotorMixRule(1.0, -1.0, 0.0, 1.0), // RIGHT
|
||||
new MotorMixRule(1.0, 1.0, 0.0, 1.0), // LEFT
|
||||
new MotorMixRule(1.0, 0.0, -1.0, -1.0) // FRONT
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 2
|
||||
{
|
||||
id: 4,
|
||||
name: 'Bicopter',
|
||||
|
@ -448,6 +448,51 @@ const mixerList = [
|
|||
} // 25
|
||||
];
|
||||
|
||||
const platformList = [
|
||||
{
|
||||
id: 0,
|
||||
name: "Multirotor",
|
||||
enabled: true,
|
||||
flapsPossible: false
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: "Airplane",
|
||||
enabled: true,
|
||||
flapsPossible: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Helicopter",
|
||||
enabled: false,
|
||||
flapsPossible: false
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Tricopter",
|
||||
enabled: true,
|
||||
flapsPossible: false
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Rover",
|
||||
enabled: false,
|
||||
flapsPossible: false
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "Boat",
|
||||
enabled: false,
|
||||
flapsPossible: false
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "Other",
|
||||
enabled: false,
|
||||
flapsPossible: false
|
||||
}
|
||||
];
|
||||
|
||||
var helper = helper || {};
|
||||
|
||||
helper.mixer = (function (mixerList) {
|
||||
|
@ -507,3 +552,35 @@ helper.mixer = (function (mixerList) {
|
|||
|
||||
return publicScope;
|
||||
})(mixerList);
|
||||
|
||||
helper.platform = (function (platforms) {
|
||||
let publicScope = {},
|
||||
privateScope = {};
|
||||
|
||||
publicScope.getList = function () {
|
||||
let retVal = [];
|
||||
for (const i in platforms) {
|
||||
if (platforms.hasOwnProperty(i)) {
|
||||
let element = platforms[i];
|
||||
if (element.enabled) {
|
||||
retVal.push(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
};
|
||||
|
||||
publicScope.getById = function (id) {
|
||||
for (const i in platforms) {
|
||||
if (platforms.hasOwnProperty(i)) {
|
||||
let element = platforms[i];
|
||||
if (element.id === id) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return publicScope;
|
||||
})(platformList);
|
|
@ -167,7 +167,8 @@
|
|||
</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_calibration"><a href="#" i18n="tabCalibration" class="tabicon ic_calibration" title="Calibration"></a></li>
|
||||
<li class="tab_calibration"><a href="#" data-i18n="tabCalibration" class="tabicon ic_calibration" title="Calibration"></a></li>
|
||||
<li class="tab_mixer"><a href="#" data-i18n="tabMixer" class="tabicon ic_wizzard" title="Mixer"></a></li>
|
||||
<li class="tab_profiles"><a href="#" data-i18n="tabPresets" class="tabicon ic_wizzard"
|
||||
title="Presets"></a></li>
|
||||
<li class="tab_ports"><a href="#" data-i18n="tabPorts" class="tabicon ic_ports" title="Ports"></a></li>
|
||||
|
|
3
main.js
3
main.js
|
@ -203,6 +203,9 @@ $(document).ready(function () {
|
|||
case 'mission_control':
|
||||
TABS.mission_control.initialize(content_ready);
|
||||
break;
|
||||
case 'mixer':
|
||||
TABS.mixer.initialize(content_ready);
|
||||
break;
|
||||
case 'motors':
|
||||
TABS.motors.initialize(content_ready);
|
||||
break;
|
||||
|
|
0
src/css/tabs/mixer.css
Normal file
0
src/css/tabs/mixer.css
Normal file
43
tabs/mixer.html
Normal file
43
tabs/mixer.html
Normal file
|
@ -0,0 +1,43 @@
|
|||
<div class="tab-configuration tab-mixer toolbar_fixed_bottom">
|
||||
<div class="content_wrapper">
|
||||
<div class="tab_title" data-i18n="tabMixer">Mixer</div>
|
||||
<div class="leftWrapper">
|
||||
<div class="platform-type gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" data-i18n="platformConfiguration"></div>
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
<div class="select">
|
||||
<select id="platform-type"></select>
|
||||
<label for="platform-type">
|
||||
<span data-i18n="platformType"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="select">
|
||||
<div class="mixerPreview half">
|
||||
<img src="./resources/motor_order/custom.svg" />
|
||||
</div>
|
||||
<div class="half" style="width: calc(50% - 10px); margin-left: 10px;">
|
||||
<select id="mixer-preset"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="has-flaps-wrapper" class="checkbox">
|
||||
<input type="checkbox" id="has-flaps" class="toggle" />
|
||||
<label for="has-flaps">
|
||||
<span data-i18n="platformHasFlaps"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rightWrapper">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="content_toolbar">
|
||||
<div class="btn save_btn">
|
||||
<a id="save-button" class="save disabled" href="#" data-i18n="presetsButtonApply"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
107
tabs/mixer.js
Normal file
107
tabs/mixer.js
Normal file
|
@ -0,0 +1,107 @@
|
|||
'use strict';
|
||||
|
||||
TABS.mixer = {};
|
||||
|
||||
TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||
|
||||
let loadChainer = new MSPChainerClass(),
|
||||
saveChainer = new MSPChainerClass(),
|
||||
currentPlatform,
|
||||
currentMixerPreset;
|
||||
|
||||
if (GUI.active_tab != 'mixer') {
|
||||
GUI.active_tab = 'mixer';
|
||||
googleAnalytics.sendAppView('Mixer');
|
||||
}
|
||||
|
||||
loadChainer.setChain([
|
||||
mspHelper.loadBfConfig,
|
||||
mspHelper.loadMixerConfig,
|
||||
mspHelper.loadMotors
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
loadChainer.execute();
|
||||
|
||||
saveChainer.setChain([
|
||||
mspHelper.saveBfConfig,
|
||||
mspHelper.saveMixerConfig,
|
||||
mspHelper.saveToEeprom
|
||||
]);
|
||||
saveChainer.setExitPoint(function () {
|
||||
GUI.log(chrome.i18n.getMessage('mixerSaved'));
|
||||
SERVO_RULES.cleanup();
|
||||
MOTOR_RULES.cleanup();
|
||||
});
|
||||
|
||||
function loadHtml() {
|
||||
$('#content').load("./tabs/mixer.html", processHtml);
|
||||
}
|
||||
|
||||
function processHtml() {
|
||||
|
||||
function fillMixerPreset() {
|
||||
let mixers = helper.mixer.getByPlatform(MIXER_CONFIG.platformType);
|
||||
|
||||
$mixerPreset.find("*").remove();
|
||||
for (i in mixers) {
|
||||
if (mixers.hasOwnProperty(i)) {
|
||||
let m = mixers[i];
|
||||
$mixerPreset.append('<option value="' + m.id + '">' + m.name + '</option>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let $platformSelect = $('#platform-type'),
|
||||
platforms = helper.platform.getList(),
|
||||
$hasFlapsWrapper = $('#has-flaps-wrapper'),
|
||||
$hasFlaps = $('#has-flaps'),
|
||||
$mixerPreset = $('#mixer-preset');
|
||||
|
||||
$platformSelect.find("*").remove();
|
||||
|
||||
for (i in platforms) {
|
||||
if (platforms.hasOwnProperty(i)) {
|
||||
let p = platforms[i];
|
||||
$platformSelect.append('<option value="' + p.id + '">' + p.name + '</option>');
|
||||
}
|
||||
}
|
||||
|
||||
$platformSelect.change(function () {
|
||||
MIXER_CONFIG.platformType = parseInt($platformSelect.val(), 10);
|
||||
currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType);
|
||||
|
||||
if (currentPlatform.flapsPossible) {
|
||||
$hasFlapsWrapper.removeClass('is-hidden');
|
||||
} else {
|
||||
$hasFlapsWrapper.addClass('is-hidden');
|
||||
}
|
||||
|
||||
fillMixerPreset();
|
||||
$mixerPreset.change();
|
||||
});
|
||||
|
||||
currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType);
|
||||
$platformSelect.val(MIXER_CONFIG.platformType).change();
|
||||
|
||||
$mixerPreset.change(function () {
|
||||
currentMixerPreset = helper.mixer.getById(parseInt($mixerPreset.val(), 10));
|
||||
|
||||
$('.mixerPreview img').attr('src', './resources/motor_order/'
|
||||
+ currentMixerPreset.image + '.svg');
|
||||
});
|
||||
|
||||
if (MIXER_CONFIG.appliedMixerPreset > -1) {
|
||||
$mixerPreset.val(MIXER_CONFIG.appliedMixerPreset).change();
|
||||
} else {
|
||||
$mixerPreset.change();
|
||||
}
|
||||
|
||||
localize();
|
||||
GUI.content_ready(callback);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TABS.mixer.cleanup = function (callback) {
|
||||
if (callback) callback();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue