pybricks.common.Charger: Document it.

This commit is contained in:
Laurens Valk
2022-01-14 15:14:28 +01:00
parent d3ae4ec9ee
commit 0ceabe8497
3 changed files with 44 additions and 1 deletions
+8
View File
@@ -83,6 +83,14 @@ Prime Hub / Inventor Hub
.. automethod:: pybricks.hubs::PrimeHub.battery.current
.. rubric:: Getting the charger status
.. automethod:: pybricks.hubs::PrimeHub.charger.connected
.. automethod:: pybricks.hubs::PrimeHub.charger.current
.. automethod:: pybricks.hubs::PrimeHub.charger.status
.. rubric:: System control
.. automethod:: pybricks.hubs::PrimeHub.system.set_stop_button
+34
View File
@@ -708,6 +708,40 @@ class Battery:
pass
class Charger:
"""Get the status of a battery charger."""
def connected(self):
"""Checks whether a charger is connected via USB.
Returns:
bool: ``True`` if a charger is connected, ``False`` if not.
"""
def status(self):
"""Gets the status of the battery charger, represented by one of the
following values. This corresponds to the battery light indicator
right next to the USB port.
0. Not charging (off).
1. Charging (red).
2. Charging is complete (green).
3. There is a problem with the charger (yellow).
Returns:
int: Status value.
"""
pass
def current(self):
"""Gets the charging current.
Returns:
:ref:`current`: Charging current.
"""
pass
class SimpleAccelerometer:
"""Get measurements from an accelerometer."""
+2 -1
View File
@@ -5,7 +5,7 @@
from ._common import (Speaker as _Speaker, Battery as _Battery,
ColorLight as _ColorLight, Keypad as _Keypad,
LightMatrix as _LightMatrix, IMU as _IMU,
System as _System,
Charger as _Charger, System as _System,
SimpleAccelerometer as _SimpleAccelerometer)
from .ev3dev._speaker import Speaker as _EV3Speaker
from .geometry import Axis as _Axis
@@ -94,6 +94,7 @@ class PrimeHub:
_Button.CENTER,
_Button.BLUETOOTH,
))
charger = _Charger()
light = _ColorLight()
display = _LightMatrix(5, 5)
speaker = _Speaker()