Few years ago the function SystemIdleTimerReset() did this job. On our side we had to detect the device idle time and call this function appropriately. In Windows Mobile 6 this function keeps the system running, but the display is turned off.
How to keep the backlight on?
If you need to keep your device at full power, you can use the following code:
Do not forget to release handle when you close application:
SystemIdleTimerReset() should be used also - this function keeps the device running. If you will forget about it, the display will be on, but the device will go to sleep together with your application. It looks like your application gets stuck.
More details about this approach and a working example you can find in MSDN: Program Applications to Turn the Smartphone Backlight Off and On
Bruce Eitman proposed a new solution in his article Windows CE: Keeping the Backlight On
.
He found out that the power manager is monitoring a named event. The name of this event can be obtained from the registry:
If we have the name, we can create this event and raise it periodically.
In order to test this approach I made a simple class CPowerEvent:
And the implementation is the following:
My test application is a simple dialog-based MFC application. I added CPowerEven oject into the dialog class as a private member. On the dialog form I put 2 buttons: On and Off. The buttons' click handlers are trivial:
1. Button "On" calls method Start() from the CPowerEvent object.
2. Button "Off" calls method Stop().
I tested this approach with the power event on few Windows Mobile 6.1 devices. I found one device where this code didn't work. The approach described in the beginning of the article fails also. Probably, the device has a different power manager, as can be the case with OEM devices.
Like always, the simplest solution for this "Display On" ("Backlight On") problem can be found on the application level - the device is on all the time when the user type something on the keyboard. So, if I will periodically emulate the keyboard input the device will never "go to sleep".
The following code emulate the keyboard input that keeps the device on:
Few more important points about the subject of this article:
1. We need to remember that we are working with the mobile devices and the effective power management is a critical issue. The code represented here does not save the battery. It does not overload the CPU, but keeping the backlight on all the time is, definitely, against all Microsoft recommendations for power effective applications.
2. I assume that tomorrow I will see another device with Windows Mobile (or CE) 5 or 6 where all described techniques will not work. OEMs (device manufacturers) always build and tailor their own platforms for their devices. They adopt the operating system for their hardware. In many cases OEM's develop their own drivers based on the Microsoft samples. It is even not necessary to follow the Microsoft recommendations. So due to the customization an OEM may have done, the programs that use the registry information, OEM's keyboard codes, etc., as the examples in this article, may not work on a specific Windows CE/Mobile device.
by: mark_wills on 2009-07-30 at 21:34:15ID: 2440
@pgnatyuk:
Articles when first submittted are regarded as "unverified" in so much as none of the Editors have seen it yet.
As an article is worked on it should swap status between Editor Review and Author Review.
As aikimark has already pointed out, it really was a message for him. Sorry for any confusion.