1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 14:55:21 +03:00

cleanup eventPage, small optimizations and stricter rules for msp send callbacks

This commit is contained in:
cTn 2014-10-07 17:40:52 +02:00
parent 719b47ab48
commit 437fbe2cd0
2 changed files with 7 additions and 9 deletions

View file

@ -12,7 +12,7 @@
*/ */
'use strict'; 'use strict';
function start_app() { function startApplication() {
var applicationStartTime = new Date().getTime(); var applicationStartTime = new Date().getTime();
chrome.app.window.create('main.html', { chrome.app.window.create('main.html', {
@ -73,9 +73,7 @@ function start_app() {
}); });
} }
chrome.app.runtime.onLaunched.addListener(function () { chrome.app.runtime.onLaunched.addListener(startApplication);
start_app();
});
chrome.runtime.onInstalled.addListener(function (details) { chrome.runtime.onInstalled.addListener(function (details) {
if (details.reason == 'update') { if (details.reason == 'update') {
@ -107,6 +105,6 @@ chrome.runtime.onInstalled.addListener(function (details) {
chrome.notifications.onButtonClicked.addListener(function (notificationId, buttonIndex) { chrome.notifications.onButtonClicked.addListener(function (notificationId, buttonIndex) {
if (notificationId == 'baseflight_update') { if (notificationId == 'baseflight_update') {
start_app(); startApplication();
} }
}); });

View file

@ -540,16 +540,16 @@ var MSP = {
} }
var obj = {'code': code, 'callback': (callback_msp) ? callback_msp : false}; var obj = {'code': code, 'callback': (callback_msp) ? callback_msp : false};
obj.timer = setInterval(function() { obj.timer = setInterval(function () {
console.log('MSP data request timed-out: ' + code); console.log('MSP data request timed-out: ' + code);
serial.send(bufferOut, function(sendInfo) {}); serial.send(bufferOut, false);
}, 1000); // we should be able to define timeout in the future }, 1000); // we should be able to define timeout in the future
MSP.callbacks.push(obj); MSP.callbacks.push(obj);
serial.send(bufferOut, function(sendInfo) { serial.send(bufferOut, function (sendInfo) {
if (sendInfo.bytesSent > 0) { if (sendInfo.bytesSent == bufferOut.length) {
if (callback_sent) callback_sent(); if (callback_sent) callback_sent();
} }
}); });