Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
247 andreas 1
#include "tiosbattery.h"
2
#include "UIKit/UIKit.h"
3
#include <Foundation/Foundation.h>
4
 
5
TIOSBattery::TIOSBattery()
6
{
7
}
8
 
9
void TIOSBattery::update()
10
{
11
    UIDevice *myDevice = [UIDevice currentDevice];
12
    [myDevice setBatteryMonitoringEnabled:YES];
13
    mLeft = [myDevice batteryLevel] * 100;
14
    int status = [myDevice batteryState];
15
 
16
    switch (status)
17
    {
18
        case UIDeviceBatteryStateUnplugged: mState = BS_UNPLUGGED; break;
19
        case UIDeviceBatteryStateCharging:  mState = BS_CHARGING; break;
20
        case UIDeviceBatteryStateFull:      mState = BS_FULL; break;
21
 
22
        default:
23
            mState = BS_UNKNOWN;
24
    }
25
}