1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-26 09:45:23 +03:00

Merge pull request #450 from iNavFlight/agh_workaround_f3_font_bug

Add a workaround for uploading fonts on F3 from macOS
This commit is contained in:
Alberto García Hierro 2018-05-25 13:15:54 +01:00 committed by GitHub
commit aeff96317a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -273,7 +273,7 @@ var MSP = {
} }
}, },
send_message: function (code, data, callback_sent, callback_msp) { send_message: function (code, data, callback_sent, callback_msp, protocolVersion) {
var payloadLength = data && data.length ? data.length : 0; var payloadLength = data && data.length ? data.length : 0;
var length; var length;
var buffer; var buffer;
@ -281,7 +281,11 @@ var MSP = {
var checksum; var checksum;
var ii; var ii;
switch (this.protocolVersion) { if (!protocolVersion) {
protocolVersion = this.protocolVersion;
}
switch (protocolVersion) {
case this.constants.PROTOCOL_V1: case this.constants.PROTOCOL_V1:
// TODO: Error if code is < 255 and MSPv1 is requested // TODO: Error if code is < 255 and MSPv1 is requested
length = payloadLength + 6; length = payloadLength + 6;
@ -322,7 +326,7 @@ var MSP = {
view[length-1] = checksum; view[length-1] = checksum;
break; break;
default: default:
throw "Invalid MSP protocol version " + this.protocolVersion; throw "Invalid MSP protocol version " + protocolVersion;
} }
@ -354,12 +358,12 @@ var MSP = {
} }
return crc; return crc;
}, },
promise: function(code, data) { promise: function(code, data, protocolVersion) {
var self = this; var self = this;
return new Promise(function(resolve) { return new Promise(function(resolve) {
self.send_message(code, data, false, function(data) { self.send_message(code, data, false, function(data) {
resolve(data); resolve(data);
}); }, protocolVersion);
}); });
}, },
callbacks_cleanup: function () { callbacks_cleanup: function () {

View file

@ -236,7 +236,9 @@ FONT.msp = {
FONT.upload = function ($progress) { FONT.upload = function ($progress) {
return Promise.mapSeries(FONT.data.characters, function (data, i) { return Promise.mapSeries(FONT.data.characters, function (data, i) {
$progress.val((i / FONT.data.characters.length) * 100); $progress.val((i / FONT.data.characters.length) * 100);
return MSP.promise(MSPCodes.MSP_OSD_CHAR_WRITE, FONT.msp.encode(i)); // Force usage of V1 protocol to workaround the 64 byte write bug
// on F3 when the configurator is running on macOS
return MSP.promise(MSPCodes.MSP_OSD_CHAR_WRITE, FONT.msp.encode(i), MSP.constants.PROTOCOL_V1);
}) })
.then(function () { .then(function () {
OSD.GUI.jbox.close(); OSD.GUI.jbox.close();