diff -r 578be2adaf3e -r 307f4279f433 Adaptation/GUID-65CDCA83-C726-5173-8E46-B8981D1D7B02.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adaptation/GUID-65CDCA83-C726-5173-8E46-B8981D1D7B02.dita Fri Oct 15 14:32:18 2010 +0100 @@ -0,0 +1,62 @@ + + + + + +Battery +Monitor Implementation TutorialA base port can implement code to monitor the battery of the phone +and to provide notifications when the battery power is low. +

The battery monitor code is implemented in the power controller kernel +extension.

+

Note: to implement battery monitor code, the battery monitor hardware must +be accessible to the Application CPU of the phone.

+

Typically, your battery monitor class would derive from the DBatteryMonitor class, +defined as:

+class DBatteryMonitor + { +public: + IMPORT_C DBatteryMonitor(); + IMPORT_C void Register(); +public: + virtual TSupplyStatus MachinePowerStatus() = 0; + virtual void SystemTimeChanged(TInt anOldTime, TInt aNewTime) = 0; + }; +

Symbian platform considers that batteries can be in one of 4 possible logical +states, defined by the TSupplyStatus enum. It is up to the +implementor of the battery monitor component to map these logical states to +points on the main battery discharge curve.

+

There are two pure virtual functions to be implemented:

+ +

We also suggest that the battery monitor component offer a public function +prototyped as:

+void SupplyInfo(TSupplyInfoV1& si); +

to supply information about the state of the main battery and the backup +battery (if there is one), or external power to user side components that +may require it (e.g. a user-side power monitor component that is used to track +the state of batteries and initiate an orderly shutdown if it reaches a critically +low level), and is usually called by the EHalGroupPower handler +for EPowerHalSupplyInfo in response to calling HAL::Get() with EPowerGood, EPowerBatteryStatus, EPowerBackupStatus, and EPowerExternal. +Such a function would need to fill in a subset of the fields defined by TSupplyInfoV1.

+
DBatteryMonitor::MachinePowerStatus() virtual TSupplyStatus MachinePowerStatus() = 0;

This +should read and return the logical state of the main battery or, if external +power is connected, it should return EGood.

When +is it called?

The function is called by peripheral drivers via +a call to Kern::MachinePowerStatus() before starting lengthy +operations or operations that may result in a substantial increase in power +consumption.

Implementation issues

A suggested implementation +would have the function reading the state of the main battery, or whether +external power is connected, and mapping to one of the logical states defined +by TSupplyStatus. When requested by the power manager it +returns the logical state.

+
DBatteryMonitor::SystemTimeChanged() virtual void SystemTimeChanged(TInt anOldTime, TInt aNewTime) = 0;

This +function is now deprecated, and you should just define an empty implementation.

+
\ No newline at end of file