mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
fix lpp values for voltage and current as signed
This commit is contained in:
parent
ec91a123ee
commit
e51838177f
2 changed files with 20 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||
|
||||
[project]
|
||||
name = "meshcore"
|
||||
version = "2.2.11"
|
||||
version = "2.2.12"
|
||||
authors = [
|
||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
||||
|
|
|
|||
|
|
@ -35,6 +35,25 @@ my_lpp_types = {
|
|||
|
||||
|
||||
def lpp_format_val(type, val):
|
||||
|
||||
# Fix signed wrap for LPP Current (type 117)
|
||||
if type.type == 117 and len(val) >= 1:
|
||||
v = val[0]
|
||||
# LPP current resolution is typically 0.001 A over uint16 range (0..65.535 A)
|
||||
# Reinterpret values above signed max as negative
|
||||
if v > 32.767:
|
||||
v -= 65.536
|
||||
return round(v, 3)
|
||||
|
||||
# Same for voltage (type 116)
|
||||
if type.type == 116 and len(val) >= 1:
|
||||
v = val[0]
|
||||
# LPP voltage resolution is typically 0.01 V over uint16 range (0..65.535 A)
|
||||
# Reinterpret values above signed max as negative
|
||||
if v > 327.67:
|
||||
v -= 655.36
|
||||
return round(v, 2)
|
||||
|
||||
if my_lpp_types[type.type][1] is None:
|
||||
return val
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue