Module micromelon.battery
Functions to read the state of the robot's internal battery
Expand source code
"""
Functions to read the state of the robot's internal battery
"""
from ._battery import *
__all__ = [
"readVoltage",
"readPercentage",
"readCurrent",
]
Functions
def readCurrent()
-
Reads the current output of the internal battery in milliamps
Returns
integer value in milliamps
Expand source code
def readCurrent(): """ Reads the current output of the internal battery in milliamps Returns: integer value in milliamps """ milliAmps = _rc.readAttribute(OPTYPE.CURRENT_SENSOR) return bytesToIntArray(milliAmps, 2)[0]
def readPercentage()
-
Reads the state of internal battery charge as a percentage
Returns
integer percentage
Expand source code
def readPercentage(): """ Reads the state of internal battery charge as a percentage Returns: integer percentage """ return _rc.readAttribute(OPTYPE.STATE_OF_CHARGE)[0]
def readVoltage()
-
Reads the voltage of the internal battery
Returns
float value in volts
Expand source code
def readVoltage(): """ Reads the voltage of the internal battery Returns: float value in volts """ milliVolts = _rc.readAttribute(OPTYPE.BATTERY_VOLTAGE) milliVolts = bytesToIntArray(milliVolts, 2, False)[0] return float(milliVolts) / 1000.0