StarOS: battery

Part battery_cell, 1 port each, and it stacks. The module is battery. Each cell stores 300 Wh and charges at up to 150 W. See the overview.

function returns
battery.charge() energy stored, Wh, as the turn began
battery.capacity() what the cells can store, Wh
battery.is_charging() True if the cells took charge from a network last turn

Every base also has a solar skin that works with no part. A crane carries a pack of its own that counts as cells.

def tick():
    if battery.charge() * 4 < battery.capacity():
        robot.log("low battery")
    else:
        robot.move("east")