mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
fix lpp values for voltage and current as signed
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "2.2.11"
|
version = "2.2.12"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
{ name="Alex Wolden", email="awolden@gmail.com" },
|
||||||
|
|||||||
@@ -35,6 +35,25 @@ my_lpp_types = {
|
|||||||
|
|
||||||
|
|
||||||
def lpp_format_val(type, val):
|
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:
|
if my_lpp_types[type.type][1] is None:
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user