Merge remote-tracking branch 'upstream/development' into development

10.3.x-maintenance
Nicholas Sherlock 2015-03-14 10:19:24 +13:00
commit 2863077ee3
16 changed files with 485 additions and 242 deletions

View File

@ -518,9 +518,15 @@
"portsHelp": {
"message": "Configure serial ports. <strong>Note:</strong> not all combinations are valid. When the flight controller firmware detects this the serial port configuration will be reset."
},
"portsFirmwareUpgradeRequired": {
"message": "Firmware upgrade <span style=\"color: red\">required</span>. Serial port configurations of firmware &lt; 1.8.0 is not supported."
},
"portsButtonSave": {
"message": "Save and Reboot"
},
"portsTelemetryDisabled": {
"message": "Disabled"
},
"portsFunction_MSP": {
"message": "MSP"
},
@ -564,12 +570,21 @@
"pidTuningRollPitchRate": {
"message": "ROLL &amp; PITCH rate"
},
"pidTuningRollRate": {
"message": "ROLL rate"
},
"pidTuningPitchRate": {
"message": "PITCH rate"
},
"pidTuningYawRate": {
"message": "YAW rate"
},
"pidTuningTPA": {
"message": "TPA"
},
"pidTuningTPABreakPoint": {
"message": "TPA Breakpoint"
},
"pidTuningButtonSave": {
"message": "Save"
},
@ -887,6 +902,9 @@
"dataflashNotSupportedNote": {
"message": "Your flight controller does not have a compatible dataflash chip available."
},
"dataflashFirmwareUpgradeRequired": {
"message": "Dataflash requires firmware &gt;= 1.8.0."
},
"dataflashButtonSaveFile": {
"message": "Save flash to file..."
},

View File

@ -1,5 +1,8 @@
<span>2015.03.03 - 0.63 - cleanflight</span>
<span>2015.03.11 - 0.63.0 - cleanflight</span>
<p>
- PID Tuning tab allows TPA Breakpoint changes - Requires 1.8.0 firmware.<br />
- Corrected Artificial Horizon Pitch/Roll views.<br />
- Changed logging time stamp to include date stamp.<br />
- Support new firmware 1.8 serial port configuration.<br />
- Move documentation and help to new tab.<br />
- Add contributing section to welcome tab.<br />
@ -437,4 +440,4 @@
- Polished Auxiliary configuration tab<br />
- Polished Raw sensod data tab<br />
- Updated libraries<br />
</p>
</p>

View File

