Windows Mobile background light control

Source: Internet
Author: User

General introduction:In Windows Mobile, an API is provided to control background lights. This API enables you to turn on background lights, turn off background lights, and Flash the screen.

Development language:Use the C # language and implement it in the. NET Compact Framework framework.

Applicable scenarios:1. When the system runs for a long time, in order to save the battery of hardware, you can turn off the background light and the software can run in the background. In the 2..net Compact framework, if WebService is used for data interaction, Beijing Light will automatically turn on each WebService call. To avoid this problem, you can turn off the background light before performing data interaction, and turn on the background light after the interaction ends. This is especially suitable for the push technology through thread round robin.

Implementation:

1. encapsulate the devicepowernotify method in the API,CodeAs follows:

[Dllimport ("coredll. dll")]
Private Static extern int devicepowernotify (string device, powerstate devicestate, int deviceflags );

2. encapsulate the powerstate enumeration object

Public Enum powerstate
{
Pwrdeviceunspecified =-1,
Fullon = 0, // full on
Lowon = 1, // low on
Standby = 2, // standby
Sleep = 3, // sleep
Off = 4, // off
Pwrdevicemaximum = 5
};

3. encapsulate an external interface

Public static void setbacklight (powerstate PWR)
{
Devicepowernotify ("bkl1:", PWR, 1 );
}

OK, so far, it has basically been completed. The following describes a method for testing. The effect of the method is that the device based on Windows Mobile flashes the screen.

Int COUNT = 5; // only 5 flashes

While (count> 0)
{
Setbacklight (powerstate. Off );
Thread. Sleep (500 );
Setbacklight (powerstate. Fullon );
Thread. Sleep (500 );
Application. doevents ();
Count --;
}

Have you seen the results? The above code has been tested.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.