A Python library for talking to the AXP209 power management unit
AXP209 is a pmu that is used on quite few Allwinner embeded boards, like C.H.I.P and Cubietruck.
Because currently the sysfs api for AXP209 is in flux I wrote this library that bypasses the kernel and directly talks to the AXP209 over I2C bus using smbus2 library.
This library runs on both Python 2.7 and Python 3
Installation
pip install axp209
SMBus bus number/object
The default SMBus object set in this library is an integer 0. You might need to change to another integer[like 1] depending on your system, or pass an object. e.g. axp = AXP209(1) for the Olimex A20-SOM204.
Examples
>>> from axp209 import AXP209
>>> axp = AXP209()
>>> axp.battery_voltage
4144.8
>>> axp.battery_discharge_current
269.0
>>>
Read and print out all the battery status values
from axp209 import AXP209
axp = AXP209()
print("internal_temperature: %.2fC" % axp.internal_temperature)
print("battery_exists: %s" % axp.battery_exists)
print("battery_charging: %s" % ("charging" if axp.battery_charging else "done"))
print("battery_current_direction: %s" % ("charging" if axp.battery_current_direction else "discharging"))
print("battery_voltage: %.1fmV" % axp.battery_voltage)
print("battery_discharge_current: %.1fmA" % axp.battery_discharge_current)
print("battery_charge_current: %.1fmA" % axp.battery_charge_current)
print("battery_gauge: %d%%" % axp.battery_gauge)
axp.close()
Blink CHIP status led
from time import sleep
from axp209 import AXP209
with AXP209() as axp:
while True:
axp.gpio2_output = False
sleep(1)
axp.gpio2_output = True
sleep(1)
There is also a commandline utility than you can use after installing it
root@sumochip1:~# axp209
internal_temperature: 67.00C
battery_exists: True
battery_charging: charging
battery_current_direction: discharging
battery_voltage: 3974.3mV
battery_discharge_current: 0.0mA
battery_charge_current: 0.0mA
battery_gauge: 76%
root@sumochip1:~#
Metadata
Release files for axp209 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| axp209-0.1.tar.gz | 4.7 kB | Without provenance | Details for axp209-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| axp209-0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for axp209-0.1-py2.py3-none-any.whl |
Total release size: 10.3 kB
Release files / axp209-0.1.tar.gz
| Download URL | axp209-0.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e6664766954cfad99500e58399cc1f826e5423a91ed41970abb0fb38f40fd3b
|
|
BLAKE2b-256 checksum How to use checksums |
87388ba45c4669d3c0af6790e206c81491a7987883b5abe9105d6f1878c35f89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Release files / axp209-0.1-py2.py3-none-any.whl
| Download URL | axp209-0.1-py2.py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8a9381838de4bc683ec7dc574057438f4974f742d1cae238e1bebddb38fdccfb
|
|
BLAKE2b-256 checksum How to use checksums |
aaa0798e9f09365b33194494aaa0fb6a6c23ea061f00c7eb29c987a61fb919a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Security for axp209 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.