@ -102,7 +102,7 @@ function configuration_backup(callback) {
configuration.RCMAP = jQuery.extend(true, [], RC_MAP);
configuration.BF_CONFIG = jQuery.extend(true, {}, BF_CONFIG);
configuration.SERIAL_CONFIG = jQuery.extend(true, {}, SERIAL_CONFIG);
configuration.LED_STRIP = jQuery.extend(true, {}, LED_STRIP);
configuration.LED_STRIP = jQuery.extend(true, [], LED_STRIP);
save();
}
@ -314,7 +314,7 @@ function configuration_restore(callback) {
GUI.log(chrome.i18n.getMessage('configMigratedTo', [migratedVersion]));
appliedMigrationsCount++;
}
if (!compareVersions(migratedVersion, '0.61.0')) {
// Changing PID controller via UI was added.
@ -330,6 +330,77 @@ function configuration_restore(callback) {
appliedMigrationsCount++;
}
if (!compareVersions(migratedVersion, '0.63.0')) {
// LED Strip was saved as object instead of array.
if (typeof(configuration.LED_STRIP) == 'object') {
var fixed_led_strip = [];
var index = 0;
while (configuration.LED_STRIP[index]) {
fixed_led_strip.push(configuration.LED_STRIP[index++]);
}
configuration.LED_STRIP = fixed_led_strip;
}
// Serial configuation redesigned
var ports = [];
for (var portIndex = 0; portIndex < configuration.SERIAL_CONFIG.ports.length; portIndex++) {
var oldPort = configuration.SERIAL_CONFIG.ports[portIndex];
var newPort = {
identifier: oldPort.identifier,
functionMask: 0,
msp_baudrate: configuration.SERIAL_CONFIG.mspBaudRate,
gps_baudrate: configuration.SERIAL_CONFIG.gpsBaudRate,
telemetry_baudrate: 0, // auto
blackbox_baudrate: 5, // 115200
};
switch(oldPort.scenario) {
case 1: // MSP, CLI, TELEMETRY, SMARTPORT TELEMETRY, GPS-PASSTHROUGH
case 5: // MSP, CLI, GPS-PASSTHROUGH
case 8: // MSP ONLY
newPort.functionMask = 1; // FUCNTION_MSP
break;
case 2: // GPS
newPort.functionMask = 2; // FUNCTION_GPS
break;
case 3: // RX_SERIAL
newPort.functionMask = 64; // FUNCTION_RX_SERIAL
break;
case 10: // BLACKBOX ONLY
newPort.functionMask = 128; // FUNCTION_BLACKBOX
break;
case 11: // MSP, CLI, BLACKBOX, GPS-PASSTHROUGH
newPort.functionMask = 1 + 128; // FUNCTION_BLACKBOX
break;
}
ports.push(newPort);
}
configuration.SERIAL_CONFIG = {
ports: ports
};
for (var profileIndex = 0; profileIndex < 3; profileIndex++) {
var RC = configuration.profiles[profileIndex].RC;
// TPA breakpoint was added
if (!RC.dynamic_THR_breakpoint) {
RC.dynamic_THR_breakpoint = 1500; // firmware default
}
// Roll and pitch rates were split
RC.roll_rate = RC.roll_pitch_rate;
RC.pitch_rate = RC.roll_pitch_rate;
}
migratedVersion = '0.63.0';
GUI.log(chrome.i18n.getMessage('configMigratedTo', [migratedVersion]));
appliedMigrationsCount++;
}
GUI.log(chrome.i18n.getMessage('configMigrationSuccessful', [appliedMigrationsCount]));
return true;
}

View File

