Support for MSP_NAME

10.3.x-maintenance
KiteAnton 2016-07-13 23:32:18 +02:00
parent f5a34f7a9d
commit aab0035d92
5 changed files with 75 additions and 5 deletions

View File

@ -1751,8 +1751,15 @@
},
"pidTuningRatesTip": {
"message": "Play with the rates and see how those affect the stick curve"
},
"configurationMisc": {
"message": "Misc"
},
"configurationVesselName": {
"message": "Vessel name"
}

View File

@ -58,7 +58,8 @@ var FC = {
mode: 0,
profile: 0,
uid: [0, 0, 0],
accelerometerTrims: [0, 0]
accelerometerTrims: [0, 0],
name: ''
};
BF_CONFIG = {

View File

@ -8,6 +8,9 @@ var MSP_codes = {
MSP_BOARD_INFO: 4,
MSP_BUILD_INFO: 5,
MSP_NAME: 10,
MSP_SET_NAME: 11,
// MSP commands for Cleanflight original features
MSP_CHANNEL_FORWARDING: 32,
MSP_SET_CHANNEL_FORWARDING: 33,
@ -731,6 +734,19 @@ var MSP = {
offset+=2;
break;
case MSP_codes.MSP_NAME:
var offset = 0;
var name = '';
var letter;
do {
letter = String.fromCharCode(data.getUint8(offset++));
if (letter != '\0') {
name += letter;
}
} while (letter != '\0' && offset < 100);
CONFIG.name = name;
break;
case MSP_codes.MSP_SET_CHANNEL_FORWARDING:
console.log('Channel forwarding saved');
break;
@ -1082,6 +1098,10 @@ var MSP = {
break;
case MSP_codes.MSP_SET_VTX_CONFIG:
break;
case MSP_codes.MSP_SET_NAME:
console.log('Name set');
break;
default:
console.log('Unknown code detected: ' + code);
} else {
@ -1485,6 +1505,14 @@ MSP.crunch = function (code) {
buffer.push(SENSOR_CONFIG.baro_hardware);
buffer.push(SENSOR_CONFIG.mag_hardware);
break;
case MSP_codes.MSP_SET_NAME:
for (var i = 0; i<32; i++) {
buffer.push(CONFIG.name.charCodeAt(i));
}
break;
default:
return false;
}

View File

@ -485,6 +485,18 @@
</div>
</div>
</div>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationMisc"></div>
</div>
<div class="spacer_box">
<div class="number">
<label> <input type="text" name="vesselName"/> <span
i18n="configurationVesselName"></span>
</label>
</div>
</div>
</div>
</div>
<div class="rightWrapper other">
<div class="gui_box grey">

View File

@ -89,7 +89,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_advanced_tuning() {
var next_callback = load_html;
var next_callback = load_name;
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
MSP.send_message(MSP_codes.MSP_ADVANCED_TUNING, false, false, next_callback);
} else {
@ -97,6 +97,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function load_name() {
var next_callback = load_html;
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
MSP.send_message(MSP_codes.MSP_NAME, false, false, next_callback);
} else {
next_callback();
}
}
//Update Analog/Battery Data
@ -388,6 +396,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('.hardwareSelection').hide();
}
$('input[name="vesselName"]').val(CONFIG.name);
// generate GPS
var gpsProtocols = [
@ -711,7 +721,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_advanced_tuning() {
var next_callback = save_to_eeprom;
var next_callback = save_name;
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
@ -723,6 +733,17 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function save_name() {
var next_callback = save_to_eeprom;
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
CONFIG.name = $.trim($('input[name="vesselName"]').val());
MSP.send_message(MSP_codes.MSP_SET_NAME, MSP.crunch(MSP_codes.MSP_SET_NAME), false, next_callback);
} else {
next_callback();
}
}
function save_to_eeprom() {
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, reboot);
}
@ -754,7 +775,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
MSP.send_message(MSP_codes.MSP_SET_BF_CONFIG, MSP.crunch(MSP_codes.MSP_SET_BF_CONFIG), false, save_serial_config);
// MSP.send_message(MSP_codes.MSP_SET_BF_CONFIG, MSP.crunch(MSP_codes.MSP_SET_BF_CONFIG), false, save_serial_config);
save_name();
});
// status data pulled via separate timer with static speed