Skip to content
Tangent 128 edited this page Mar 28, 2015 · 3 revisions

SDL.getPowerInfo

Get the current power state.

Function

SYNOPSIS

state, seconds, percentage = function SDL.getPowerInfo()

RETURNS

  • state, the current state (see SDL.powerState)
  • seconds, the seconds left (if battery)
  • percentage, the percentage left (if battery)

EXAMPLES

local state, secs, pct = SDL.getPowerInfo()

if state == SDL.powerState.OnBattery then
print("Running on battery")
print(string.format("%d seconds left", secs))
end
Clone this wiki locally