int DeviceGetBatteryState();

 

Gets the state of the device's battery.

 

Return Value

 

Returns an integer value that represents the current battery state.

 

Remarks

 

DeviceGetBatteryState() returns the current battery state.  See the table below for possible return values:

 

Return Value

Description

Notes

0

Unknown

The battery state could not be determined

1

Unplugged

The device is not plugged in to power and battery is discharging

2

Charging

The device is plugged in and battery is charging

3

Full

The device is plugged in and battery is fully charged

 

Windows Simulator NOTE: To provide values for the Windows Simulator, be sure to edit C:\DragonFireSDK\DragonFireSDK.ini and modify the value for BatteryState in the Device section.

 

Availability

 

Available in DragonFireSDK 1.4 and later.

 

Example

 

#include "DragonFireSDK.h"

 

int MyFont;

int BatteryStateText;

 

int Value;

char TextBuffer[100];

 

void GetBatteryStateText()

{

  Value = DeviceGetBatteryState();

  switch (Value)

  {

    case 0:

        sprintf(TextBuffer, "Battery State: Unknown");

        break;

 

    case 1:

        sprintf(TextBuffer, "Battery State: Unplugged");

        break;

 

    case 2:

        sprintf(TextBuffer, "Battery State: Charging");

        break;

       

    case 3:

        sprintf(TextBuffer, "Battery State: Full");

        break;

 

    default:

        sprintf(TextBuffer, "Battery State: Unknown");

        break;

  }

}

 

void AppMain()

{  

  LandscapeMode();

 

  DeviceSetBatteryMonitoring(1);

  MyFont = FontAdd("Helvetica", "Regular", 18, 0x00FF00);

 

  GetBatteryStateText();

  BatteryStateText = TextAdd(10, 10, TextBuffer, MyFont);

}

 

//===============================================

void OnTimer()

{

  GetBatteryStateText();

  TextSetText(BatteryStateText, TextBuffer);

}

 

//===============================================

void AppExit()

{

 

}