@ -3,9 +3,9 @@
var CONFIGURATOR = {
'releaseDate': 1424462791805, // new Date().getTime() - 2015.02.20
'apiVersionAccepted': 1.2,
'backupRestoreMinApiVersionAccepted': 1.6,
'backupRestoreMinApiVersionAccepted': 1.5,
'pidControllerChangeMinApiVersion': 1.5,
'backupFileMinVersionAccepted': '0.63', // chrome.runtime.getManifest().version is stored as string, so does this one
'backupFileMinVersionAccepted': '0.55', // chrome.runtime.getManifest().version is stored as string, so does this one
'connectionValid': false,
'connectionValidCliOnly': false,
'cliActive': false,
@ -65,11 +65,14 @@ var RC = {
var RC_tuning = {
RC_RATE: 0,
RC_EXPO: 0,
roll_pitch_rate: 0,
roll_pitch_rate: 0, // pre 1.7 api only
roll_rate: 0,
pitch_rate: 0,
yaw_rate: 0,
dynamic_THR_PID: 0,
throttle_MID: 0,
throttle_EXPO: 0
throttle_EXPO: 0,
dynamic_THR_breakpoint: 0
};
var AUX_CONFIG = [];
@ -86,6 +89,8 @@ var SERVO_CONFIG = [];
var SERIAL_CONFIG = {
ports: [],
// pre 1.6 settings
mspBaudRate: 0,
gpsBaudRate: 0,
gpsPassthroughBaudRate: 0,

View File

@ -207,11 +207,20 @@ GUI_control.prototype.timeout_kill_all = function () {
GUI_control.prototype.log = function (message) {
var command_log = $('div#log');
var d = new Date();
var year = d.getFullYear();
var month = ((d.getMonth() < 9) ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1));
var date = ((d.getDate() < 10) ? '0' + d.getDate() : d.getDate());
var time = ((d.getHours() < 10) ? '0' + d.getHours(): d.getHours())
+ ':' + ((d.getMinutes() < 10) ? '0' + d.getMinutes(): d.getMinutes())
+ ':' + ((d.getSeconds() < 10) ? '0' + d.getSeconds(): d.getSeconds());
+ ':' + ((d.getMinutes() < 10) ? '0' + d.getMinutes(): d.getMinutes())
+ ':' + ((d.getSeconds() < 10) ? '0' + d.getSeconds(): d.getSeconds());
$('div.wrapper', command_log).append('<p>' + time + ' -- ' + message + '</p>');
var formattedDate = "{0}-{1}-{2} {3}".format(
year,
month,
date,
' @ ' + time
);
$('div.wrapper', command_log).append('<p>' + formattedDate + ' -- ' + message + '</p>');
command_log.scrollTop($('div.wrapper', command_log).height());
};
@ -230,4 +239,4 @@ GUI_control.prototype.tab_switch_cleanup = function (callback) {
};
// initialize object into GUI variable
var GUI = new GUI_control();
var GUI = new GUI_control();

File diff suppressed because one or more lines are too long

View File

@ -65,6 +65,7 @@
// Private methods
function _setRoll(roll){
roll *= -1;
placeholder.each(function(){
$(this).find('div.instrument.attitude div.roll').css('transform', 'rotate('+roll+'deg)');
});
@ -75,7 +76,7 @@
if(pitch>constants.pitch_bound){pitch = constants.pitch_bound;}
else if(pitch<-constants.pitch_bound){pitch = -constants.pitch_bound;}
placeholder.each(function(){
$(this).find('div.instrument.attitude div.roll div.pitch').css('top', pitch*0.7 + '%');
$(this).find('div.instrument.attitude div.roll div.pitch').css('top', -pitch*0.7 + '%');
});
}

View File

@ -290,13 +290,22 @@ var MSP = {
ANALOG.amperage = data.getInt16(5, 1) / 100; // A
break;
case MSP_codes.MSP_RC_TUNING:
RC_tuning.RC_RATE = parseFloat((data.getUint8(0) / 100).toFixed(2));
RC_tuning.RC_EXPO = parseFloat((data.getUint8(1) / 100).toFixed(2));
RC_tuning.roll_pitch_rate = parseFloat((data.getUint8(2) / 100).toFixed(2));
RC_tuning.yaw_rate = parseFloat((data.getUint8(3) / 100).toFixed(2));
RC_tuning.dynamic_THR_PID = parseFloat((data.getUint8(4) / 100).toFixed(2));
RC_tuning.throttle_MID = parseFloat((data.getUint8(5) / 100).toFixed(2));
RC_tuning.throttle_EXPO = parseFloat((data.getUint8(6) / 100).toFixed(2));
var offset = 0;
RC_tuning.RC_RATE = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
RC_tuning.RC_EXPO = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
if (CONFIG.apiVersion < 1.7) {
RC_tuning.roll_pitch_rate = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
} else {
RC_tuning.roll_rate = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
RC_tuning.pitch_rate = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
}
RC_tuning.yaw_rate = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
RC_tuning.dynamic_THR_PID = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
RC_tuning.throttle_MID = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
RC_tuning.throttle_EXPO = parseFloat((data.getUint8(offset++) / 100).toFixed(2));
if (CONFIG.apiVersion >= 1.7) {
RC_tuning.dynamic_THR_breakpoint = data.getUint16(offset++, 1);
}
break;
case MSP_codes.MSP_PID:
// PID data arrived, we need to scale it and save to appropriate bank / array
@ -914,11 +923,20 @@ MSP.crunch = function (code) {
case MSP_codes.MSP_SET_RC_TUNING:
buffer.push(parseInt(RC_tuning.RC_RATE * 100));
buffer.push(parseInt(RC_tuning.RC_EXPO * 100));
buffer.push(parseInt(RC_tuning.roll_pitch_rate * 100));
if (CONFIG.apiVersion < 1.7) {
buffer.push(parseInt(RC_tuning.roll_pitch_rate * 100));
} else {
buffer.push(parseInt(RC_tuning.roll_rate * 100));
buffer.push(parseInt(RC_tuning.pitch_rate * 100));
}
buffer.push(parseInt(RC_tuning.yaw_rate * 100));
buffer.push(parseInt(RC_tuning.dynamic_THR_PID * 100));
buffer.push(parseInt(RC_tuning.throttle_MID * 100));
buffer.push(parseInt(RC_tuning.throttle_EXPO * 100));
if (CONFIG.apiVersion >= 1.7) {
buffer.push(lowByte(RC_tuning.dynamic_THR_breakpoint));
buffer.push(highByte(RC_tuning.dynamic_THR_breakpoint));
}
break;
// Disabled, cleanflight does not use MSP_SET_BOX.
/*

View File

@ -62,6 +62,6 @@
<a href="#" class="save-flash" i18n="dataflashButtonSaveFile"></a>
</div>
</div>
<div class="note require-no-dataflash" i18n="dataflashNotSupportedNote">
<div class="note require-no-dataflash">
</div>
</div>

View File

@ -1,6 +1,8 @@
'use strict';
TABS.dataflash = {};
TABS.dataflash = {
available: false
};
TABS.dataflash.initialize = function (callback) {
var
self = this,
@ -18,10 +20,19 @@ TABS.dataflash.initialize = function (callback) {
log_buffer = [];
if (CONFIGURATOR.connectionValid) {
MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false, function() {
$('#content').load("./tabs/dataflash.html", function() {
create_html();
});
TABS.dataflash.available = (CONFIG.apiVersion >= 1.6)
if (!TABS.dataflash.available) {
load_html();
return;
}
MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/dataflash.html", function() {
create_html();
});
}
@ -71,27 +82,35 @@ TABS.dataflash.initialize = function (callback) {
}
function create_html() {
var
supportsDataflash = DATAFLASH.totalSize > 0;
// translate to user-selected language
localize();
if (TABS.dataflash.available) {
var supportsDataflash = DATAFLASH.totalSize > 0;
$(".tab-dataflash").toggleClass("supported", supportsDataflash);
$(".tab-dataflash").toggleClass("supported", supportsDataflash);
if (supportsDataflash) {
// UI hooks
$('.tab-dataflash a.erase-flash').click(ask_to_erase_flash);
$('.tab-dataflash a.erase-flash-confirm').click(flash_erase);
$('.tab-dataflash a.erase-flash-cancel').click(flash_erase_cancel);
if (supportsDataflash) {
// UI hooks
$('.tab-dataflash a.erase-flash').click(ask_to_erase_flash);
$('.tab-dataflash a.erase-flash-confirm').click(flash_erase);
$('.tab-dataflash a.erase-flash-cancel').click(flash_erase_cancel);
$('.tab-dataflash a.save-flash').click(flash_save_begin);
$('.tab-dataflash a.save-flash-cancel').click(flash_save_cancel);
$('.tab-dataflash a.save-flash-dismiss').click(dismiss_saving_dialog);
update_html();
$('.tab-dataflash a.save-flash').click(flash_save_begin);
$('.tab-dataflash a.save-flash-cancel').click(flash_save_cancel);
$('.tab-dataflash a.save-flash-dismiss').click(dismiss_saving_dialog);
update_html();
} else {
$(".tab-dataflash .note").html(chrome.i18n.getMessage('dataflashNotSupportedNote'));
}
} else {
$(".tab-dataflash").removeClass("supported");
$(".tab-dataflash .note").html(chrome.i18n.getMessage('dataflashFirmwareUpgradeRequired'));
}
if (callback) callback();
}

View File

@ -90,6 +90,11 @@
float: right;
width: calc(40% - 10px); /* - ( "virtual" margin) */
}
.tab-pid_tuning .rate-tpa .tpa{
float: right;
border: 1px solid #ADDFAC; /*THEME CHANGE HERE*/
width: calc(100% - 10px); /* - ( "virtual" margin) */
}
.tab-pid_tuning .buttons {
width: calc(100% - 20px);
@ -118,4 +123,4 @@
.tab-pid_tuning .update:hover,
.tab-pid_tuning .refresh:hover {
background-color: #dedcdc;
}
}

169
tabs/pid_tuning.html Normal file → Executable file
View File

@ -12,84 +12,95 @@
</select>
</div>
<div class="clear-both"></div>
<table class="pid_tuning">
<tr>
<th class="name" i18n="pidTuningName"></th>
<th class="proportional" i18n="pidTuningProportional"></th>
<th class="integral" i18n="pidTuningIntegral"></th>
<th class="derivative" i18n="pidTuningDerivative"></th>
</tr>
<tr class="ROLL"><!-- 0 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
</tr>
<tr class="PITCH"><!-- 1 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
</tr>
<tr class="YAW"><!-- 2 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
</tr>
<tr class="ALT"><!-- 3 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
</tr>
<tr class="Vario"><!-- 9 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
</tr>
<tr class="Pos"><!-- 4 -->
<td></td>
<td><input type="number" name="p" step="0.01" min="0" max="2.55" /></td>
<td><input type="number" name="i" step="0.01" min="0" max="2.55" /></td>
</tr>
<tr class="PosR"><!-- 5 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.01" min="0" max="2.55" /></td>
<td><input type="number" name="d" step="0.001" min="0" max="0.255" /></td>
</tr>
<tr class="NavR"><!-- 6 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.01" min="0" max="2.55" /></td>
<td><input type="number" name="d" step="0.001" min="0" max="0.255" /></td>
</tr>
<tr class="LEVEL"><!-- 7 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
</tr>
<tr class="MAG"><!-- 8 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
</tr>
</table>
<table class="rate-tpa">
<tr>
<th i18n="pidTuningRollPitchRate"></th>
<th i18n="pidTuningYawRate"></th>
<th i18n="pidTuningTPA"></th>
</tr>
<tr>
<td><input type="number" name="roll-pitch" step="0.01" min="0" max="2.55" /></td>
<td><input type="number" name="yaw" step="0.01" min="0" max="2.55" /></td>
<td><input type="number" name="tpa" step="0.01" min="0" max="2.55" /></td>
</tr>
</table>
<form name="pid-tuning" id="pid-tuning">
<table class="pid_tuning">
<tr>
<th class="name" i18n="pidTuningName"></th>
<th class="proportional" i18n="pidTuningProportional"></th>
<th class="integral" i18n="pidTuningIntegral"></th>
<th class="derivative" i18n="pidTuningDerivative"></th>
</tr>
<tr class="ROLL"><!-- 0 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
</tr>
<tr class="PITCH"><!-- 1 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
</tr>
<tr class="YAW"><!-- 2 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
</tr>
<tr class="ALT"><!-- 3 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
</tr>
<tr class="Vario"><!-- 9 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
</tr>
<tr class="Pos"><!-- 4 -->
<td></td>
<td><input type="number" name="p" step="0.01" min="0" max="2.55"/></td>
<td><input type="number" name="i" step="0.01" min="0" max="2.55"/></td>
</tr>
<tr class="PosR"><!-- 5 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.01" min="0" max="2.55"/></td>
<td><input type="number" name="d" step="0.001" min="0" max="0.255"/></td>
</tr>
<tr class="NavR"><!-- 6 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.01" min="0" max="2.55"/></td>
<td><input type="number" name="d" step="0.001" min="0" max="0.255"/></td>
</tr>
<tr class="LEVEL"><!-- 7 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
</tr>
<tr class="MAG"><!-- 8 -->
<td></td>
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
</tr>
</table>
<table class="rate-tpa">
<thead>
<tr>
<th class="roll-pitch" i18n="pidTuningRollPitchRate"></th>
<th class="roll" i18n="pidTuningRollRate"></th>
<th class="pitch" i18n="pidTuningPitchRate"></th>
<th i18n="pidTuningYawRate"></th>
<th i18n="pidTuningTPA"></th>
<th class="tpa-breakpoint" i18n="pidTuningTPABreakPoint"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="roll-pitch" ><input type="number" name="roll-pitch" step="0.01" min="0" max="2.55"/></td>
<td class="roll" ><input type="number" name="roll" step="0.01" min="0" max="2.55"/></td>
<td class="pitch" ><input type="number" name="pitch" step="0.01" min="0" max="2.55"/></td>
<td><input type="number" name="yaw" step="0.01" min="0" max="2.55"/></td>
<td><input type="number" name="tpa" step="0.01" min="0" max="2.55"/></td>
<td class="tpa-breakpoint"><input type="number" name="tpa-breakpoint" step="10" min="1000" max="2000" /></td>
</tr>
</tbody>
</table>
</form>
<div class="clear-both"></div>
<div class="profile">
<span class="head" i18n="pidTuningProfileHead"></span>
@ -103,4 +114,4 @@
<a class="update" href="#" i18n="pidTuningButtonSave"></a>
<a class="refresh" href="#" i18n="pidTuningButtonRefresh"></a>
</div>
</div>
</div>

239
tabs/pid_tuning.js Normal file → Executable file
View File

@ -1,9 +1,12 @@
'use strict';
TABS.pid_tuning = {};
TABS.pid_tuning = {
controllerChanged: true
};
TABS.pid_tuning.initialize = function (callback) {
var self = this;
if (GUI.active_tab != 'pid_tuning') {
GUI.active_tab = 'pid_tuning';
googleAnalytics.sendAppView('PID Tuning');
@ -36,23 +39,7 @@ TABS.pid_tuning.initialize = function (callback) {
// requesting MSP_STATUS manually because it contains CONFIG.profile
MSP.send_message(MSP_codes.MSP_STATUS, false, false, get_pid_controller);
function process_html() {
// translate to user-selected language
localize();
// Fill in the names from PID_names array
// this needs to be reworked, but will do for now
$('.pid_tuning tr:eq(1) td:first').text(PID_names[0]);
$('.pid_tuning tr:eq(2) td:first').text(PID_names[1]);
$('.pid_tuning tr:eq(3) td:first').text(PID_names[2]);
$('.pid_tuning tr:eq(4) td:first').text(PID_names[3]);
$('.pid_tuning tr:eq(5) td:first').text(PID_names[9]);
$('.pid_tuning tr:eq(6) td:first').text(PID_names[4]);
$('.pid_tuning tr:eq(7) td:first').text(PID_names[5]);
$('.pid_tuning tr:eq(8) td:first').text(PID_names[6]);
$('.pid_tuning tr:eq(9) td:first').text(PID_names[7]);
$('.pid_tuning tr:eq(10) td:first').text(PID_names[8]);
function pid_and_rc_to_form() {
// Fill in the data from PIDs array
var i = 0;
$('.pid_tuning .ROLL input').each(function () {
@ -186,28 +173,122 @@ TABS.pid_tuning.initialize = function (callback) {
// Fill in data from RC_tuning object
$('.rate-tpa input[name="roll-pitch"]').val(RC_tuning.roll_pitch_rate.toFixed(2));
$('.rate-tpa input[name="roll"]').val(RC_tuning.roll_rate.toFixed(2));
$('.rate-tpa input[name="pitch"]').val(RC_tuning.pitch_rate.toFixed(2));
$('.rate-tpa input[name="yaw"]').val(RC_tuning.yaw_rate.toFixed(2));
$('.rate-tpa input[name="tpa"]').val(RC_tuning.dynamic_THR_PID.toFixed(2));
$('.rate-tpa input[name="tpa-breakpoint"]').val(RC_tuning.dynamic_THR_breakpoint);
}
function form_to_pid_and_rc() {
// Catch all the changes and stuff the inside PIDs array
var i = 0;
$('table.pid_tuning tr.ROLL input').each(function () {
PIDs[0][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.PITCH input').each(function () {
PIDs[1][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.YAW input').each(function () {
PIDs[2][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.ALT input').each(function () {
PIDs[3][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.Vario input').each(function () {
PIDs[9][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.Pos input').each(function () {
PIDs[4][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.PosR input').each(function () {
PIDs[5][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.NavR input').each(function () {
PIDs[6][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.LEVEL input').each(function () {
PIDs[7][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.MAG input').each(function () {
PIDs[8][i++] = parseFloat($(this).val());
});
// catch RC_tuning changes
RC_tuning.roll_pitch_rate = parseFloat($('.rate-tpa input[name="roll-pitch"]').val());
RC_tuning.roll_rate = parseFloat($('.rate-tpa input[name="roll"]').val());
RC_tuning.pitch_rate = parseFloat($('.rate-tpa input[name="pitch"]').val());
RC_tuning.yaw_rate = parseFloat($('.rate-tpa input[name="yaw"]').val());
RC_tuning.dynamic_THR_PID = parseFloat($('.rate-tpa input[name="tpa"]').val());
RC_tuning.dynamic_THR_breakpoint = parseInt($('.rate-tpa input[name="tpa-breakpoint"]').val());
}
function process_html() {
// translate to user-selected language
localize();
// Fill in the names from PID_names array
// this needs to be reworked, but will do for now
$('.pid_tuning tr:eq(1) td:first').text(PID_names[0]);
$('.pid_tuning tr:eq(2) td:first').text(PID_names[1]);
$('.pid_tuning tr:eq(3) td:first').text(PID_names[2]);
$('.pid_tuning tr:eq(4) td:first').text(PID_names[3]);
$('.pid_tuning tr:eq(5) td:first').text(PID_names[9]);
$('.pid_tuning tr:eq(6) td:first').text(PID_names[4]);
$('.pid_tuning tr:eq(7) td:first').text(PID_names[5]);
$('.pid_tuning tr:eq(8) td:first').text(PID_names[6]);
$('.pid_tuning tr:eq(9) td:first').text(PID_names[7]);
$('.pid_tuning tr:eq(10) td:first').text(PID_names[8]);
pid_and_rc_to_form();
var pidController_e = $('select[name="controller"]');
var profile_e = $('select[name="profile"]');
var form_e = $('#pid-tuning');
if (GUI.canChangePidController) {
pidController_e.val(PID.controller);
} else {
GUI.log(chrome.i18n.getMessage('pidTuningUpgradeFirmwareToChangePidController', [CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion]));
pidController_e.empty();
pidController_e.append('<option value="">Unknown</option>');
pidController_e.prop('disabled', true);
}
if (CONFIG.apiVersion < 1.7) {
$('.rate-tpa .tpa-breakpoint').hide();
$('.rate-tpa .roll').hide();
$('.rate-tpa .pitch').hide();
} else {
$('.rate-tpa .roll-pitch').hide();
}
// Fill in currently selected profile
$('select[name="profile"]').val(CONFIG.profile);
profile_e.val(CONFIG.profile);
// UI Hooks
$('select[name="profile"]').change(function () {
profile_e.change(function () {
var profile = parseInt($(this).val());
MSP.send_message(MSP_codes.MSP_SELECT_SETTING, [profile], false, function () {
GUI.log(chrome.i18n.getMessage('pidTuningLoadedProfile', [profile + 1]));
@ -221,74 +302,37 @@ TABS.pid_tuning.initialize = function (callback) {
$('a.refresh').click(function () {
GUI.tab_switch_cleanup(function () {
GUI.log(chrome.i18n.getMessage('pidTuningDataRefreshed'));
TABS.pid_tuning.initialize();
});
});
$('a.update').click(function () {
// Catch all the changes and stuff the inside PIDs array
var i = 0;
$('table.pid_tuning tr.ROLL input').each(function () {
PIDs[0][i++] = parseFloat($(this).val());
});
form_e.find('input').each(function (k, item) {
$(item).change(function () {
pidController_e.prop("disabled", true);
TABS.pid_tuning.controllerChanged = false;
})
});
i = 0;
$('table.pid_tuning tr.PITCH input').each(function () {
PIDs[1][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.YAW input').each(function () {
PIDs[2][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.ALT input').each(function () {
PIDs[3][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.Vario input').each(function () {
PIDs[9][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.Pos input').each(function () {
PIDs[4][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.PosR input').each(function () {
PIDs[5][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.NavR input').each(function () {
PIDs[6][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.LEVEL input').each(function () {
PIDs[7][i++] = parseFloat($(this).val());
});
i = 0;
$('table.pid_tuning tr.MAG input').each(function () {
PIDs[8][i++] = parseFloat($(this).val());
});
// catch RC_tuning changes
RC_tuning.roll_pitch_rate = parseFloat($('.rate-tpa input[name="roll-pitch"]').val());
RC_tuning.yaw_rate = parseFloat($('.rate-tpa input[name="yaw"]').val());
RC_tuning.dynamic_THR_PID = parseFloat($('.rate-tpa input[name="tpa"]').val());
var pidController_e = $('select[name="controller"]');
function send_pids() {
MSP.send_message(MSP_codes.MSP_SET_PID, MSP.crunch(MSP_codes.MSP_SET_PID), false, send_rc_tuning_changes);
pidController_e.change(function () {
if (PID.controller != pidController_e.val()) {
form_e.find('input').each(function (k, item) {
$(item).prop('disabled', true);
TABS.pid_tuning.controllerChanged = true;
});
}
});
// update == save.
$('a.update').click(function () {
form_to_pid_and_rc();
function send_pids() {
if (!TABS.pid_tuning.controllerChanged) {
MSP.send_message(MSP_codes.MSP_SET_PID, MSP.crunch(MSP_codes.MSP_SET_PID), false, send_rc_tuning_changes);
}
}
function send_rc_tuning_changes() {
MSP.send_message(MSP_codes.MSP_SET_RC_TUNING, MSP.crunch(MSP_codes.MSP_SET_RC_TUNING), false, save_to_eeprom);
}
@ -299,9 +343,14 @@ TABS.pid_tuning.initialize = function (callback) {
});
}
if (GUI.canChangePidController) {
PID.controller = pidController_e.val();
MSP.send_message(MSP_codes.MSP_SET_PID_CONTROLLER, MSP.crunch(MSP_codes.MSP_SET_PID_CONTROLLER), false, send_pids);
if (GUI.canChangePidController && TABS.pid_tuning.controllerChanged) {
PID.controller = pidController_e.val();
MSP.send_message(MSP_codes.MSP_SET_PID_CONTROLLER, MSP.crunch(MSP_codes.MSP_SET_PID_CONTROLLER), false, function () {
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(chrome.i18n.getMessage('pidTuningEepromSaved'));
});
TABS.pid_tuning.initialize();
});
} else {
send_pids();
}
@ -312,10 +361,14 @@ TABS.pid_tuning.initialize = function (callback) {
MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true);
if (callback) callback();
if (callback) {
callback();
}
}
};
TABS.pid_tuning.cleanup = function (callback) {
if (callback) callback();
}
if (callback) {
callback();
}
};

View File

@ -64,4 +64,22 @@
}
.tab-ports .save:hover {
background-color: #dedcdc;
}
}
.tab-ports .note {
padding: 5px;
border: 1px dashed silver;
margin-bottom: 8px;
}
.require-support {
display:none;
}
.tab-ports.supported .require-support {
display:block;
}
.require-upgrade {
display:block;
}
.tab-ports.supported .require-upgrade {
display:none;
}

View File

@ -1,25 +1,29 @@
<div id="content-watermark"></div>
<div class="tab-ports">
<div class="help">
<p i18n="portsHelp"></p>
<div class="require-support">
<div class="help">
<p i18n="portsHelp"></p>
</div>
<table class="ports">
<thead>
<tr>
<td>Identifier</td>
<td>Data</td>
<td>Logging</td>
<td>Telemetry</td>
<td>RX</td>
<td>GPS</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="clear-both"></div>
<div class="buttons">
<a class="save" href="#" i18n="portsButtonSave"></a>
</div>
</div>
<table class="ports">
<thead>
<tr>
<td>Identifier</td>
<td>Data</td>
<td>Logging</td>
<td>Telemetry</td>
<td>RX</td>
<td>GPS</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="clear-both"></div>
<div class="buttons">
<a class="save" href="#" i18n="portsButtonSave"></a>
<div class="note require-upgrade" i18n="portsFirmwareUpgradeRequired">
</div>
</div>

View File

@ -80,6 +80,13 @@ TABS.ports.initialize = function (callback, scrollPosition) {
function update_ui() {
if (CONFIG.apiVersion < 1.6) {
$(".tab-ports").removeClass("supported");
return;
}
$(".tab-ports").addClass("supported");
var portIdentifierToNameMapping = {
0: 'UART1',
@ -172,7 +179,8 @@ TABS.ports.initialize = function (callback, scrollPosition) {
if (select_e.size() == 0) {
functions_e.prepend('<span class="function"><select name="' + selectElementName + '" /></span>');
select_e = functions_e.find(selectElementSelector);
select_e.append('<option value="">-- Select --</option>');
var disabledText = chrome.i18n.getMessage('portsTelemetryDisabled');
select_e.append('<option value="">' + disabledText + '</option>');
}
select_e.append('<option value="' + functionName + '">' + functionRule.displayName + '</option>');
@ -268,4 +276,4 @@ TABS.ports.initialize = function (callback, scrollPosition) {
TABS.ports.cleanup = function (callback) {
if (callback) callback();
};
};