mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 20:10:11 +03:00
Add support for changing the craft name
Uses MSP_NAME/MSP_SET_NAME to get and set it. A new section was added to the Configuration tab which includes an input for the name. Also, some CSS changes to allow wider fields for string inputs.
This commit is contained in:
parent
007d4f9694
commit
824a0d5f8b
6 changed files with 106 additions and 5 deletions
|
@ -735,6 +735,15 @@
|
||||||
"configurationSPIProtocol": {
|
"configurationSPIProtocol": {
|
||||||
"message": "RX SPI protocol"
|
"message": "RX SPI protocol"
|
||||||
},
|
},
|
||||||
|
"configurationPersonalization": {
|
||||||
|
"message": "Personalization"
|
||||||
|
},
|
||||||
|
"configurationCraftName": {
|
||||||
|
"message": "Craft Name"
|
||||||
|
},
|
||||||
|
"configurationCraftNameHelp": {
|
||||||
|
"message": "Craft name. Can be displayed by OSD and by compatible RC systems."
|
||||||
|
},
|
||||||
"configurationEepromSaved": {
|
"configurationEepromSaved": {
|
||||||
"message": "EEPROM <span style=\"color: #37a8db\">saved</span>"
|
"message": "EEPROM <span style=\"color: #37a8db\">saved</span>"
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,6 +10,9 @@ var MSPCodes = {
|
||||||
MSP_INAV_PID: 6,
|
MSP_INAV_PID: 6,
|
||||||
MSP_SET_INAV_PID: 7,
|
MSP_SET_INAV_PID: 7,
|
||||||
|
|
||||||
|
MSP_NAME: 10,
|
||||||
|
MSP_SET_NAME: 11,
|
||||||
|
|
||||||
MSP_NAV_POSHOLD: 12,
|
MSP_NAV_POSHOLD: 12,
|
||||||
MSP_SET_NAV_POSHOLD: 13,
|
MSP_SET_NAV_POSHOLD: 13,
|
||||||
MSP_CALIBRATION_DATA: 14,
|
MSP_CALIBRATION_DATA: 14,
|
||||||
|
|
|
@ -1115,6 +1115,11 @@ var mspHelper = (function (gui) {
|
||||||
case MSPCodes.MSP_OSD_CHAR_WRITE:
|
case MSPCodes.MSP_OSD_CHAR_WRITE:
|
||||||
console.log('OSD char uploaded');
|
console.log('OSD char uploaded');
|
||||||
break;
|
break;
|
||||||
|
case MSPCodes.MSP_NAME:
|
||||||
|
break;
|
||||||
|
case MSPCodes.MSP_SET_NAME:
|
||||||
|
console.log("Craft name set");
|
||||||
|
break;
|
||||||
case MSPCodes.MSPV2_SETTING:
|
case MSPCodes.MSPV2_SETTING:
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSPV2_SET_SETTING:
|
case MSPCodes.MSPV2_SET_SETTING:
|
||||||
|
@ -2517,6 +2522,39 @@ var mspHelper = (function (gui) {
|
||||||
self.loadServoMixRules = function (callback) {
|
self.loadServoMixRules = function (callback) {
|
||||||
MSP.send_message(MSPCodes.MSP_SERVO_MIX_RULES, false, false, callback);
|
MSP.send_message(MSPCodes.MSP_SERVO_MIX_RULES, false, false, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.getCraftName = function(callback) {
|
||||||
|
if (semver.gt(CONFIG.flightControllerVersion, "1.8.0")) {
|
||||||
|
MSP.send_message(MSPCodes.MSP_NAME, false, false, function(resp) {
|
||||||
|
var name = "";
|
||||||
|
for (var ii = 0; ii < resp.data.byteLength; ii++) {
|
||||||
|
var c = resp.data.readU8();
|
||||||
|
if (c != 0) {
|
||||||
|
name += String.fromCharCode(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (callback) {
|
||||||
|
callback(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (callback) {
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setCraftName = function(name, callback) {
|
||||||
|
if (semver.gt(CONFIG.flightControllerVersion, "1.8.0")) {
|
||||||
|
var data = [];
|
||||||
|
name = name || "";
|
||||||
|
for (var ii = 0; ii < name.length; ii++) {
|
||||||
|
data.push(name.charCodeAt(ii));
|
||||||
|
}
|
||||||
|
MSP.send_message(MSPCodes.MSP_SET_NAME, data, false, callback);
|
||||||
|
} else if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
})(GUI);
|
})(GUI);
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-section .number input,
|
.config-section input,
|
||||||
.tab-configuration .number input {
|
.tab-configuration input {
|
||||||
width: 65px;
|
|
||||||
padding-left: 3px;
|
padding-left: 3px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
@ -34,8 +33,17 @@
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-configuration .number .disabled {
|
.config-section .number input,
|
||||||
|
.tab-configuration .number input {
|
||||||
width: 65px;
|
width: 65px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-section .string input,
|
||||||
|
.tab-configuration .string input {
|
||||||
|
width: 130px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-configuration .disabled {
|
||||||
background-color: #ececec;
|
background-color: #ececec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +234,10 @@ hr {
|
||||||
left: 2em;
|
left: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.config-section .string label {
|
||||||
|
left: 175px;
|
||||||
|
}
|
||||||
|
|
||||||
.config-section .radio input {
|
.config-section .radio input {
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
|
|
|
@ -212,6 +212,21 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="config-section gui_box grey config-personalization">
|
||||||
|
<div class="gui_box_titlebar">
|
||||||
|
<div class="spacer_box_title" data-i18n="configurationPersonalization"></div>
|
||||||
|
</div>
|
||||||
|
<div class="spacer_box">
|
||||||
|
<div class="string">
|
||||||
|
<input maxlength="16" id="craft_name" name="craft_name" />
|
||||||
|
<label for="craft_name">
|
||||||
|
<span data-i18n="configurationCraftName"></span>
|
||||||
|
</label>
|
||||||
|
<div class="helpicon cf_tip" data-i18n_title="configurationCraftNameHelp"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--Right column begins here-->
|
<!--Right column begins here-->
|
||||||
|
|
|
@ -10,6 +10,18 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||||
googleAnalytics.sendAppView('Configuration');
|
googleAnalytics.sendAppView('Configuration');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var craftName = null;
|
||||||
|
var loadCraftName = function(callback) {
|
||||||
|
mspHelper.getCraftName(function(name) {
|
||||||
|
craftName = name;
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var saveCraftName = function(callback) {
|
||||||
|
mspHelper.setCraftName(craftName, callback);
|
||||||
|
};
|
||||||
|
|
||||||
var loadChainer = new MSPChainerClass();
|
var loadChainer = new MSPChainerClass();
|
||||||
|
|
||||||
loadChainer.setChain([
|
loadChainer.setChain([
|
||||||
|
@ -22,7 +34,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||||
mspHelper.loadSensorAlignment,
|
mspHelper.loadSensorAlignment,
|
||||||
mspHelper.loadAdvancedConfig,
|
mspHelper.loadAdvancedConfig,
|
||||||
mspHelper.loadINAVPidConfig,
|
mspHelper.loadINAVPidConfig,
|
||||||
mspHelper.loadSensorConfig
|
mspHelper.loadSensorConfig,
|
||||||
|
loadCraftName
|
||||||
]);
|
]);
|
||||||
loadChainer.setExitPoint(load_html);
|
loadChainer.setExitPoint(load_html);
|
||||||
loadChainer.execute();
|
loadChainer.execute();
|
||||||
|
@ -41,6 +54,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||||
mspHelper.saveAdvancedConfig,
|
mspHelper.saveAdvancedConfig,
|
||||||
mspHelper.saveINAVPidConfig,
|
mspHelper.saveINAVPidConfig,
|
||||||
mspHelper.saveSensorConfig,
|
mspHelper.saveSensorConfig,
|
||||||
|
saveCraftName,
|
||||||
mspHelper.saveToEeprom
|
mspHelper.saveToEeprom
|
||||||
]);
|
]);
|
||||||
saveChainer.setExitPoint(reboot);
|
saveChainer.setExitPoint(reboot);
|
||||||
|
@ -597,6 +611,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Craft name
|
||||||
|
if (craftName != null) {
|
||||||
|
$('.config-personalization').show();
|
||||||
|
$('input[name="craft_name"]').val(craftName);
|
||||||
|
} else {
|
||||||
|
// craft name not supported by the firmware
|
||||||
|
$('.config-personalization').hide();
|
||||||
|
}
|
||||||
|
|
||||||
$('a.save').click(function () {
|
$('a.save').click(function () {
|
||||||
// gather data that doesn't have automatic change event bound
|
// gather data that doesn't have automatic change event bound
|
||||||
|
@ -635,6 +657,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||||
SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val());
|
SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val());
|
||||||
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
|
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
|
||||||
|
|
||||||
|
craftName = $('input[name="craft_name"]').val();
|
||||||
|
|
||||||
var rxTypes = FC.getRxTypes();
|
var rxTypes = FC.getRxTypes();
|
||||||
|
|
||||||
function is_using_rx_type(name) {
|
function is_using_rx_type(name) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue