mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
Merge branch 'master' into MrD-Highlight-parameters-that-change-with-profiles-or-battery-profiles
This commit is contained in:
commit
e7c7f2d342
17 changed files with 490 additions and 315 deletions
307
js/model.js
307
js/model.js
|
@ -44,6 +44,7 @@ const
|
|||
|
||||
// generate mixer
|
||||
const mixerList = [
|
||||
// ** Multirotor
|
||||
{
|
||||
id: 1,
|
||||
name: 'Tricopter',
|
||||
|
@ -60,7 +61,7 @@ const mixerList = [
|
|||
servoMixer: [
|
||||
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0),
|
||||
]
|
||||
}, // 1
|
||||
}, // 1
|
||||
{
|
||||
id: 3,
|
||||
name: 'Quad X',
|
||||
|
@ -76,7 +77,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 1.0, -1.0, -1.0), // FRONT_L
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 3
|
||||
}, // 3
|
||||
{
|
||||
id: 2,
|
||||
name: 'Quad +',
|
||||
|
@ -92,7 +93,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 0.0, -1.0, -1.0), // FRONT
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 2
|
||||
}, // 2
|
||||
{
|
||||
id: 4,
|
||||
name: 'Bicopter',
|
||||
|
@ -103,18 +104,7 @@ const mixerList = [
|
|||
platform: PLATFORM_MULTIROTOR,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 4
|
||||
{
|
||||
id: 5,
|
||||
name: 'Gimbal',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_OTHER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 5
|
||||
}, // 4
|
||||
{
|
||||
id: 6,
|
||||
name: 'Y6',
|
||||
|
@ -132,7 +122,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 1.0, -0.666667, 1.0), // UNDER_LEFT
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 6
|
||||
}, // 6
|
||||
{
|
||||
id: 7,
|
||||
name: 'Hex +',
|
||||
|
@ -150,45 +140,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 0.0, 1.0, -1.0), // REAR
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 7
|
||||
{
|
||||
id: 8,
|
||||
name: 'Flying Wing',
|
||||
model: 'flying_wing',
|
||||
image: 'flying_wing',
|
||||
enabled: true,
|
||||
legacy: true,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.0),
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.0),
|
||||
],
|
||||
servoMixer: [
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_ROLL, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_ROLL, -50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
]
|
||||
}, // 8
|
||||
{
|
||||
id: 27,
|
||||
name: 'Flying Wing with differential thrust',
|
||||
model: 'flying_wing',
|
||||
image: 'flying_wing',
|
||||
enabled: true,
|
||||
legacy: false,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.1),
|
||||
new MotorMixRule(1.0, 0.0, 0.0, -0.1)
|
||||
],
|
||||
servoMixer: [
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_ROLL, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_ROLL, -50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
]
|
||||
}, // 27
|
||||
}, // 7
|
||||
{
|
||||
id: 9,
|
||||
name: 'Y4',
|
||||
|
@ -204,7 +156,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 1.0, -1.0, 0.0), // FRONT_L CW
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 9
|
||||
}, // 9
|
||||
{
|
||||
id: 10,
|
||||
name: 'Hex X',
|
||||
|
@ -222,7 +174,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 1.0, 0.0, 1.0), // LEFT
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 10
|
||||
}, // 10
|
||||
{
|
||||
id: 11,
|
||||
name: 'Octo X8',
|
||||
|
@ -242,7 +194,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 1.0, -1.0, 1.0), // UNDER_FRONT_L
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 11
|
||||
}, // 11
|
||||
{
|
||||
id: 12,
|
||||
name: 'Octo Flat +',
|
||||
|
@ -262,7 +214,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 1.0, 0.0, -1.0), // LEFT
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 12
|
||||
}, // 12
|
||||
{
|
||||
id: 13,
|
||||
name: 'Octo Flat X',
|
||||
|
@ -282,51 +234,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 1.0, 0.414178, -1.0), // MIDREAR_L
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 13
|
||||
{
|
||||
id: 14,
|
||||
name: 'Airplane',
|
||||
model: 'twin_plane',
|
||||
image: 'airplane',
|
||||
enabled: true,
|
||||
legacy: true,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
hasFlaps: true,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.0),
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.0),
|
||||
],
|
||||
servoMixer: [
|
||||
new ServoMixRule(SERVO_ELEVATOR, INPUT_STABILIZED_PITCH, 100, 0),
|
||||
new ServoMixRule(SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0),
|
||||
/*new ServoMixRule(SERVO_FLAPPERON_1, INPUT_FEATURE_FLAPS, 100, 0),*/
|
||||
new ServoMixRule(SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0),
|
||||
/*new ServoMixRule(SERVO_FLAPPERON_2, INPUT_FEATURE_FLAPS, -100, 0),*/
|
||||
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0),
|
||||
]
|
||||
}, // 14
|
||||
{
|
||||
id: 15,
|
||||
name: 'Heli 120',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_HELICOPTER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 15
|
||||
{
|
||||
id: 16,
|
||||
name: 'Heli 90',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_HELICOPTER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 16
|
||||
}, // 13
|
||||
{
|
||||
id: 17,
|
||||
name: 'V-tail Quad',
|
||||
|
@ -360,18 +268,7 @@ const mixerList = [
|
|||
new MotorMixRule(1.0, 0.0, 0.0, 0.0), // LEFT
|
||||
],
|
||||
servoMixer: []
|
||||
}, // 18
|
||||
{
|
||||
id: 19,
|
||||
name: 'PPM to SERVO',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_OTHER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 19
|
||||
}, // 18
|
||||
{
|
||||
id: 20,
|
||||
name: 'Dualcopter',
|
||||
|
@ -382,7 +279,7 @@ const mixerList = [
|
|||
platform: PLATFORM_MULTIROTOR,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 20
|
||||
}, // 20
|
||||
{
|
||||
id: 21,
|
||||
name: 'Singlecopter',
|
||||
|
@ -393,7 +290,7 @@ const mixerList = [
|
|||
platform: PLATFORM_MULTIROTOR,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 21
|
||||
}, // 21
|
||||
{
|
||||
id: 22,
|
||||
name: 'A-tail Quad',
|
||||
|
@ -420,18 +317,7 @@ const mixerList = [
|
|||
platform: PLATFORM_MULTIROTOR,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 23
|
||||
{
|
||||
id: 24,
|
||||
name: 'Custom Airplane',
|
||||
model: 'twin_plane',
|
||||
image: 'airplane',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 24
|
||||
}, // 23
|
||||
{
|
||||
id: 25,
|
||||
name: 'Custom Tricopter',
|
||||
|
@ -442,7 +328,67 @@ const mixerList = [
|
|||
platform: PLATFORM_TRICOPTER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 25
|
||||
}, // 25
|
||||
|
||||
// ** Fixed Wing **
|
||||
{
|
||||
id: 8,
|
||||
name: 'Flying Wing',
|
||||
model: 'flying_wing',
|
||||
image: 'flying_wing',
|
||||
enabled: true,
|
||||
legacy: true,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.0),
|
||||
],
|
||||
servoMixer: [
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_ROLL, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_ROLL, -50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
]
|
||||
}, // 8
|
||||
{
|
||||
id: 27,
|
||||
name: 'Flying Wing with differential thrust',
|
||||
model: 'flying_wing',
|
||||
image: 'flying_wing',
|
||||
enabled: true,
|
||||
legacy: false,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.1),
|
||||
new MotorMixRule(1.0, 0.0, 0.0, -0.1)
|
||||
],
|
||||
servoMixer: [
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_ROLL, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_ROLL, -50, 0),
|
||||
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
]
|
||||
}, // 27
|
||||
{
|
||||
id: 14,
|
||||
name: 'Airplane',
|
||||
model: 'twin_plane',
|
||||
image: 'airplane',
|
||||
enabled: true,
|
||||
legacy: true,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
hasFlaps: true,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.0),
|
||||
],
|
||||
servoMixer: [
|
||||
new ServoMixRule(SERVO_ELEVATOR, INPUT_STABILIZED_PITCH, 100, 0),
|
||||
new ServoMixRule(SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0),
|
||||
/*new ServoMixRule(SERVO_FLAPPERON_1, INPUT_FEATURE_FLAPS, 100, 0),*/
|
||||
new ServoMixRule(SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0),
|
||||
/*new ServoMixRule(SERVO_FLAPPERON_2, INPUT_FEATURE_FLAPS, -100, 0),*/
|
||||
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0),
|
||||
]
|
||||
}, // 14
|
||||
{
|
||||
id: 26,
|
||||
name: 'Airplane with differential thrust',
|
||||
|
@ -464,10 +410,10 @@ const mixerList = [
|
|||
/*new ServoMixRule(SERVO_FLAPPERON_2, INPUT_FEATURE_FLAPS, -100, 0),*/
|
||||
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0),
|
||||
]
|
||||
},
|
||||
}, // 26
|
||||
{
|
||||
id: 28,
|
||||
name: 'Airplane V-tail (individual aileron servos)',
|
||||
name: 'Airplane V-tail',
|
||||
model: 'vtail_plane',
|
||||
image: 'airplane_vtail',
|
||||
enabled: true,
|
||||
|
@ -487,7 +433,31 @@ const mixerList = [
|
|||
new ServoMixRule(4, INPUT_STABILIZED_PITCH, -50, 0),
|
||||
new ServoMixRule(4, INPUT_STABILIZED_YAW, -50, 0)
|
||||
]
|
||||
},
|
||||
}, // 28
|
||||
{
|
||||
id: 34,
|
||||
name: 'Airplane V-tail with differential thrust',
|
||||
model: 'vtail_plane',
|
||||
image: 'airplane_vtail',
|
||||
enabled: true,
|
||||
legacy: false,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
hasFlaps: true,
|
||||
motorMixer: [
|
||||
new MotorMixRule(1.0, 0.0, 0.0, 0.3),
|
||||
new MotorMixRule(1.0, 0.0, 0.0, -0.3)
|
||||
],
|
||||
servoMixer: [
|
||||
new ServoMixRule(1, INPUT_STABILIZED_ROLL, 100, 0),
|
||||
/*new ServoMixRule(1, INPUT_FEATURE_FLAPS, 100, 0),*/
|
||||
new ServoMixRule(2, INPUT_STABILIZED_ROLL, 100, 0),
|
||||
/*new ServoMixRule(2, INPUT_FEATURE_FLAPS, 100, 0),*/
|
||||
new ServoMixRule(3, INPUT_STABILIZED_PITCH, 50, 0),
|
||||
new ServoMixRule(3, INPUT_STABILIZED_YAW, -50, 0),
|
||||
new ServoMixRule(4, INPUT_STABILIZED_PITCH, -50, 0),
|
||||
new ServoMixRule(4, INPUT_STABILIZED_YAW, -50, 0)
|
||||
]
|
||||
}, // 34
|
||||
{
|
||||
id: 29,
|
||||
name: 'Airplane V-tail (single aileron servo)',
|
||||
|
@ -506,7 +476,7 @@ const mixerList = [
|
|||
new ServoMixRule(3, INPUT_STABILIZED_PITCH, -50, 0),
|
||||
new ServoMixRule(3, INPUT_STABILIZED_YAW, -50, 0),
|
||||
]
|
||||
},
|
||||
}, //29
|
||||
{
|
||||
id: 30,
|
||||
name: 'Airplane without rudder',
|
||||
|
@ -526,7 +496,44 @@ const mixerList = [
|
|||
new ServoMixRule(SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0),
|
||||
/*new ServoMixRule(SERVO_FLAPPERON_2, INPUT_FEATURE_FLAPS, 100, 0),*/
|
||||
]
|
||||
},
|
||||
}, // 30
|
||||
{
|
||||
id: 24,
|
||||
name: 'Custom Airplane',
|
||||
model: 'twin_plane',
|
||||
image: 'airplane',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_AIRPLANE,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 24
|
||||
|
||||
// ** Helicopter **
|
||||
{
|
||||
id: 15,
|
||||
name: 'Heli 120',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_HELICOPTER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 15
|
||||
{
|
||||
id: 16,
|
||||
name: 'Heli 90',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_HELICOPTER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 16
|
||||
|
||||
// ** Other platforms **
|
||||
{
|
||||
id: 31,
|
||||
name: 'Rover',
|
||||
|
@ -556,8 +563,8 @@ const mixerList = [
|
|||
servoMixer: [
|
||||
new ServoMixRule(3, INPUT_STABILIZED_YAW, 100, 0),
|
||||
]
|
||||
}
|
||||
,
|
||||
},
|
||||
// ** Misc **
|
||||
{
|
||||
id: 33,
|
||||
name: 'Other',
|
||||
|
@ -572,7 +579,29 @@ const mixerList = [
|
|||
servoMixer: [
|
||||
new ServoMixRule(3, INPUT_STABILIZED_YAW, 100, 0),
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Gimbal',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_OTHER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 5
|
||||
{
|
||||
id: 19,
|
||||
name: 'PPM to SERVO',
|
||||
model: 'custom',
|
||||
image: 'custom',
|
||||
enabled: false,
|
||||
legacy: true,
|
||||
platform: PLATFORM_OTHER,
|
||||
motorMixer: [],
|
||||
servoMixer: []
|
||||
}, // 19
|
||||
];
|
||||
|
||||
const platformList = [
|
||||
|
|
|
@ -7,9 +7,9 @@ var MotorMixRule = function (throttle, roll, pitch, yaw) {
|
|||
|
||||
self.fromMsp = function (mspThrottle, mspRoll, mspPitch, mspYaw) {
|
||||
throttle = mspThrottle / 1000;
|
||||
roll = (mspRoll / 1000) - 2;
|
||||
pitch = (mspPitch / 1000) - 2;
|
||||
yaw = (mspYaw / 1000) - 2;
|
||||
roll = Math.round(((mspRoll / 1000) - 2) * 1000) / 1000;
|
||||
pitch = Math.round(((mspPitch / 1000) - 2) * 1000) / 1000;
|
||||
yaw = Math.round(((mspYaw / 1000) - 2) * 1000) / 1000;
|
||||
};
|
||||
|
||||
self.isUsed = function () {
|
||||
|
|
|
@ -99,5 +99,20 @@ let ServoMixerRuleCollection = function () {
|
|||
});
|
||||
}
|
||||
|
||||
self.getNextUnusedIndex = function() {
|
||||
let nextTarget = 0;
|
||||
|
||||
for (let ruleIndex in data) {
|
||||
if (data.hasOwnProperty(ruleIndex)) {
|
||||
let target = data[ruleIndex].getTarget();
|
||||
if (target > nextTarget) {
|
||||
nextTarget = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nextTarget+1;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
159
js/settings.js
159
js/settings.js
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const GulpClient = require("gulp");
|
||||
|
||||
var Settings = (function () {
|
||||
let self = {};
|
||||
|
||||
|
@ -38,6 +40,8 @@ var Settings = (function () {
|
|||
}
|
||||
parent.show();
|
||||
|
||||
input.prop('title', 'CLI: ' + input.data('setting'));
|
||||
|
||||
if (input.prop('tagName') == 'SELECT' || s.setting.table) {
|
||||
if (input.attr('type') == 'checkbox') {
|
||||
input.prop('checked', s.value > 0);
|
||||
|
@ -79,9 +83,9 @@ var Settings = (function () {
|
|||
input.val(s.value.toFixed(2));
|
||||
} else {
|
||||
var multiplier = parseFloat(input.data('setting-multiplier') || 1);
|
||||
input.attr('type', 'number');
|
||||
input.val((s.value / multiplier).toFixed(Math.log10(multiplier)));
|
||||
|
||||
input.val((s.value / multiplier).toFixed(Math.log10(multiplier)));
|
||||
input.attr('type', 'number');
|
||||
if (typeof s.setting.min !== 'undefined' && s.setting.min !== null) {
|
||||
input.attr('min', (s.setting.min / multiplier).toFixed(Math.log10(multiplier)));
|
||||
}
|
||||
|
@ -146,22 +150,39 @@ var Settings = (function () {
|
|||
|
||||
//display names for the units
|
||||
const unitDisplayDames = {
|
||||
// Misc
|
||||
'us' : "uS",
|
||||
'deg' : '°',
|
||||
'cdeg' : 'centi°',
|
||||
'cmss' : 'cm/s/s',
|
||||
'cm' : 'cm',
|
||||
'cms' : 'cm/s',
|
||||
'm' : 'm',
|
||||
'ms' : 'ms',
|
||||
'mps' : 'm/s',
|
||||
'kmh' : 'Km/h',
|
||||
'sec' : 's',
|
||||
'kt' : 'Kt',
|
||||
'ft' : 'ft',
|
||||
'mph' : 'mph',
|
||||
'cw' : 'cW',
|
||||
'percent' : '%'
|
||||
'percent' : '%',
|
||||
'cmss' : 'cm/s/s',
|
||||
// Time
|
||||
'msec' : 'ms',
|
||||
'dsec' : 'ds',
|
||||
'sec' : 's',
|
||||
// Angles
|
||||
'deg' : '°',
|
||||
'decideg' : 'deci°',
|
||||
// Temperature
|
||||
'decidegc' : 'deci°C',
|
||||
'degc' : '°C',
|
||||
'degf' : '°F',
|
||||
// Speed
|
||||
'cms' : 'cm/s',
|
||||
'v-cms' : 'cm/s',
|
||||
'ms' : 'm/s',
|
||||
'kmh' : 'Km/h',
|
||||
'mph' : 'mph',
|
||||
'hftmin' : 'x100 ft/min',
|
||||
'fts' : 'ft/s',
|
||||
'kt' : 'Kt',
|
||||
// Distance
|
||||
'cm' : 'cm',
|
||||
'm' : 'm',
|
||||
'km' : 'Km',
|
||||
'm-lrg' : 'm', // Metres, but converted to larger units
|
||||
'ft' : 'ft',
|
||||
'mi' : 'mi',
|
||||
'nm' : 'NM'
|
||||
}
|
||||
|
||||
|
||||
|
@ -179,51 +200,97 @@ var Settings = (function () {
|
|||
'm' : 100,
|
||||
'ft' : 30.48
|
||||
},
|
||||
'cms' : {
|
||||
'm' : {
|
||||
'm' : 1,
|
||||
'ft' : 0.3048
|
||||
},
|
||||
'm-lrg' : {
|
||||
'km' : 1000,
|
||||
'mi' : 1609.344,
|
||||
'nm' : 1852
|
||||
},
|
||||
'cms' : { // Horizontal speed
|
||||
'kmh' : 27.77777777777778,
|
||||
'kt': 51.44444444444457,
|
||||
'mph' : 44.704,
|
||||
'mps' : 100
|
||||
'ms' : 100
|
||||
},
|
||||
'ms' : {
|
||||
'v-cms' : { // Vertical speed
|
||||
'ms' : 100,
|
||||
'hftmin' : 50.8,
|
||||
'fts' : 30.48
|
||||
},
|
||||
'msec' : {
|
||||
'sec' : 1000
|
||||
},
|
||||
'cdeg' : {
|
||||
'dsec' : {
|
||||
'sec' : 10
|
||||
},
|
||||
'decideg' : {
|
||||
'deg' : 10
|
||||
},
|
||||
'decidegc' : {
|
||||
'degc' : 10,
|
||||
'degf' : 'FAHREN'
|
||||
},
|
||||
};
|
||||
|
||||
//this holds which units get converted in which unit systems
|
||||
const conversionTable = {
|
||||
0: { //imperial
|
||||
'cm' : 'ft',
|
||||
'm' : 'ft',
|
||||
'm-lrg' : 'mi',
|
||||
'cms' : 'mph',
|
||||
'cdeg' : 'deg',
|
||||
'ms' : 'sec'
|
||||
'v-cms' : 'fts',
|
||||
'msec' : 'sec',
|
||||
'dsec' : 'sec',
|
||||
'decideg' : 'deg',
|
||||
'decidegc' : 'degf',
|
||||
},
|
||||
1: {//metric
|
||||
1: { //metric
|
||||
'cm': 'm',
|
||||
'm' : 'm',
|
||||
'm-lrg' : 'km',
|
||||
'cms' : 'kmh',
|
||||
'ms' : 'sec',
|
||||
'cdeg' : 'deg'
|
||||
'v-cms' : 'ms',
|
||||
'msec' : 'sec',
|
||||
'dsec' : 'sec',
|
||||
'decideg' : 'deg',
|
||||
'decidegc' : 'degc',
|
||||
},
|
||||
2: { //metric with MPH
|
||||
'cm': 'm',
|
||||
'm' : 'm',
|
||||
'm-lrg' : 'km',
|
||||
'cms' : 'mph',
|
||||
'cdeg' : 'deg',
|
||||
'ms' : 'sec'
|
||||
'v-cms' : 'ms',
|
||||
'decideg' : 'deg',
|
||||
'msec' : 'sec',
|
||||
'dsec' : 'sec',
|
||||
'decidegc' : 'degc',
|
||||
},
|
||||
3:{ //UK
|
||||
'cm' : 'ft',
|
||||
'm' : 'ft',
|
||||
'm-lrg' : 'mi',
|
||||
'cms' : 'mph',
|
||||
'cdeg' : 'deg',
|
||||
'ms' : 'sec'
|
||||
'v-cms' : 'fts',
|
||||
'decideg' : 'deg',
|
||||
'msec' : 'sec',
|
||||
'dsec' : 'sec',
|
||||
'decidegc' : 'degc',
|
||||
},
|
||||
4: { //General aviation
|
||||
'cm' : 'ft',
|
||||
'm' : 'ft',
|
||||
'm-lrg' : 'nm',
|
||||
'cms': 'kt',
|
||||
'cdeg' : 'deg',
|
||||
'ms' : 'sec'
|
||||
'v-cms' : 'hftmin',
|
||||
'decideg' : 'deg',
|
||||
'msec' : 'sec',
|
||||
'dsec' : 'sec',
|
||||
'decidegc' : 'degc',
|
||||
},
|
||||
default:{}//show base units
|
||||
};
|
||||
|
@ -249,18 +316,31 @@ var Settings = (function () {
|
|||
// Update the step, min, and max; as we have the multiplier here.
|
||||
if (element.attr('type') == 'number') {
|
||||
element.attr('step', ((multiplier != 1) ? '0.01' : '1'));
|
||||
element.attr('min', (element.attr('min') / multiplier).toFixed(2));
|
||||
element.attr('max', (element.attr('max') / multiplier).toFixed(2));
|
||||
if (multiplier != 'FAHREN') {
|
||||
element.attr('min', (element.attr('min') / multiplier).toFixed(2));
|
||||
element.attr('max', (element.attr('max') / multiplier).toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the input with a new formatted unit
|
||||
const convertedValue = Number((oldValue / multiplier).toFixed(2));
|
||||
const newValue = Number.isInteger(convertedValue) ? Math.round(convertedValue) : convertedValue;
|
||||
let newValue = "";
|
||||
if (multiplier == 'FAHREN') {
|
||||
element.attr('min', toFahrenheit(element.attr('min')).toFixed(2));
|
||||
element.attr('max', toFahrenheit(element.attr('max')).toFixed(2));
|
||||
newValue = toFahrenheit(oldValue).toFixed(2);
|
||||
} else {
|
||||
const convertedValue = Number((oldValue / multiplier).toFixed(2));
|
||||
newValue = Number.isInteger(convertedValue) ? Math.round(convertedValue) : convertedValue;
|
||||
}
|
||||
element.val(newValue);
|
||||
element.data('setting-multiplier', multiplier);
|
||||
|
||||
// Now wrap the input in a display that shows the unit
|
||||
element.wrap(`<div data-unit="${unitDisplayDames[unitName]}" class="unit_wrapper unit"></div>`);
|
||||
|
||||
function toFahrenheit(decidegC) {
|
||||
return (decidegC / 10) * 1.8 + 32;
|
||||
};
|
||||
}
|
||||
|
||||
self.saveInput = function(input) {
|
||||
|
@ -281,8 +361,13 @@ var Settings = (function () {
|
|||
} else if(setting.type == 'string') {
|
||||
value = input.val();
|
||||
} else {
|
||||
var multiplier = parseFloat(input.data('setting-multiplier') || 1);
|
||||
value = parseFloat(input.val()) * multiplier;
|
||||
var multiplier = input.data('setting-multiplier') || 1;
|
||||
if (multiplier == 'FAHREN') {
|
||||
value = Math.round(((parseFloat(input.val())-32) / 1.8) * 10);
|
||||
} else {
|
||||
multiplier = parseFloat(multiplier);
|
||||
value = Math.round(parseFloat(input.val()) * multiplier);
|
||||
}
|
||||
}
|
||||
return mspHelper.setSetting(settingName, value);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue