Merge pull request #51 from iNavFlight/esc-protocol-select

UI fixes done, @digitalentity tested, merging
pull/54/head^2
Paweł Spychalski 8 years ago committed by GitHub
commit 6c4075bc43

@ -1696,5 +1696,11 @@
},
"boardLimitedFunctionality": {
"message": "Due to limited flash size, the board you have selected will have limited functionality, not all functions and features will be available. Hardware support map is available on <a href=\"https://github.com/iNavFlight/inav/wiki/Hardware-support-map\" target=\"_blank\">INAV Wiki pages</a>"
},
"escProtocol": {
"message": "ESC protocol"
},
"escRefreshRate": {
"message" : "ESC refresh rate"
}
}

@ -37,6 +37,7 @@ var SENSOR_ALIGNMENT;
var RX_CONFIG;
var FAILSAFE_CONFIG;
var RXFAIL_CONFIG;
var ADVANCED_CONFIG;
var FC = {
isRatesInDps: function () {
@ -199,6 +200,16 @@ var FC = {
vbatwarningcellvoltage: 0
};
ADVANCED_CONFIG = {
gyroSyncDenominator: null,
pidProcessDenom: null,
useUnsyncedPwm: null,
motorPwmProtocol: null,
motorPwmRate: null,
servoPwmRate: null,
gyroSync: null
};
_3D = {
deadband3d_low: 0,
deadband3d_high: 0,

@ -43,6 +43,9 @@ var MSP_codes = {
MSP_TRANSPONDER_CONFIG: 82,
MSP_SET_TRANSPONDER_CONFIG: 83,
MSP_ADVANCED_CONFIG: 90,
MSP_SET_ADVANCED_CONFIG: 91,
// Multiwii MSP commands
MSP_IDENT: 100,
MSP_STATUS: 101,
@ -1070,6 +1073,28 @@ var MSP = {
case MSP_codes.MSP_SET_TRANSPONDER_CONFIG:
console.log("Transponder config saved");
break;
case MSP_codes.MSP_ADVANCED_CONFIG:
var offset = 0;
ADVANCED_CONFIG.gyroSyncDenominator = data.getUint8(offset, 1);
offset++;
ADVANCED_CONFIG.pidProcessDenom = data.getUint8(offset, 1);
offset++;
ADVANCED_CONFIG.useUnsyncedPwm = data.getUint8(offset, 1);
offset++;
ADVANCED_CONFIG.motorPwmProtocol = data.getUint8(offset, 1);
offset++;
ADVANCED_CONFIG.motorPwmRate = data.getUint16(offset, 1);
offset += 2;
ADVANCED_CONFIG.servoPwmRate = data.getUint16(offset, 1);
offset += 2;
ADVANCED_CONFIG.gyroSync = data.getUint8(offset, 1);
break;
case MSP_codes.MSP_SET_ADVANCED_CONFIG:
console.log("Advanced config saved");
break;
case MSP_codes.MSP_SET_MODE_RANGE:
console.log('Mode range saved');
break;
@ -1454,6 +1479,21 @@ MSP.crunch = function (code) {
buffer.push(SENSOR_ALIGNMENT.align_mag);
break;
case MSP_codes.MSP_SET_ADVANCED_CONFIG:
buffer.push(ADVANCED_CONFIG.gyroSyncDenominator);
buffer.push(ADVANCED_CONFIG.pidProcessDenom);
buffer.push(ADVANCED_CONFIG.useUnsyncedPwm);
buffer.push(ADVANCED_CONFIG.motorPwmProtocol);
buffer.push(lowByte(ADVANCED_CONFIG.motorPwmRate));
buffer.push(highByte(ADVANCED_CONFIG.motorPwmRate));
buffer.push(lowByte(ADVANCED_CONFIG.servoPwmRate));
buffer.push(highByte(ADVANCED_CONFIG.servoPwmRate));
buffer.push(ADVANCED_CONFIG.gyroSync);
break;
default:
return false;
}

@ -1816,9 +1816,15 @@ input {
@media only screen and (max-height: 700px) , only screen and (max-device-height: 700px) {
.tab_container {
overflow-x: hidden;
overflow-y: auto;
.tab_container {
overflow-x: hidden;
overflow-y: auto;
}
}
}
select {
border: 1px solid silver;
border-radius: 3px;
padding: 1px;
}

@ -60,12 +60,6 @@
background-color: #e4e4e4;
}
.tab-adjustments .adjustment select {
/* outline: 1px solid silver; */
border-radius: 3px;
border: 1px solid silver;
}
.tab-adjustments .adjustment td {
text-align: center;
}
@ -121,4 +115,4 @@
.tab-adjustments .spacebottom {
margin-bottom: 15px;
}
}

@ -124,11 +124,6 @@
padding: 10px 0px;
}
.tab-auxiliary .range .channel {
border: 1px solid silver;
border-radius: 3px;
}
.tab-auxiliary .range .marker {
position: absolute;
left: 50%;
@ -216,4 +211,4 @@
.tab-auxiliary .fixed_band .save_btn a {
margin-right: 15px;
}
}
}

@ -61,7 +61,6 @@
height: 20px;
margin-top: 5px;
font-weight: bold;
border: 1px solid silver;
}
.tab-configuration dl.features dt {
@ -113,7 +112,6 @@
width: 100px;
height: 20px;
margin: 0 10px 5px 0;
border: 1px solid silver;
}
.tab-configuration .gps span {
@ -122,13 +120,11 @@
.tab-configuration .serialRX {
width: 100%;
border: 1px solid silver;
margin-bottom: 5px;
}
.tab-configuration .nrf24Protocol {
width: 100%;
border: 1px solid silver;
margin-bottom: 5px;
}
@ -182,7 +178,7 @@
.tab-configuration .disarm .checkbox {
float: left;
padding-left: 0px;
margin-top: -5px;
/*margin-top: -5px;*/
padding-bottom: 5px;
border-bottom: 1px solid #ddd;
width: 100%;
@ -378,8 +374,6 @@
width: 45%;
height: 20px;
margin: 0 0px 2px 0;
border: 1px solid silver;
border-radius:3px;
}
@ -397,8 +391,6 @@
width: 100%;
height: 20px;
margin: 0 0px 2px 0;
border: 1px solid silver;
border-radius:3px;
margin-bottom: 20px;
margin-top:3px;
@ -454,7 +446,7 @@
}
.tab-configuration .sensoralignment {
width: 50%;
width: 50%;
float: left;
}
@ -500,4 +492,13 @@
.tab-configuration .current .gui_box {
float: left;
}
}
}
#esc-protocols {
display: none;
}
#esc-protocols span {
display: inline-block;
width: 10em;
}

@ -32,12 +32,28 @@
<div class="spacer_box_title" i18n="configurationEscFeatures"></div>
</div>
<div class="spacer_box">
<div id="esc-protocols">
<div class="select">
<label for="esc-protocol"> <span class="freelabel"
i18n="escProtocol"></span>
<select name="esc-protocol" id="esc-protocol"></select>
</div>
<div class="select">
<label for="esc-refresh-rate"> <span class="freelabel"
i18n="escRefreshRate"></span>
<select name="esc-rate" id="esc-rate"></select>
</div>
<div class="clear-both"></div>
</div>
<table cellpadding="0" cellspacing="0">
<tbody class="features esc">
<!-- table generated here -->
</tbody>
</table>
<!-- -->
<div class="disarm">
<div class="checkbox">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
@ -122,7 +138,7 @@
</div>
<div class="sensoralignment">
<div class="select">
<label>
<label>
<span i18n="configurationSensorAlignmentGyro"></span>
<select class="gyroalign">
<option value="0">Default</option>
@ -131,7 +147,7 @@
</label>
</div>
<div class="select">
<label>
<label>
<span i18n="configurationSensorAlignmentAcc"></span>
<select class="accalign">
<option value="0">Default</option>

@ -68,13 +68,23 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_sensor_alignment() {
var next_callback = load_html;
var next_callback = loadAdvancedConfig;
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
MSP.send_message(MSP_codes.MSP_SENSOR_ALIGNMENT, false, false, next_callback);
} else {
next_callback();
}
}
function loadAdvancedConfig() {
var next_callback = load_html;
if (semver.gte(CONFIG.flightControllerVersion, "1.3.0")) {
MSP.send_message(MSP_codes.MSP_ADVANCED_CONFIG, false, false, next_callback);
} else {
next_callback();
}
}
//Update Analog/Battery Data
function load_analog() {
MSP.send_message(MSP_codes.MSP_ANALOG, false, false, function () {
@ -138,10 +148,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
{bit: 15, group: 'rssi', name: 'RSSI_ADC'},
{bit: 16, group: 'other', name: 'LED_STRIP'},
{bit: 17, group: 'other', name: 'DISPLAY'},
{bit: 18, group: 'esc', name: 'ONESHOT125', haveTip: true},
{bit: 19, group: 'other', name: 'BLACKBOX', haveTip: true}
];
if (semver.lt(CONFIG.flightControllerVersion, "1.3.0")) {
features.push(
{bit: 18, group: 'esc', name: 'ONESHOT125', haveTip: true}
);
}
if (semver.gte(CONFIG.apiVersion, "1.12.0")) {
features.push(
{bit: 20, group: 'other', name: 'CHANNEL_FORWARDING'}
@ -436,6 +451,99 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('input[name="currentoffset"]').val(BF_CONFIG.currentoffset);
$('input[name="multiwiicurrentoutput"]').prop('checked', MISC.multiwiicurrentoutput);
var escProtocols = {
0: {
name: "STANDARD",
defaultRate: 400,
rates: {
50: "50Hz",
400: "400Hz"
}
},
1: {
name: "ONESHOT125",
defaultRate: 1000,
rates: {
400: "400Hz",
1000: "1kHz",
2000: "2kHz"
}
},
2: {
name: "ONESHOT42",
defaultRate: 2000,
rates: {
400: "400Hz",
1000: "1kHz",
2000: "2kHz",
4000: "4kHz",
8000: "8kHz"
}
},
3: {
name: "MULTISHOT",
defaultRate: 2000,
rates: {
400: "400Hz",
1000: "1kHz",
2000: "2kHz",
4000: "4kHz",
8000: "8kHz"
}
},
4: {
name: "BRUSHED",
defaultRate: 8000,
rates: {
8000: "8kHz",
16000: "16kHz",
32000: "32kHz"
}
}
};
function buildMotorRates() {
var protocolData = escProtocols[ADVANCED_CONFIG.motorPwmProtocol];
$escRate.find('option').remove();
for (var i in protocolData.rates) {
if (protocolData.rates.hasOwnProperty(i)) {
$escRate.append('<option value="' + i + '">' + protocolData.rates[i] + '</option>');
}
}
}
if (semver.gte(CONFIG.flightControllerVersion, "1.3.0")) {
var $escProtocol = $('#esc-protocol');
var $escRate = $('#esc-rate');
for (var i in escProtocols) {
if (escProtocols.hasOwnProperty(i)) {
var protocolData = escProtocols[i];
$escProtocol.append('<option value="' + i + '">' + protocolData.name + '</option>');
}
}
buildMotorRates();
$escProtocol.val(ADVANCED_CONFIG.motorPwmProtocol);
$escRate.val(ADVANCED_CONFIG.motorPwmRate);
$escProtocol.change(function () {
ADVANCED_CONFIG.motorPwmProtocol = $(this).val();
buildMotorRates();
ADVANCED_CONFIG.motorPwmRate = escProtocols[ADVANCED_CONFIG.motorPwmProtocol].defaultRate;
$escRate.val(ADVANCED_CONFIG.motorPwmRate);
});
$escRate.change(function () {
ADVANCED_CONFIG.motorPwmRate = $(this).val();
});
$("#esc-protocols").show();
}
//fill 3D
if (semver.lt(CONFIG.apiVersion, "1.14.0")) {
$('.tab-configuration .3d').hide();
@ -605,7 +713,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_rx_config() {
var next_callback = save_to_eeprom;
var next_callback = saveAdvancedConfig;
if(semver.gte(CONFIG.apiVersion, "1.21.0")) {
MSP.send_message(MSP_codes.MSP_SET_RX_CONFIG, MSP.crunch(MSP_codes.MSP_SET_RX_CONFIG), false, next_callback);
} else {
@ -613,6 +721,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function saveAdvancedConfig() {
var next_callback = save_to_eeprom;
if(semver.gte(CONFIG.flightControllerVersion, "1.3.0")) {
MSP.send_message(MSP_codes.MSP_SET_ADVANCED_CONFIG, MSP.crunch(MSP_codes.MSP_SET_ADVANCED_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_to_eeprom() {
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, reboot);
}

@ -122,7 +122,7 @@
.tab-failsafe .spacer_box .helpicon {
margin-top: 3px;
margin-right: 0;
}
.tab-failsafe .checkbox:last-child {
@ -190,13 +190,12 @@
float: right;
margin-right: 0;
}
.tab-failsafe .stage1 select {
float: left;
width: 95%;
height: 22px;
margin: 0;
border: 1px solid silver;
}
.tab-failsafe .modename {
@ -212,12 +211,12 @@
}
.tab-failsafe .channelprimary {
float:left;
width:60%;
float:left;
width:60%;
}
.tab-failsafe .channelauxiliary {
float:left;
float:left;
width:60%;
padding-top: 2px;
}
@ -227,13 +226,13 @@
}
.tab-failsafe .channelsetting {
float:left;
width:25%;
float:left;
width:25%;
}
.tab-failsafe .auxiliary {
float:left;
width:15%;
float:left;
width:15%;
}
.tab-failsafe .note {

@ -63,7 +63,6 @@
.tab-pid_tuning .cf select {
margin: 4px;
width: calc(100% - 10px);
border: 1px solid silver;
}
.tab-pid_tuning .rate-tpa th:nth-child(2) {

Loading…
Cancel
Save