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. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
discovering_20the_20system_20power_20status.txt · Last modified: 2024/01/05 00:22 by 127.0.0.1