mirror of
https://github.com/liberatedsystems/Sideband_CE.git
synced 2024-09-03 04:13:27 +02:00
Added relative rendering to telemeter
This commit is contained in:
parent
e664850c7e
commit
23a4e5b312
@ -5,6 +5,7 @@ import struct
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
from RNS.vendor import umsgpack as umsgpack
|
from RNS.vendor import umsgpack as umsgpack
|
||||||
|
from .geo import orthodromic_distance, euclidian_distance, azalt
|
||||||
|
|
||||||
class Telemeter():
|
class Telemeter():
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -421,12 +422,26 @@ class Pressure(Sensor):
|
|||||||
def render(self, relative_to=None):
|
def render(self, relative_to=None):
|
||||||
if self.data == None:
|
if self.data == None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
delta = None
|
||||||
|
if relative_to and "pressure" in relative_to.sensors:
|
||||||
|
rs = relative_to.sensors["pressure"]
|
||||||
|
if "mbar" in rs.data and rs.data["mbar"] != None:
|
||||||
|
if self.data["mbar"] != None:
|
||||||
|
delta = round(rs.data["mbar"] - self.data["mbar"], 1)
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
|
# RNS.log("OVERRIDING DELTA", RNS.LOG_WARNING)
|
||||||
|
# delta = round(740.1 - self.data["mbar"], 1)
|
||||||
|
|
||||||
rendered = {
|
rendered = {
|
||||||
"icon": "weather-cloudy",
|
"icon": "weather-cloudy",
|
||||||
"name": "Ambient Pressure",
|
"name": "Ambient Pressure",
|
||||||
"values": { "mbar": self.data["mbar"] },
|
"values": { "mbar": self.data["mbar"] },
|
||||||
}
|
}
|
||||||
|
if delta != None:
|
||||||
|
rendered["deltas"] = {"mbar": delta}
|
||||||
|
|
||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
class Location(Sensor):
|
class Location(Sensor):
|
||||||
@ -596,11 +611,31 @@ class Location(Sensor):
|
|||||||
"longtitude": self.data["longtitude"],
|
"longtitude": self.data["longtitude"],
|
||||||
"altitude": self.data["altitude"],
|
"altitude": self.data["altitude"],
|
||||||
"speed": self.data["speed"],
|
"speed": self.data["speed"],
|
||||||
"bearing": self.data["bearing"],
|
"heading": self.data["bearing"],
|
||||||
"accuracy": self.data["accuracy"],
|
"accuracy": self.data["accuracy"],
|
||||||
"updated": self.data["last_update"],
|
"updated": self.data["last_update"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if relative_to != None and "location" in relative_to.sensors:
|
||||||
|
slat = self.data["latitude"]; slon = self.data["longtitude"]
|
||||||
|
salt = self.data["altitude"];
|
||||||
|
if salt == None: salt = 0
|
||||||
|
if slat != None and slon != None:
|
||||||
|
s = relative_to.sensors["location"]
|
||||||
|
d = s.data
|
||||||
|
if "latitude" in d and "longtitude" in d and "altitude" in d:
|
||||||
|
lat = d["latitude"]; lon = d["longtitude"]; alt = d["altitude"]
|
||||||
|
if lat != None and lon != None:
|
||||||
|
if alt == None: alt = 0
|
||||||
|
cs = (slat, slon, salt); cr = (lat, lon, alt)
|
||||||
|
ed = euclidian_distance(cs, cr)
|
||||||
|
od = orthodromic_distance(cs, cr)
|
||||||
|
aa = azalt(cs, cr)
|
||||||
|
rendered["distance"] = {"euclidian": ed, "orthodromic": od}
|
||||||
|
rendered["azalt"] = {"azimuth": aa[0], "altitude": aa[1]}
|
||||||
|
|
||||||
|
|
||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
class PhysicalLink(Sensor):
|
class PhysicalLink(Sensor):
|
||||||
@ -865,12 +900,26 @@ class AmbientLight(Sensor):
|
|||||||
def render(self, relative_to=None):
|
def render(self, relative_to=None):
|
||||||
if self.data == None:
|
if self.data == None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
delta = None
|
||||||
|
if relative_to and "ambient_light" in relative_to.sensors:
|
||||||
|
rs = relative_to.sensors["ambient_light"]
|
||||||
|
if "lux" in rs.data and rs.data["lux"] != None:
|
||||||
|
if self.data["lux"] != None:
|
||||||
|
delta = round(rs.data["lux"] - self.data["lux"], 2)
|
||||||
|
|
||||||
|
# TODO: Remove
|
||||||
|
# RNS.log("OVERRIDING DELTA", RNS.LOG_WARNING)
|
||||||
|
# delta = round(2500 - self.data["lux"], 2)
|
||||||
|
|
||||||
rendered = {
|
rendered = {
|
||||||
"icon": "white-balance-sunny",
|
"icon": "white-balance-sunny",
|
||||||
"name": "Ambient Light",
|
"name": "Ambient Light",
|
||||||
"values": { "lux": self.data["lux"] },
|
"values": { "lux": self.data["lux"] },
|
||||||
}
|
}
|
||||||
|
if delta != None:
|
||||||
|
rendered["deltas"] = {"lux": delta}
|
||||||
|
|
||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
class Gravity(Sensor):
|
class Gravity(Sensor):
|
||||||
|
Loading…
Reference in New Issue
Block a user