pamoja-power
Duty cycling and an energy-aware governor that stretches work as the battery drains. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-power
from pamoja import power
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/power.py:
from pamoja.power import DutyCycle, PowerMode, power_plan
# A solar node samples every minute while the charge is healthy, stretches to ten minutes
# to conserve, and to an hour once the battery is nearly flat. Durations cross the binding
# as microseconds.
plan = power_plan(60_000_000, 600_000_000, 3_600_000_000)
# The default thresholds enter saver mode below 50% charge and critical below 20%.
for charge in (0.80, 0.35, 0.12):
every = plan.interval_us(charge) // 1_000_000
print(f"at {charge * 100:.0f}% charge: {plan.mode(charge)}, sampling every {every}s")
# A panel that is delivering buys back one mode, so the same flat battery keeps reporting
# on the ten-minute saver cadence while the sun is on it.
charging = plan.mode_while_charging(0.12, True)
print(f"the same flat battery, while charging: {charging}")
# The work is the same two seconds whichever mode the node is in; stretching the cycle is
# what saves the energy. The duty fraction is the proxy for average draw, so the hourly
# cadence costs a sixtieth of what the one-minute cadence does.
awake_us = 2_000_000
healthy = DutyCycle(awake_us, plan.interval_us(0.80) - awake_us)
flat = DutyCycle(awake_us, plan.interval_us(0.12) - awake_us)
print(f"awake {healthy.fraction * 100:.2f}% of the time when healthy")
print(f"awake {flat.fraction * 100:.3f}% of the time when flat")
# Stating the budget as a fraction instead gives the awake time directly.
quarter = DutyCycle.from_fraction(1_000_000, 0.25)
print(f"a quarter-duty second is {quarter.active_us / 1000:.0f}ms awake")
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-power |
reference, docs.rs, install |
| TypeScript | @pamoja/power |
reference, install |
| Python | pamoja-power |
reference, install |
| C# | Pamoja.Power |
reference, install |
Documentation
pamoja.powerreference, every class and function in this module.- The Power guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-power 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pamoja_power-0.1.18.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_power-0.1.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.3 kB
Release files / pamoja_power-0.1.18.tar.gz
| Download URL | pamoja_power-0.1.18.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b96a8031e7b4db93305c538d369dd84d6403cc3d9b7ead5937697f83fe100dfb
|
|
BLAKE2b-256 checksum How to use checksums |
f3852de0f77ed7111a6eee7b57abf48cec778d04906328a39c7e65f07a894200
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_power-0.1.18-py3-none-any.whl
| Download URL | pamoja_power-0.1.18-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
090b6393f703488429cf3cf46a811a91c32b654c073d1eaf1fc20cbb2c5b2a90
|
|
BLAKE2b-256 checksum How to use checksums |
c4164d8a84dd6920c1b70d9d654086b419ad73cb8a2a4ce5ac29f03d8274e3b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|