void DeviceSetBatteryMonitoring(int flag);

 

Turns monitoring for the battery state / level on or off.

 

Return Value

 

Returns a non-zero value if the call was successful, zero otherwise.

 

Parameters

 

flag

Specifies whether battery monitoring should be on or off (0 = off, 1 = on).

 

Remarks

 

DeviceSetBatteryMonitoring() turns battery monitoring on or off.  If you have checked the battery level or state using either DeviceGetBatteryLevel() or DeviceGetBatteryState(), then this function would have been called implicitly for you if battery monitoring was not on previously.

 

NOTE: If your application no longer needs information about the battery, it is a good idea to turn off battery monitoring.

 

Availability

 

Available in DragonFireSDK 1.4 and later.

 

Example

 

#include "DragonFireSDK.h"

 

int MyFont;

int BatteryLevelText;

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);

 

  Value = DeviceGetBatteryLevel();

  sprintf(TextBuffer, "Battery Level: %d", Value);  

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

 

  GetBatteryStateText();

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

  }

 

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

void OnTimer()

{

  Value = DeviceGetBatteryLevel();

  sprintf(TextBuffer, "Battery Level: %d", Value);  

  TextSetText(BatteryLevelText, TextBuffer);

 

  GetBatteryStateText();

  TextSetText(BatteryStateText, TextBuffer);

}

 

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

void AppExit()

{

 

}