mirror of
https://github.com/okalachev/flix.git
synced 2026-06-27 21:46:38 +00:00
Implement battery voltage monitoring
Add power subsystem. Add PWR_VOLT_PIN, PWR_VOLT_SCALE, PWR_VOLT_LPF_A parameters. Support BATTERY_STATUS mavlink messages streaming. Add pw cli command. Add voltage field to pyflix library. pyflix@0.12.
This commit is contained in:
@@ -26,6 +26,7 @@ class Flix:
|
||||
mode: str = ''
|
||||
armed: bool = False
|
||||
landed: bool = False
|
||||
voltage: float = 0
|
||||
attitude: List[float]
|
||||
attitude_euler: List[float] # roll, pitch, yaw
|
||||
rates: List[float]
|
||||
@@ -68,7 +69,7 @@ class Flix:
|
||||
self._heartbeat_thread.start()
|
||||
if wait_connection:
|
||||
self.wait('mavlink.HEARTBEAT')
|
||||
time.sleep(0.2) # give some time to receive initial state
|
||||
time.sleep(0.6) # give some time to receive initial state
|
||||
|
||||
def _init_state(self):
|
||||
self.attitude = [1, 0, 0, 0]
|
||||
@@ -190,6 +191,10 @@ class Flix:
|
||||
self._trigger('acc', self.acc)
|
||||
self._trigger('gyro', self.gyro)
|
||||
|
||||
if isinstance(msg, mavlink.MAVLink_battery_status_message):
|
||||
self.voltage = msg.voltages[0] / 1000
|
||||
self._trigger('voltage', self.voltage)
|
||||
|
||||
if isinstance(msg, mavlink.MAVLink_serial_control_message):
|
||||
# new chunk of data
|
||||
text = bytes(msg.data)[:msg.count].decode('utf-8', errors='ignore')
|
||||
|
||||
Reference in New Issue
Block a user