Power manager class. More...
#include <PowerManager.h>
Public Member Functions | |
virtual | ~PowerManager () |
Class destructor. | |
void | enableTransitions (bool flag) |
Enable power state switching. | |
bool | setPowerMode (PowerState newState) |
Set device power mode. | |
bool | kickIdle () |
Deferring idle mode. | |
int | getIdleDuration () |
Get idle period duration. | |
void | ledEnable (bool red, bool green) |
Enable LED outputs. | |
void | keybSetBackLight (unsigned char level) |
Set keypad backlight brightness. | |
void | keybFadeBackLight (unsigned char level) |
Fade keypad backlight brightness. | |
bool | oledEnable (bool flag) |
Enable display. | |
bool | oledSetBrightness (unsigned char level) |
Set display brightness. | |
bool | oledFadeBrightness (unsigned char level) |
Fade display brightness. | |
bool | oledFreeze (bool flag) |
Freeze display. | |
void | oledSetMaxBrightness (int maxLevel) |
Set maximum display brightness. | |
void | buzzerPlay (int freq, int duration) |
Sound buzzer. | |
bool | gprsPowerOn () |
Power on GPRS module. | |
bool | gprsPowerOff () |
Power off GPRS module. | |
void | gprsReset () |
Reset GPRS module. | |
bool | gprsGetPower () |
Get GPRS module state. | |
void | gprsSetDTR (bool active) |
Set DTR line of GPRS module. | |
void | mpciEnableRadio (bool enable) |
Enable radio interface of the communication module. | |
void | mpciEnable3V3 (bool enable) |
Enable communication module 3.3V power supply. | |
bool | scannerPowerUp () |
Power up barcode scanner. | |
bool | scannerPowerDown () |
Power down barcode scanner. | |
bool | scannerSetAim (bool flag) |
Set barcode scanner aiming. | |
bool | rtcGetAlarmState () |
Get RTC alarm status. | |
bool | rtcSetAlarm (int delay) |
Set RTC alarm. | |
bool | rtcEnableAlarm (bool flag) |
Enable RTC alarm. | |
bool | rtcSetTime (time_t now) |
Set RTC time. | |
bool | rtcGetTime (time_t *pNow) |
Get RTC time. | |
int | getBatteryCapacity (int *pVoltage=NULL) |
Get battery capacity and voltage. | |
int | getBatteryVoltage () |
Get battery voltage. | |
int | getTempReading () |
Read temperature. | |
int | getAmbientLight () |
Get ambient light intensity. | |
PowerState | getCurrentState () |
Get current power state. | |
bool | isUsbConnected () |
Get USB VBus pin state. | |
void | setPowerSaveSleep (int sec) |
Set power saving sleep duration. | |
Static Public Member Functions | |
static bool | initPowerManager () |
Initialize power manager. | |
static bool | deinitPowerManager () |
Release power manager. | |
static PowerManager * | getPowerManager () |
Retrieve power manager. | |
static int | kickIdleProc () |
Deferring idle mode. | |
Protected Member Functions | |
PowerManager () | |
Class constructor. | |
bool | initialize () |
Initialization routine The actual routine to perform power manager initialization:
| |
bool | deinitialize () |
Uninitialization routine The actual routine to perform device uninitialization. Closes speaker device, power driver and RTC driver handles. |
Power manager class.
Power manager implements a singleton class that takes care of basic power management functions of the mobile terminal. Power manager must be initialized at the beginning of the application life and uninitialized at the end. Power manager does not maintain any worker threads by itself. Instead, an external supervisor or monitor should initiate power state transitions.
PowerManager::~PowerManager | ( | ) | [virtual] |
Class destructor.
Destroys the power manager object.
PowerManager::PowerManager | ( | ) | [protected] |
Class constructor.
Presets power manager attributes. Maximum screen brightness is initially set to 255.
void PowerManager::buzzerPlay | ( | int | freq, | |
int | duration | |||
) |
Sound buzzer.
Generates a buzzer tone.
freq | Specifies buzzer tone frequency, in Hertz. | |
duration | Specifies tone duration, in milliseconds. |
bool PowerManager::deinitialize | ( | ) | [protected] |
Uninitialization routine The actual routine to perform device uninitialization. Closes speaker device, power driver and RTC driver handles.
bool PowerManager::deinitPowerManager | ( | ) | [static] |
Release power manager.
Uninitializes the power manager singleton object and deletes it. Must be called at the end of the application life.
void PowerManager::enableTransitions | ( | bool | flag | ) |
Enable power state switching.
Enables or disables power manager state switching.
flag | When set to false, setPowerState() method will not have any effect. When set to true, setPowerState() operates normally. |
int PowerManager::getAmbientLight | ( | ) |
Get ambient light intensity.
Reads integrated ambient light sensor data, combining both IR and visible light spectra.
int PowerManager::getBatteryCapacity | ( | int * | pVoltage = NULL |
) |
Get battery capacity and voltage.
Reads current battery capacity in percent. Alternatively, reads approximate battery voltage for post-processing. Note that averaging is applied for successive reads, to reduce voltage jitter and drift.
pVoltage | Pointer to integer that holds the approximated voltage level. If the parameter is not NULL, the voltage is stored in millivolts. |
int PowerManager::getBatteryVoltage | ( | ) |
Get battery voltage.
Reads current battery raw voltage for post-processing.
PowerState PowerManager::getCurrentState | ( | ) |
Get current power state.
int PowerManager::getIdleDuration | ( | ) |
Get idle period duration.
Calculates and returns the duration of idle state. The idle duration is calculated based on the last kickIdle() call instant.
PowerManager * PowerManager::getPowerManager | ( | ) | [static] |
Retrieve power manager.
Static function used to return a pointer to the one and the only power manager object.
int PowerManager::getTempReading | ( | ) |
Read temperature.
Reads internal temperature sensor.
bool PowerManager::gprsGetPower | ( | ) |
Get GPRS module state.
Reads current power state of the GPRS module on GSM-enabled data terminals.
bool PowerManager::gprsPowerOff | ( | ) |
Power off GPRS module.
Powers down the GPRS module on GSM-enabled data terminals. The GPRS module resulting state is sensed and reported back. Depending on network state, the call may take variable amount of time. If the module does not report a valid shutdown in 10 seconds, the module power supply is disconnected.
bool PowerManager::gprsPowerOn | ( | ) |
Power on GPRS module.
Powers up the GPRS module on GSM-enabled data terminals. The GPRS module resulting state is sensed and reported back.
void PowerManager::gprsReset | ( | ) |
Reset GPRS module.
Generates a reset pulse to restart the GPRS module on GSM-enable data terminals.
void PowerManager::gprsSetDTR | ( | bool | active | ) |
Set DTR line of GPRS module.
Enables or disables DTR signal on the GPRS module serial port interface. DTR signal is used to control operation of the GPRS module, for example its power saving mode.
active | Specifies the DTR line state. |
bool PowerManager::initialize | ( | ) | [protected] |
Initialization routine The actual routine to perform power manager initialization:
bool PowerManager::initPowerManager | ( | ) | [static] |
Initialize power manager.
Creates the power manager singleton object and initializes it. Must be called before any other power manager function.
bool PowerManager::isUsbConnected | ( | ) |
Get USB VBus pin state.
void PowerManager::keybFadeBackLight | ( | unsigned char | level | ) |
Fade keypad backlight brightness.
Fades the keypad backlight brightness to the desired level fluently.
level | Specifies the destination keypad backlight brightness (0..255). |
void PowerManager::keybSetBackLight | ( | unsigned char | level | ) |
Set keypad backlight brightness.
Sets the keypad backlight brightness to absolute level instantly.
level | Specifies the keypad backlight brightness (0..255). |
bool PowerManager::kickIdle | ( | ) |
Deferring idle mode.
Instructs power manager that the device is not idle at the moment. Power manager saves current timestamp that is further used for calculation of the idle duration.
int PowerManager::kickIdleProc | ( | ) | [static] |
Deferring idle mode.
Instructs power manager that the device is not idle at the moment. Power manager saves current timestamp that is further used for calculation of the idle duration. Calls the kickIdle() method.
void PowerManager::ledEnable | ( | bool | red, | |
bool | green | |||
) |
Enable LED outputs.
Enables or disables LED outputs of the data terminal. Note that the battery charger circuitry also drives LED outputs, which may interfere with software.
red | Enables red LED. | |
green | Enables green LED. |
void PowerManager::mpciEnable3V3 | ( | bool | enable | ) |
Enable communication module 3.3V power supply.
Enables or disables the 3.3V power supply to the data terminal communication module. Currently implemented on WLAN-enabled devices.
enable | Specifies if the power supply is to be enabled. |
void PowerManager::mpciEnableRadio | ( | bool | enable | ) |
Enable radio interface of the communication module.
Enables or disables the radio interface of the data terminal communication module. Currently implemented on WLAN-enabled devices.
enable | Specifies if the radio interface is to be enabled. |
bool PowerManager::oledEnable | ( | bool | flag | ) |
Enable display.
Enables or disables the display of the data terminal. When the display is disabled, it is placed to a low-power mode.
flag | Specifies if the display should be enabled. |
bool PowerManager::oledFadeBrightness | ( | unsigned char | level | ) |
Fade display brightness.
Fades the display brightness to the specified level fluently.
level | Specifies the destination display brightness (0..255). |
bool PowerManager::oledFreeze | ( | bool | flag | ) |
Freeze display.
Freezes the content of the display. May be used to avoid flickering, for example.
flag | Set to true to freeze the display. Set to false to unfreeze afterwards. |
bool PowerManager::oledSetBrightness | ( | unsigned char | level | ) |
Set display brightness.
Sets the display brightness to the absolute level instantly.
level | Specifies the display brightness (0..255). |
void PowerManager::oledSetMaxBrightness | ( | int | maxLevel | ) |
Set maximum display brightness.
Sets maximum display brightness. Does not have any effect immediately, as the value is used for calculation of display brightnesses for FULLY_OPERATIONAL and DISPLAY_DIMMED power modes.
maxLevel | Specifies maximum display brightness (0..255). |
bool PowerManager::rtcEnableAlarm | ( | bool | flag | ) |
Enable RTC alarm.
Enables or disables RTC alarm.
flag | Specifies if the RTC alarm is to be enabled. |
bool PowerManager::rtcGetAlarmState | ( | ) |
Get RTC alarm status.
Returns current RTC alarm status, as reported by kernel.
bool PowerManager::rtcGetTime | ( | time_t * | pNow | ) |
Get RTC time.
Reads current RTC time. The RTC must be running in order this call to succeed.
pNow | Points to the destination timestamp returned in Unix format. |
bool PowerManager::rtcSetAlarm | ( | int | delay | ) |
Set RTC alarm.
Initializes RTC alarm to trigger in a specified time interval. The alarm may be used to bring the device out of a power saving mode.
delay | Specifies the time interval after which the alarm is triggered, in seconds. |
bool PowerManager::rtcSetTime | ( | time_t | now | ) |
Set RTC time.
Initializes the integrated RTC implemented by means of the CPU Real-Time Timer. The RTC must be re-initialized every time the data terminal device loses power supply for a long period.
now | Contains the current timestamp in Unix format. |
bool PowerManager::scannerPowerDown | ( | ) |
Power down barcode scanner.
Powers down a barcode scanner device on data terminals that have 1D or 2D barcode scanner integrated into the sensor module.
bool PowerManager::scannerPowerUp | ( | ) |
Power up barcode scanner.
Powers up a barcode scanner device on data terminals that have 1D or 2D barcode scanner integrated into the sensor module.
bool PowerManager::scannerSetAim | ( | bool | flag | ) |
Set barcode scanner aiming.
Enables or disables aiming of a barcode scanner device on data terminals that have 1D or 2D barcode scanner integrated into the sensor module.
flag | Specifies if barcode scanner aiming is to be enabled. |
bool PowerManager::setPowerMode | ( | PowerState | newState | ) |
Set device power mode.
Sets current power state of the data terminal. Executes all operations required to enter the specified power state. All registered event listeners are called and queried for their readiness to proceed to the new power state.
The following states are supported: FULLY_OPERATIONAL, DISPLAY_DIMMED, DISPLAY_MINIMAL, DISPLAY_DISABLED, LOW_POWER_SLEEP, POWER_DOWN.
When LOW_POWER_SLEEP mode is specified, the system proceeds to a power saving mode where it runs on a slow clock and awaits for a GPIO or RTC alarm interrupt. In case of a GPIO interrupt (button press), the system proceeds to FULLY_OPERATIONAL state. In case of an RTC alarm interrupt, the system proceeds to a limited LOW_POWER_AWAKE state where it awaits further action.
newState | Specifies the new power state. |
void PowerManager::setPowerSaveSleep | ( | int | sec | ) |
Set power saving sleep duration.
Sets the time period that the data terminal spends in power saving mode, when entered. After the given period is elapsed, the device proceeds to a limited LOW_POWER_AWAKE state and awaits further action.
sec | Specifies the power saving sleep duration, in seconds. |