Skip to content

Commit

Permalink
Add unknown statistics fields to OSD (betaflight#1507)
Browse files Browse the repository at this point in the history
Add unknown statistics fields to OSD
  • Loading branch information
mikeller authored Jun 30, 2019
2 parents a546e23 + 555f372 commit fa79242
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
4 changes: 3 additions & 1 deletion locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4427,7 +4427,9 @@
"osdDescStatMinRssiDbm": {
"message": "Minimum RSSI dBm value"
},

"osdDescStatUnknown": {
"message": "Unknown statistic (details to be added in a future release)"
},
"osdDescribeFontVersion1": {
"message": "Font version: 1 (Betaflight 4.0 or older)"
},
Expand Down
38 changes: 21 additions & 17 deletions src/js/tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -1823,23 +1823,27 @@ OSD.msp = {
if (expectedStatsCount != OSD.constants.STATISTIC_FIELDS.length) {
console.error("Firmware is transmitting a different number of statistics (" + expectedStatsCount + ") to what the configurator is expecting (" + OSD.constants.STATISTIC_FIELDS.length + ")");
}
while (view.offset < view.byteLength && d.stat_items.length < OSD.constants.STATISTIC_FIELDS.length) {
var v = view.readU8();
var j = d.stat_items.length;
var c = OSD.constants.STATISTIC_FIELDS[j];
d.stat_items.push({
name: c.name,
text: c.text,
desc: c.desc,
index: j,
enabled: v === 1
});
expectedStatsCount--;
}
// Read all the data for any statistics we don't know about
while (expectedStatsCount > 0) {
view.readU8();
expectedStatsCount--;

for (var i = 0; i < expectedStatsCount; i++) {

let v = view.readU8();

// Known statistics field
if (i < OSD.constants.STATISTIC_FIELDS.length) {

let c = OSD.constants.STATISTIC_FIELDS[i];
d.stat_items.push({
name: c.name,
text: c.text,
desc: c.desc,
index: i,
enabled: v === 1
});

// Read all the data for any statistics we don't know about
} else {
d.stat_items.push({name: 'UNKNOWN', desc: 'osdDescStatUnknown', index: i, enabled: v === 1 });
}
}

// Parse configurable timers
Expand Down

0 comments on commit fa79242

Please sign in to comment.