mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
first CAP_BASEFLIGHT_CONFIG implementation (unfinished) for initial tab, including temporary backwards compatibility support
This commit is contained in:
parent
df738f9daf
commit
875f3bfa15
3 changed files with 484 additions and 211 deletions
|
@ -1,3 +1,14 @@
|
|||
/* temporary styles that are used during compatibility period */
|
||||
.tab-initial_setup .CAP_BASEFLIGHT_CONFIG,
|
||||
.tab-initial_setup .COMPATIBILITY {
|
||||
display: none;
|
||||
height: calc(100% - 142px);
|
||||
}
|
||||
.tab-initial_setup .CAP_BASEFLIGHT_CONFIG #interactive_block {
|
||||
width: calc(100% - 411px);
|
||||
}
|
||||
/* temporary styles end*/
|
||||
|
||||
.tab-initial_setup {
|
||||
height: 100%;
|
||||
}
|
||||
|
@ -48,7 +59,7 @@
|
|||
float: left;
|
||||
position: relative;
|
||||
|
||||
height: calc(100% - 142px);
|
||||
height: 100%;
|
||||
width: calc(100% - 522px);
|
||||
|
||||
border: 1px solid silver;
|
||||
|
@ -119,6 +130,55 @@
|
|||
.tab-initial_setup .block_wrapper {
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.tab-initial_setup .block {
|
||||
float: left;
|
||||
display: block;
|
||||
|
||||
margin-left: 10px;
|
||||
|
||||
border: 1px solid silver;
|
||||
}
|
||||
.tab-initial_setup .block .head {
|
||||
display: block;
|
||||
|
||||
text-align: center;
|
||||
line-height: 20px;
|
||||
font-weight: bold;
|
||||
|
||||
border-bottom: 1px solid silver;
|
||||
background-color: #ececec;
|
||||
}
|
||||
.tab-initial_setup .mixer {
|
||||
width: 200px;
|
||||
}
|
||||
.tab-initial_setup .mixer .preview {
|
||||
display: block;
|
||||
|
||||
width: 200px;
|
||||
height: 140px;
|
||||
|
||||
margin: 5px 0 5px 0;
|
||||
}
|
||||
.tab-initial_setup .mixer select {
|
||||
display: block;
|
||||
|
||||
padding-left: 5px;
|
||||
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
border-top: 1px solid silver;
|
||||
}
|
||||
.tab-initial_setup .block .info {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.tab-initial_setup .battery,
|
||||
.tab-initial_setup .throttle,
|
||||
.tab-initial_setup .acc-trim,
|
||||
|
|
|
@ -20,6 +20,56 @@
|
|||
<p i18n="initialSetupBackupRestoreText">
|
||||
</p>
|
||||
</div>
|
||||
<div class="CAP_BASEFLIGHT_CONFIG">
|
||||
<div id="interactive_block">
|
||||
<div id="canvas_wrapper">
|
||||
<canvas id="canvas"></canvas>
|
||||
</div>
|
||||
<span class="model"></span>
|
||||
<span class="heading"></span>
|
||||
<a class="reset" href="#" i18n="initialSetupButtonResetZaxis"></a>
|
||||
</div>
|
||||
<div class="block mixer">
|
||||
<span class="head" i18n="initialSetupMixerHead"></span>
|
||||
<img class="preview" src="" />
|
||||
<select name="mixer">
|
||||
<option value="1">TRI</option>
|
||||
<option value="2">Quad +</option>
|
||||
<option value="3">Quad X</option>
|
||||
<option value="4">BI</option>
|
||||
<option value="5">Gimbal</option>
|
||||
<option value="6">Y 6</option>
|
||||
<option value="7">HEX 6</option>
|
||||
<option value="8">Flying Wing</option>
|
||||
<option value="9">Y 4</option>
|
||||
<option value="10">HEX 6 X</option>
|
||||
<option value="11">OCTO X8</option>
|
||||
<option value="12">OCTO X8 - TODO</option>
|
||||
<option value="13">OCTO X8 - TODO</option>
|
||||
<option value="14">Airplane</option>
|
||||
<option value="15">Heli 120</option>
|
||||
<option value="16">Heli 90</option>
|
||||
<option value="17">Vtail</option>
|
||||
<option value="18">Hex 6 H</option>
|
||||
<option value="19">PPM to SERVO</option>
|
||||
<option value="20">Dualcopter</option>
|
||||
<option value="21">Singlecopter</option>
|
||||
<option value="22">Custom</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="block info">
|
||||
<span class="head" i18n="initialSetupInfoHead"></span>
|
||||
<div class="fields">
|
||||
<dl>
|
||||
<dt i18n="initialSetupBattery"></dt><dd class="bat-voltage">0 V</dd>
|
||||
<dt i18n="initialSetupDrawn"></dt><dd class="bat-mah-drawn">0 mAh</dd>
|
||||
<dt i18n="initialSetupDrawing"></dt><dd class="bat-mah-drawing">0 A</dd>
|
||||
<dt i18n="initialSetupRSSI"></dt><dd class="rssi">0 %</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="COMPATIBILITY">
|
||||
<div id="interactive_block">
|
||||
<div id="canvas_wrapper">
|
||||
<canvas id="canvas"></canvas>
|
||||
|
@ -80,6 +130,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<a class="update" href="#" i18n="initialSetupButtonSave"></a>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,15 @@ TABS.initial_setup.initialize = function (callback) {
|
|||
googleAnalytics.sendAppView('Initial Setup');
|
||||
|
||||
function load_ident() {
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, load_misc_data);
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, load_config);
|
||||
}
|
||||
|
||||
function load_config() {
|
||||
if (bit_check(CONFIG.capability, 30)) {
|
||||
MSP.send_message(MSP_codes.MSP_CONFIG, false, false, load_misc_data);
|
||||
} else {
|
||||
load_misc_data();
|
||||
}
|
||||
}
|
||||
|
||||
function load_misc_data() {
|
||||
|
@ -28,8 +36,156 @@ TABS.initial_setup.initialize = function (callback) {
|
|||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
// if CAP_BASEFLIGHT_CONFIG (30)
|
||||
if (bit_check(CONFIG.capability, 30)) {
|
||||
// current stuff, this will become default when the compatibility period ends
|
||||
$('.CAP_BASEFLIGHT_CONFIG').show();
|
||||
|
||||
// initialize 3D
|
||||
self.initialize3D();
|
||||
self.initialize3D(false);
|
||||
|
||||
// Display multiType and motor diagram (if such exist)
|
||||
var str;
|
||||
switch (CONFIG.multiType) {
|
||||
case 1: // TRI
|
||||
str = 'TRI';
|
||||
break;
|
||||
case 2: // QUAD +
|
||||
str = 'Quad +';
|
||||
break;
|
||||
case 3: // QUAD X
|
||||
str = 'Quad X';
|
||||
break;
|
||||
case 4: // BI
|
||||
str = 'BI';
|
||||
break;
|
||||
case 5: // GIMBAL
|
||||
str = 'Gimbal';
|
||||
break;
|
||||
case 6: // Y6
|
||||
str = 'Y6';
|
||||
break;
|
||||
case 7: // HEX 6
|
||||
str = 'HEX 6';
|
||||
break;
|
||||
case 8: // FLYING_WING
|
||||
str = 'Flying Wing';
|
||||
break;
|
||||
case 9: // Y4
|
||||
str = 'Y4';
|
||||
break;
|
||||
case 10: // HEX6 X
|
||||
str = 'HEX6 X';
|
||||
break;
|
||||
case 11: // OCTO X8
|
||||
case 12:
|
||||
case 13:
|
||||
str = 'OCTO X8';
|
||||
break;
|
||||
case 14: // AIRPLANE
|
||||
str = 'Airplane';
|
||||
break;
|
||||
case 15: // Heli 120
|
||||
str = 'Heli 120';
|
||||
break;
|
||||
case 16: // Heli 90
|
||||
str = 'Heli 90';
|
||||
break;
|
||||
case 17: // Vtail
|
||||
str = 'Vtail';
|
||||
break;
|
||||
case 18: // HEX6 H
|
||||
str = 'HEX6 H';
|
||||
break;
|
||||
case 19: // PPM to SERVO
|
||||
str = 'PPM to SERVO';
|
||||
break;
|
||||
case 20: // Dualcopter
|
||||
str = 'Dualcopter';
|
||||
break;
|
||||
case 21: // Singlecopter
|
||||
str = 'Singlecopter';
|
||||
break;
|
||||
case 22: // Custom
|
||||
str = 'Custom';
|
||||
break;
|
||||
}
|
||||
|
||||
// set model name in interactive block
|
||||
$('span.model').text(chrome.i18n.getMessage('initialSetupModel', [str]));
|
||||
|
||||
// set heading in interactive block
|
||||
$('span.heading').text(chrome.i18n.getMessage('initialSetupheading', [0]));
|
||||
|
||||
// UI hook handling mixer type change that swaps the image representation
|
||||
$('.mixer select').change(function () {
|
||||
var val = $(this).val();
|
||||
|
||||
var imageArray = [
|
||||
'custom', // there is no type 0, we will use custom image as spacer
|
||||
'tri',
|
||||
'quadp',
|
||||
'quadx',
|
||||
'custom', // bi
|
||||
'custom', // gimbal
|
||||
'y6',
|
||||
'hex6p',
|
||||
'custom', // flying wing
|
||||
'y4',
|
||||
'hex6x',
|
||||
'octox',
|
||||
'octox',
|
||||
'octox',
|
||||
'airplane',
|
||||
'custom',
|
||||
'custom',
|
||||
'vtail',
|
||||
'custom',
|
||||
'custom',
|
||||
'custom',
|
||||
'custom',
|
||||
'custom',
|
||||
];
|
||||
|
||||
$('.mixer .preview').attr('src', './images/motor_order/' + imageArray[val] + '.svg');
|
||||
});
|
||||
|
||||
// update mixer type with current value
|
||||
$('.mixer select').val(BF_CONFIG.mixerConfiguration).change();
|
||||
|
||||
// save
|
||||
$('a.update').click(function () {
|
||||
// update object
|
||||
BF_CONFIG.mixerConfiguration = parseInt($('.mixer select').val());
|
||||
|
||||
function save_to_eeprom() {
|
||||
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, reboot);
|
||||
}
|
||||
|
||||
function reboot() {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupEepromSaved'));
|
||||
GUI.tab_switch_cleanup();
|
||||
|
||||
MSP.send_message(MSP_codes.MSP_SET_REBOOT, false, false, reinitialize);
|
||||
}
|
||||
|
||||
function reinitialize() {
|
||||
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('deviceReady'));
|
||||
TABS.initial_setup.initialize();
|
||||
});
|
||||
}
|
||||
|
||||
MSP.send_message(MSP_codes.MSP_SET_CONFIG, MSP.crunch('BF_CONFIG'), false, save_to_eeprom); // TODO reply byte is missing on the firmware side so this is where it fails
|
||||
});
|
||||
} else {
|
||||
// old stuff
|
||||
$('.COMPATIBILITY').show();
|
||||
|
||||
// initialize 3D
|
||||
self.initialize3D(true);
|
||||
|
||||
// Fill in misc stuff
|
||||
$('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage);
|
||||
|
@ -48,7 +204,7 @@ TABS.initial_setup.initialize = function (callback) {
|
|||
$('input[name="roll"]').val(CONFIG.accelerometerTrims[1]);
|
||||
|
||||
// Display multiType and motor diagram (if such exist)
|
||||
var str = '';
|
||||
var str;
|
||||
switch (CONFIG.multiType) {
|
||||
case 1: // TRI
|
||||
str = 'TRI';
|
||||
|
@ -134,58 +290,6 @@ TABS.initial_setup.initialize = function (callback) {
|
|||
// Heading
|
||||
$('span.heading').text(chrome.i18n.getMessage('initialSetupheading', [0]));
|
||||
|
||||
// UI Hooks
|
||||
$('a.calibrateAccel').click(function () {
|
||||
var self = $(this);
|
||||
|
||||
if (!self.hasClass('calibrating')) {
|
||||
self.addClass('calibrating');
|
||||
|
||||
// During this period MCU won't be able to process any serial commands because its locked in a for/while loop
|
||||
// until this operation finishes, sending more commands through data_poll() will result in serial buffer overflow
|
||||
GUI.interval_pause('initial_setup_data_pull');
|
||||
MSP.send_message(MSP_codes.MSP_ACC_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibStarted'));
|
||||
});
|
||||
|
||||
GUI.timeout_add('button_reset', function () {
|
||||
GUI.interval_resume('initial_setup_data_pull');
|
||||
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibEnded'));
|
||||
|
||||
self.removeClass('calibrating');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
|
||||
$('a.calibrateMag').click(function () {
|
||||
var self = $(this);
|
||||
|
||||
if (!self.hasClass('calibrating')) {
|
||||
self.addClass('calibrating');
|
||||
|
||||
MSP.send_message(MSP_codes.MSP_MAG_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupMagCalibStarted'));
|
||||
});
|
||||
|
||||
GUI.timeout_add('button_reset', function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupMagCalibEnded'));
|
||||
self.removeClass('calibrating');
|
||||
}, 30000);
|
||||
}
|
||||
});
|
||||
|
||||
$('a.resetSettings').click(function() {
|
||||
MSP.send_message(MSP_codes.MSP_RESET_CONF, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupSettingsRestored'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
TABS.initial_setup.initialize();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('a.update').click(function () {
|
||||
CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());
|
||||
CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val());
|
||||
|
@ -244,6 +348,58 @@ TABS.initial_setup.initialize = function (callback) {
|
|||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// UI Hooks
|
||||
$('a.calibrateAccel').click(function () {
|
||||
var self = $(this);
|
||||
|
||||
if (!self.hasClass('calibrating')) {
|
||||
self.addClass('calibrating');
|
||||
|
||||
// During this period MCU won't be able to process any serial commands because its locked in a for/while loop
|
||||
// until this operation finishes, sending more commands through data_poll() will result in serial buffer overflow
|
||||
GUI.interval_pause('initial_setup_data_pull');
|
||||
MSP.send_message(MSP_codes.MSP_ACC_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibStarted'));
|
||||
});
|
||||
|
||||
GUI.timeout_add('button_reset', function () {
|
||||
GUI.interval_resume('initial_setup_data_pull');
|
||||
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupAccelCalibEnded'));
|
||||
|
||||
self.removeClass('calibrating');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
|
||||
$('a.calibrateMag').click(function () {
|
||||
var self = $(this);
|
||||
|
||||
if (!self.hasClass('calibrating')) {
|
||||
self.addClass('calibrating');
|
||||
|
||||
MSP.send_message(MSP_codes.MSP_MAG_CALIBRATION, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupMagCalibStarted'));
|
||||
});
|
||||
|
||||
GUI.timeout_add('button_reset', function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupMagCalibEnded'));
|
||||
self.removeClass('calibrating');
|
||||
}, 30000);
|
||||
}
|
||||
});
|
||||
|
||||
$('a.resetSettings').click(function() {
|
||||
MSP.send_message(MSP_codes.MSP_RESET_CONF, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupSettingsRestored'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
TABS.initial_setup.initialize();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// display current yaw fix value (important during tab re-initialization)
|
||||
$('div#interactive_block > a.reset').text(chrome.i18n.getMessage('initialSetupButtonResetZaxisValue', [self.yaw_fix]));
|
||||
|
@ -286,7 +442,7 @@ TABS.initial_setup.initialize = function (callback) {
|
|||
GUI.interval_add('initial_setup_data_pull', get_analog_data, 50, true);
|
||||
|
||||
// status data pulled via separate timer with static speed
|
||||
GUI.interval_add('status_pull', function () {
|
||||
GUI.interval_add('status_pull', function status_pull () {
|
||||
MSP.send_message(MSP_codes.MSP_STATUS);
|
||||
}, 250, true);
|
||||
|
||||
|
@ -294,10 +450,16 @@ TABS.initial_setup.initialize = function (callback) {
|
|||
}
|
||||
};
|
||||
|
||||
TABS.initial_setup.initialize3D = function () {
|
||||
TABS.initial_setup.initialize3D = function (compatibility) {
|
||||
var self = this;
|
||||
var canvas = $('#canvas');
|
||||
var wrapper = $('#canvas_wrapper');
|
||||
|
||||
if (compatibility) {
|
||||
var canvas = $('.COMPATIBILITY #canvas');
|
||||
var wrapper = $('.COMPATIBILITY #canvas_wrapper');
|
||||
} else {
|
||||
var canvas = $('.CAP_BASEFLIGHT_CONFIG #canvas');
|
||||
var wrapper = $('.CAP_BASEFLIGHT_CONFIG #canvas_wrapper');
|
||||
}
|
||||
|
||||
var camera = new THREE.PerspectiveCamera(50, wrapper.width() / wrapper.height(), 1, 10000);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue