Merge pull request #132 from JWyman482/bds62_baro_rounding_fix

Bds62 baro rounding fix
This commit is contained in:
Xavier Olive 2022-08-15 23:39:15 +02:00 committed by GitHub
commit d3607a16c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -2,7 +2,7 @@ def tell(msg: str) -> None:
from pyModeS import common, adsb, commb, bds from pyModeS import common, adsb, commb, bds
def _print(label, value, unit=None): def _print(label, value, unit=None):
print("%20s: " % label, end="") print("%28s: " % label, end="")
print("%s " % value, end="") print("%s " % value, end="")
if unit: if unit:
print(unit) print(unit)
@ -127,7 +127,7 @@ def tell(msg: str) -> None:
lnav = adsb.lnav_mode(msg) lnav = adsb.lnav_mode(msg)
_print("Selected altitude", alt, "feet") _print("Selected altitude", alt, "feet")
_print("Altitude source", alt_source) _print("Altitude source", alt_source)
_print("Barometric pressure setting", baro, "millibars") _print("Barometric pressure setting", baro, "" if baro == None else "millibars")
_print("Selected Heading", hdg, "°") _print("Selected Heading", hdg, "°")
if not (common.bin2int((common.hex2bin(msg)[32:])[46]) == 0): if not (common.bin2int((common.hex2bin(msg)[32:])[46]) == 0):
_print("Autopilot", types_29[autopilot] if autopilot else None) _print("Autopilot", types_29[autopilot] if autopilot else None)

View File

@ -274,8 +274,7 @@ def baro_pressure_setting(msg):
) )
baro = common.bin2int(mb[20:29]) baro = common.bin2int(mb[20:29])
baro = None if baro == 0 else 800 + (baro - 1) * 0.8 baro = None if baro == 0 else round(800 + (baro - 1) * 0.8, 1)
baro = round(baro, 1)
return baro return baro