Detect support for flash chip and disable tab if not available

10.3.x-maintenance
Nicholas Sherlock 2015-02-16 18:05:24 +13:00
parent 7fb9f43b00
commit ed285992da
4 changed files with 91 additions and 65 deletions

View File

@ -846,7 +846,10 @@
},
"dataflashNote": {
"message": "Blackbox flight logs can be stored on the onboard dataflash chip if your flight controller supports one."
"message": "Blackbox flight logs can be recorded to your flight controller's onboard dataflash chip."
},
"dataflashNotSupportedNote": {
"message": "Your flight controller does not have a compatible dataflash chip available."
},
"dataflashButtonSaveFile": {
"message": "Save flash to file..."

View File

@ -176,4 +176,17 @@
}
.dataflash-saving.done .dataflash-saving-after {
display:block;
}
.require-dataflash {
display:none;
}
.tab-dataflash.supported .require-dataflash {
display:block;
}
.require-no-dataflash {
display:block;
}
.tab-dataflash.supported .require-no-dataflash {
display:none;
}

View File

@ -1,63 +1,66 @@
<div class="tab-dataflash">
<div class="note" i18n="dataflashNote">
</div>
<dialog class="dataflash-confirm-erase">
<h3 i18n="dataflashConfirmEraseTitle"></h3>
<div class="dataflash-confirm-erase-note" i18n="dataflashConfirmEraseNote">
<div class="require-dataflash">
<div class="note" i18n="dataflashNote">
</div>
<div class="dataflash-erase-progress">
<div class="data-loading">
<p>Erase in progress, please wait...</p>
<dialog class="dataflash-confirm-erase">
<h3 i18n="dataflashConfirmEraseTitle"></h3>
<div class="dataflash-confirm-erase-note" i18n="dataflashConfirmEraseNote">
</div>
</div>
<div class="dataflash-erase-progress">
<div class="data-loading">
<p>Erase in progress, please wait...</p>
</div>
</div>
<div class="buttons">
<a href="#" class="erase-flash-cancel" i18n="dataflashButtonEraseCancel"></a>
<a href="#" class="erase-flash-confirm" i18n="dataflashButtonEraseConfirm"></a>
</div>
</dialog>
<dialog class="dataflash-saving">
<h3 i18n="dataflashSavingTitle"></h3>
<div class="dataflash-saving-before">
<div i18n="dataflashSavingNote">
</div>
<progress value="0" min="0" max="100"></progress>
<div class="buttons">
<a href="#" class="save-flash-cancel" i18n="dataflashButtonSaveCancel"></a>
</div>
</div>
<div class="dataflash-saving-after">
<div i18n="dataflashSavingNoteAfter">
</div>
<div class="buttons">
<a href="#" class="save-flash-dismiss" i18n="dataflashButtonSaveDismiss"></a>
</div>
</div>
</dialog>
<h3>Dataflash contents</h3>
<ul class="dataflash-contents">
<li class="dataflash-used">
<div class="legend">
Used space
</div>
</li>
<li class="dataflash-free">
<div class="legend">
Free space
</div>
</li>
</ul>
<div class="buttons">
<a href="#" class="erase-flash-cancel" i18n="dataflashButtonEraseCancel"></a>
<a href="#" class="erase-flash-confirm" i18n="dataflashButtonEraseConfirm"></a>
<a href="#" class="erase-flash" i18n="dataflashButtonErase"></a>
<a href="#" class="save-flash" i18n="dataflashButtonSaveFile"></a>
</div>
</dialog>
<dialog class="dataflash-saving">
<h3 i18n="dataflashSavingTitle"></h3>
<div class="dataflash-saving-before">
<div i18n="dataflashSavingNote">
</div>
<progress value="0" min="0" max="100"></progress>
<div class="buttons">
<a href="#" class="save-flash-cancel" i18n="dataflashButtonSaveCancel"></a>
</div>
</div>
<div class="dataflash-saving-after">
<div i18n="dataflashSavingNoteAfter">
</div>
<div class="buttons">
<a href="#" class="save-flash-dismiss" i18n="dataflashButtonSaveDismiss"></a>
</div>
</div>
</dialog>
<h3>Dataflash contents</h3>
<ul class="dataflash-contents">
<li class="dataflash-used">
<div class="legend">
Used space
</div>
</li>
<li class="dataflash-free">
<div class="legend">
Free space
</div>
</li>
</ul>
<div class="buttons">
<a href="#" class="erase-flash" i18n="dataflashButtonErase"></a>
<a href="#" class="save-flash" i18n="dataflashButtonSaveFile"></a>
</div>
<div class="note require-no-dataflash" i18n="dataflashNotSupportedNote">
</div>
</div>

View File

@ -71,20 +71,27 @@ TABS.dataflash.initialize = function (callback) {
}
function create_html() {
var
supportsDataflash = DATAFLASH.totalSize > 0;
// translate to user-selected language
localize();
// UI hooks
$('.tab-dataflash a.erase-flash').click(ask_to_erase_flash);
$(".tab-dataflash").toggleClass("supported", supportsDataflash);
$('.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();
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();
}
if (callback) callback();
}