Skip to content

Commit

Permalink
Port to new protocol (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindrehan authored Jul 5, 2023
2 parents 5bedc48 + 79f9eff commit b879a6c
Show file tree
Hide file tree
Showing 24 changed files with 5,038 additions and 1,381 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: ["3.7", "3.8", "3.9", "3.10"]
python: ["3.8", "3.9", "3.10", "3.11"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -23,17 +26,15 @@ jobs:
run: poetry install
- name: Run tests
run: poetry run pytest -k "not connected_to_drone" --cov-report=xml --cov blueye
- name: Upload coverage
run: |
curl -s https://codecov.io/bash |\
bash -s -- -F \
$(echo ${{ matrix.os}} |\
cut -d "-" -f 1 |\
sed "s/$/_python${{ matrix.python }}/" |\
sed "s/\.//")
shell: bash
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,PYTHON
fail_ci_if_error: false
files: ./coverage.xml
flags: ${{ matrix.os }}_${{ matrix.python }}
name: codecov-umbrella
continue-on-error: true

CheckFormatting:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ repos:
rev: stable
hooks:
- id: black
language_version: python3.7
language_version: python3.8
1 change: 0 additions & 1 deletion blueye/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .camera import DepthUnitOverlay, FontSizeOverlay, LogoOverlay, TemperatureUnitOverlay
from .constants import WaterDensities
from .drone import Drone
from .utils import open_local_documentation
28 changes: 28 additions & 0 deletions blueye/sdk/battery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Optional

import blueye.protocol

# Necessary to avoid cyclic imports
if TYPE_CHECKING:
from .drone import Drone


class Battery:
def __init__(self, parent_drone: Drone):
self._parent_drone = parent_drone

@property
def state_of_charge(self) -> Optional[float]:
"""Get the battery state of charge
*Returns*:
* Current state of charge of the drone battery (0..1)
"""
battery_tel = self._parent_drone.telemetry.get(blueye.protocol.BatteryTel)
if battery_tel is not None:
return battery_tel.battery.level
else:
return None
Loading

0 comments on commit b879a6c

Please sign in to comment.