mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
enabling strict in last 2 tabs
This commit is contained in:
parent
a893261e6d
commit
cc8ca21cc0
2 changed files with 33 additions and 29 deletions
|
@ -1,5 +1,7 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
tabs.firmware_flasher = {};
|
tabs.firmware_flasher = {};
|
||||||
tabs.firmware_flasher.initialize = function(callback) {
|
tabs.firmware_flasher.initialize = function (callback) {
|
||||||
GUI.active_tab_ref = this;
|
GUI.active_tab_ref = this;
|
||||||
GUI.active_tab = 'firmware_flasher';
|
GUI.active_tab = 'firmware_flasher';
|
||||||
googleAnalytics.sendAppView('Firmware Flasher');
|
googleAnalytics.sendAppView('Firmware Flasher');
|
||||||
|
@ -7,13 +9,13 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
var intel_hex = false; // standard intel hex in string format
|
var intel_hex = false; // standard intel hex in string format
|
||||||
var parsed_hex = false; // parsed raw hex in array format
|
var parsed_hex = false; // parsed raw hex in array format
|
||||||
|
|
||||||
$('#content').load("./tabs/firmware_flasher.html", function() {
|
$('#content').load("./tabs/firmware_flasher.html", function () {
|
||||||
// translate to user-selected language
|
// translate to user-selected language
|
||||||
localize();
|
localize();
|
||||||
|
|
||||||
// UI Hooks
|
// UI Hooks
|
||||||
$('a.load_file').click(function() {
|
$('a.load_file').click(function () {
|
||||||
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['hex']}]}, function(fileEntry) {
|
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
||||||
if (!fileEntry) {
|
if (!fileEntry) {
|
||||||
// no "valid" file selected/created, aborting
|
// no "valid" file selected/created, aborting
|
||||||
console.log('No valid file selected, aborting');
|
console.log('No valid file selected, aborting');
|
||||||
|
@ -23,14 +25,14 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
// hide github info (if it exists)
|
// hide github info (if it exists)
|
||||||
$('div.git_info').slideUp();
|
$('div.git_info').slideUp();
|
||||||
|
|
||||||
chrome.fileSystem.getDisplayPath(fileEntry, function(path) {
|
chrome.fileSystem.getDisplayPath(fileEntry, function (path) {
|
||||||
console.log('Loading file from: ' + path);
|
console.log('Loading file from: ' + path);
|
||||||
$('span.path').html(path);
|
$('span.path').html(path);
|
||||||
|
|
||||||
fileEntry.file(function(file) {
|
fileEntry.file(function (file) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
|
||||||
reader.onprogress = function(e) {
|
reader.onprogress = function (e) {
|
||||||
if (e.total > 1048576) { // 1 MB
|
if (e.total > 1048576) { // 1 MB
|
||||||
// dont allow reading files bigger then 1 MB
|
// dont allow reading files bigger then 1 MB
|
||||||
console.log('File limit (1 MB) exceeded, aborting');
|
console.log('File limit (1 MB) exceeded, aborting');
|
||||||
|
@ -44,7 +46,7 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
|
|
||||||
intel_hex = e.target.result;
|
intel_hex = e.target.result;
|
||||||
|
|
||||||
parse_hex(intel_hex, function(data) {
|
parse_hex(intel_hex, function (data) {
|
||||||
parsed_hex = data;
|
parsed_hex = data;
|
||||||
|
|
||||||
if (parsed_hex) {
|
if (parsed_hex) {
|
||||||
|
@ -67,10 +69,10 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a.load_remote_file').click(function() {
|
$('a.load_remote_file').click(function() {
|
||||||
$.get('https://raw.githubusercontent.com/hydra/cleanflight/master/obj/cleanflight_NAZE.hex', function(data) {
|
$.get('https://raw.githubusercontent.com/hydra/cleanflight/master/obj/cleanflight_NAZE.hex', function (data) {
|
||||||
intel_hex = data;
|
intel_hex = data;
|
||||||
|
|
||||||
parse_hex(intel_hex, function(data) {
|
parse_hex(intel_hex, function (data) {
|
||||||
parsed_hex = data;
|
parsed_hex = data;
|
||||||
|
|
||||||
if (parsed_hex) {
|
if (parsed_hex) {
|
||||||
|
@ -84,12 +86,12 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
|
GUI.log(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).fail(function() {
|
}).fail(function () {
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
|
GUI.log(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
|
||||||
$('a.flash_firmware').addClass('locked');
|
$('a.flash_firmware').addClass('locked');
|
||||||
});
|
});
|
||||||
|
|
||||||
$.get('https://api.github.com/repos/hydra/cleanflight/commits?page=1&per_page=1&path=obj/cleanflight_NAZE.hex', function(data) {
|
$.get('https://api.github.com/repos/hydra/cleanflight/commits?page=1&per_page=1&path=obj/cleanflight_NAZE.hex', function (data) {
|
||||||
var data = data[0];
|
var data = data[0];
|
||||||
var d = new Date(data.commit.author.date);
|
var d = new Date(data.commit.author.date);
|
||||||
var date = ('0' + (d.getMonth() + 1)).slice(-2) + '.' + ('0' + (d.getDate() + 1)).slice(-2) + '.' + d.getFullYear();
|
var date = ('0' + (d.getMonth() + 1)).slice(-2) + '.' + ('0' + (d.getDate() + 1)).slice(-2) + '.' + d.getFullYear();
|
||||||
|
@ -103,7 +105,7 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a.flash_firmware').click(function() {
|
$('a.flash_firmware').click(function () {
|
||||||
if (!$(this).hasClass('locked')) {
|
if (!$(this).hasClass('locked')) {
|
||||||
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
||||||
if (parsed_hex != false) {
|
if (parsed_hex != false) {
|
||||||
|
@ -151,7 +153,7 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('no_reboot_sequence', function(result) {
|
chrome.storage.local.get('no_reboot_sequence', function (result) {
|
||||||
if (result.no_reboot_sequence) {
|
if (result.no_reboot_sequence) {
|
||||||
$('input.updating').prop('checked', true);
|
$('input.updating').prop('checked', true);
|
||||||
$('label.flash_on_connect_wrapper').show();
|
$('label.flash_on_connect_wrapper').show();
|
||||||
|
@ -174,21 +176,21 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('flash_on_connect', function(result) {
|
chrome.storage.local.get('flash_on_connect', function (result) {
|
||||||
if (result.flash_on_connect) {
|
if (result.flash_on_connect) {
|
||||||
$('input.flash_on_connect').prop('checked', true);
|
$('input.flash_on_connect').prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
$('input.flash_on_connect').prop('checked', false);
|
$('input.flash_on_connect').prop('checked', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('input.flash_on_connect').change(function() {
|
$('input.flash_on_connect').change(function () {
|
||||||
var status = $(this).is(':checked');
|
var status = $(this).is(':checked');
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
var flashing_port;
|
var flashing_port;
|
||||||
|
|
||||||
function start() {
|
var start = function () {
|
||||||
PortHandler.port_detected('flash_next_device', function(result) {
|
PortHandler.port_detected('flash_next_device', function (result) {
|
||||||
flashing_port = result[0];
|
flashing_port = result[0];
|
||||||
GUI.log('Detected: <strong>' + flashing_port + '</strong> - triggering flash on connect');
|
GUI.log('Detected: <strong>' + flashing_port + '</strong> - triggering flash on connect');
|
||||||
console.log('Detected: ' + flashing_port + ' - triggering flash on connect');
|
console.log('Detected: ' + flashing_port + ' - triggering flash on connect');
|
||||||
|
@ -201,8 +203,8 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
}, false, true);
|
}, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function end() {
|
var end = function () {
|
||||||
PortHandler.port_removed('flashed_device_removed', function(result) {
|
PortHandler.port_removed('flashed_device_removed', function (result) {
|
||||||
for (var i = 0; i < result.length; i++) {
|
for (var i = 0; i < result.length; i++) {
|
||||||
if (result[i] == flashing_port) {
|
if (result[i] == flashing_port) {
|
||||||
// flashed device removed
|
// flashed device removed
|
||||||
|
@ -230,7 +232,7 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
}).change();
|
}).change();
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('erase_chip', function(result) {
|
chrome.storage.local.get('erase_chip', function (result) {
|
||||||
if (result.erase_chip) {
|
if (result.erase_chip) {
|
||||||
$('input.erase_chip').prop('checked', true);
|
$('input.erase_chip').prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,14 +240,14 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// bind UI hook so the status is saved on change
|
// bind UI hook so the status is saved on change
|
||||||
$('input.erase_chip').change(function() {
|
$('input.erase_chip').change(function () {
|
||||||
var status = $(this).is(':checked');
|
var status = $(this).is(':checked');
|
||||||
|
|
||||||
chrome.storage.local.set({'erase_chip': status});
|
chrome.storage.local.set({'erase_chip': status});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).keypress(function(e) {
|
$(document).keypress(function (e) {
|
||||||
if (e.which == 13) { // enter
|
if (e.which == 13) { // enter
|
||||||
// Trigger regular Flashing sequence
|
// Trigger regular Flashing sequence
|
||||||
$('a.flash_firmware').click();
|
$('a.flash_firmware').click();
|
||||||
|
@ -253,9 +255,9 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// back button
|
// back button
|
||||||
$('a.back').click(function() {
|
$('a.back').click(function () {
|
||||||
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function () {
|
||||||
tabs.default.initialize();
|
tabs.default.initialize();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -267,7 +269,7 @@ tabs.firmware_flasher.initialize = function(callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
tabs.firmware_flasher.cleanup = function(callback) {
|
tabs.firmware_flasher.cleanup = function (callback) {
|
||||||
PortHandler.flush_callbacks();
|
PortHandler.flush_callbacks();
|
||||||
|
|
||||||
// unbind "global" events
|
// unbind "global" events
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var MSP_pass_through = false;
|
var MSP_pass_through = false;
|
||||||
|
|
||||||
tabs.logging = {};
|
tabs.logging = {};
|
||||||
|
@ -11,11 +13,11 @@ tabs.logging.initialize = function(callback) {
|
||||||
if (configuration_received) {
|
if (configuration_received) {
|
||||||
MSP.send_message(MSP_codes.MSP_RC, false, false, get_motor_data);
|
MSP.send_message(MSP_codes.MSP_RC, false, false, get_motor_data);
|
||||||
|
|
||||||
function get_motor_data() {
|
var get_motor_data = function () {
|
||||||
MSP.send_message(MSP_codes.MSP_MOTOR, false, false, load_html);
|
MSP.send_message(MSP_codes.MSP_MOTOR, false, false, load_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_html() {
|
var load_html = function () {
|
||||||
$('#content').load("./tabs/logging.html", process_html);
|
$('#content').load("./tabs/logging.html", process_html);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -61,7 +63,7 @@ tabs.logging.initialize = function(callback) {
|
||||||
// print header for the csv file
|
// print header for the csv file
|
||||||
print_head();
|
print_head();
|
||||||
|
|
||||||
function log_data_poll() {
|
var log_data_poll = function () {
|
||||||
if (requests) {
|
if (requests) {
|
||||||
// save current data (only after everything is initialized)
|
// save current data (only after everything is initialized)
|
||||||
crunch_data();
|
crunch_data();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue