User Tools

Site Tools


discovering_20the_20system_20power_20status

This is an old revision of the document!


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.1522502356.txt.gz · Last modified: 2018/03/31 13:19 by 127.0.0.1