#
cp.battery
Provides access to various properties of the battery. Each of these properties
is a cp.prop
, so it can be watched for changes. For example:
local battery = require("cp.battery")
battery.powerSupply:watch(function(value)
print("Now using "..value)
end)
This will print
"Now using AC Power" or "Now using Battery Power" whenever the
power supply changes.
By default the watcher initialises in a "stopped" state, and must be started for
the cp.prop
watchers to trigger.
#
API Overview
Constants - Useful values which cannot be changed
amperage capacity cycles designCapacity health healthCondition isCharged isCharging isFinishingCharge maxCapacity otherBatteryInfo percentage psuSerial timeRemaining timeToFullCharge voltage watts
Variables - Configurable values
_watcher
Functions - API calls offered directly by the extension
start stop