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:
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() {
} |