Skip to content

Commit

Permalink
Show warning on connect when ACC is not calibrated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller committed Mar 1, 2020
1 parent f4f6da0 commit 5ae4d5a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 3 deletions.
9 changes: 9 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@
"resetToCustomDefaultsAccept": {
"message": "Apply Custom Defaults"
},
"reportProblemsDialogHeader": {
"message": "The following <strong>problems with your configuration</strong> were detected:"
},
"reportProblemsDialogFooter": {
"message": "Please <strong>fix these problems before attempting to fly your craft</strong>."
},
"reportProblemsDialogAccCalibrationNeeded": {
"message": "<strong>the accelerometer is enabled but it is not calibrated</strong>. If you plan to use the accelerometer, please follow the instructions for '$t(initialSetupButtonCalibrateAccel.message)' on the '$t(tabSetup.message)' tab. If any function that requires the accelerometer (auto level modes, GPS rescue, ...) is enabled, arming of the craft will be disabled until the accelerometer has been calibrated."
},

"infoVersions": {
"message" : "Running - OS: <strong>{{operatingSystem}}</strong>, Chrome: <strong>{{chromeVersion}}</strong>, Configurator: <strong>{{configuratorVersion}}</strong>",
Expand Down
16 changes: 16 additions & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,22 @@ input {
margin-bottom: 10px;
}

#dialogReportProblems-header {
margin-top: 10px;
margin-bottom: 5px;
}

.dialogReportProblems-listItem {
list-style: initial;
list-style-type: circle;
margin-left: 20px;
margin-bottom: 5px;
}

#dialogReportProblems-footer {
margin-bottom: 10px;
}

/*
noUi slider stylings
*/
Expand Down
1 change: 1 addition & 0 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ var FC = {
SUPPORTS_CUSTOM_DEFAULTS: 4,
HAS_CUSTOM_DEFAULTS: 5,
SUPPORTS_RX_BIND: 6,
ACC_NEEDS_CALIBRATION: 7,
},

boardHasVcp: function () {
Expand Down
25 changes: 23 additions & 2 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ function onOpen(openInfo) {
if (bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.SUPPORTS_CUSTOM_DEFAULTS) && bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.HAS_CUSTOM_DEFAULTS) && CONFIG.configurationState === FC.CONFIGURATION_STATES.DEFAULTS_BARE) {
var dialog = $('#dialogResetToCustomDefaults')[0];

$('#dialogResetToCustomDefaults-content').html(i18n.getMessage('resetToCustomDefaultsDialog'));

$('#dialogResetToCustomDefaults-acceptbtn').click(function() {
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'AcceptResetToCustomDefaults');

Expand All @@ -287,7 +285,30 @@ function onOpen(openInfo) {
});

dialog.showModal();
} else {
let needsProblemReportingDialog = false;
const problemDialogList = $('#dialogReportProblems-list');
problemDialogList.empty();
const problemItemTemplate = $('.dialogReportProblems-listItem');
const PROBLEM_ANALYTICS_EVENT = 'ProblemFound';

if (bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.ACC_NEEDS_CALIBRATION)) {
needsProblemReportingDialog = true;
problemDialogList.append(problemItemTemplate.clone().html(i18n.getMessage('reportProblemsDialogAccCalibrationNeeded')));

analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, PROBLEM_ANALYTICS_EVENT, 'AccNotCalibrated');
}

if (needsProblemReportingDialog) {
const problemDialog = $('#dialogReportProblems')[0];
$('#dialogReportProblems-closebtn').click(function() {
problemDialog.close();
});

problemDialog.showModal();
}
}

MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
var uniqueDeviceIdentifier = CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16);

Expand Down
22 changes: 21 additions & 1 deletion src/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ <h3 i18n="warningTitle"></h3>
<dialog id="dialogResetToCustomDefaults">
<h3 i18n="noticeTitle"></h3>
<div class="content">
<div id="dialogResetToCustomDefaults-content"></div>
<div id="dialogResetToCustomDefaults-content" i18n="resetToCustomDefaultsDialog"></div>
</div>
<div>
<span class="buttons">
Expand All @@ -371,6 +371,26 @@ <h3 i18n="noticeTitle"></h3>
</div>
</dialog>

<dialog id="dialogReportProblems">
<h3 i18n="warningTitle"></h3>
<div class="content">
<div id="dialogReportProblems-header" i18n="reportProblemsDialogHeader"></div>
<ul id="dialogReportProblems-list">
<!-- List elements added dynamically -->
</ul>
<div id="dialogReportProblems-footer" i18n="reportProblemsDialogFooter"></div>
</div>
<div>
<span class="buttons">
<a href="#" id="dialogReportProblems-closebtn" class="regular-button" i18n="close"></a>
</span>
</div>
</dialog>

<ul> <!-- Sonar says so -->
<li class="dialogReportProblems-listItem"></li>
</ul>

<dialog class="dialogError">
<h3 i18n="errorTitle"></h3>
<div class="content">
Expand Down

0 comments on commit 5ae4d5a

Please sign in to comment.