User Tools

Site Tools


discovering_20the_20system_20power_20status

Discovering the system power status

by Richard Russell, October 2011

The code listed below reports the current system power status, including whether the PC is operating from batteries or from the mains, the current battery status and the remaining battery life (if appropriate).

        DIM sps{ACLineStatus&, BatteryFlag&, BatteryLifePercent&, Reserved1&, \
        \       BatteryLifeTime%, BatteryFullLifeTime%}
 
        SYS "GetSystemPowerStatus", sps{}
        CASE sps.ACLineStatus& OF
          WHEN 0: PRINT "Operating from batteries"
          WHEN 1: PRINT "Operating on mains"
        ENDCASE
        CASE sps.BatteryFlag& OF
          WHEN 1: PRINT "Battery charge status is high"
          WHEN 2: PRINT "Battery charge status is low"
          WHEN 4: PRINT "Battery charge status is critical"
          WHEN 8: PRINT "Battery is charging"
          WHEN 128: PRINT "No battery fitted"
        ENDCASE
        IF sps.BatteryLifeTime%<>-1 THEN
          PRINT "Approximate remaining battery life is "; \
          \     sps.BatteryLifeTime% DIV 60 " minutes"
        ENDIF
        IF sps.BatteryFullLifeTime%<>-1 THEN
          PRINT "Approximate battery life when fully charged is "; \
          \     sps.BatteryFullLifeTime% DIV 60 " minutes"
        ENDIF
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
discovering_20the_20system_20power_20status.txt · Last modified: 2018/04/15 10:19 by richardrussell