Re: LCD_Backlight
- From: "voidcoder" <voidcoder@xxxxxxxxx>
- Date: Tue, 25 Apr 2006 08:41:22 +0200
You really don't need to reset activity events manually.
Those events are rested by PM automatically, so don't
touch them in your touchscreen driver. Just run a single
thread in your backlight driver and put the code I posted.
Don't have any time to try it myself, but it should work.
DWORD dwBacklightTimeout = ReadTimeoutFromRegistry(...);
HANDLE hActivityTimer = OpenEvent("PowerManager/UaserActivity_Active");
HANDLE hInactivityTimer = OpenEvent("PowerManager/UaserActivity_Inactive");
while (TRUE)
{
// Wait to enter "user inactivity" state
WaitForSingleObject(hInactivityTimer, INFINITE);
// If still no activity for "dwBacklightTimeout" milliseconds
if (WaitForSingleObject(hActivityTimer, dwBacklightTimeout) ==
WAIT_TIMEOUT)
{
// Turn off the backlight
TurnBacklightOff();
// Keep it off until some user activity occurs
WaitForSingleObject(hActivityTimer, INFINITE);
// Restore backlight
TurnBacklightOn();
}
}
"Anurag" <Anurag@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:3389D1BA-6C97-4845-92B3-DB0C17D30FCF@xxxxxxxxxxxxxxxx
Hello voidcode please omit the last two lines and yes I doubt if it would
make a difference if i use system activity event instead of useractivity in
this case
"Anurag" wrote:
Hello voidcoder,
I am using the standard wince5.0 full power management.It is in the PM
module(in Public root)
it reads the name and timeout from the registry and is handling the same I
am acessing the same events in my backlight driver. Also the document on
"Activity timers" says that the PM module opens 3 events :
PowerManager/ActivityTimer/SystemActivity (Auto reset event)
PowerManager/SystemActivity_Active, and
PowerManager/SystemActivity_Inactive (both manual reset event)
The document also states
Any number of threads may open handles to the manual-reset
activity/inactivity events and wait on them to determine the status of the
OS. For example, a backlight driver may use the pair of manual-reset events
created for an activity timer to decide how to control backlight power and
intensity.
This is the reason why I am waiting on the two events. Now as per my
requirement when i touch the screen or on some other activity if i want the
back light to be ON I need to set this event ie tell the system that The
system is active and keep the backlight on for another period of time.I am
doing the same via SetEvent() which does not seem to set my activity event.
I went through your code and am unable to understand which of
this is a auto reset and which is a manual reset event. In manual reset i
need to manually reset the event(which i am trying to do in my backlight
driver). I fail to understand that if my thread is waiting for the active
event and i set it throught the touch why does'nt it reflect??
Now this is the reason why I have open handles to these events and am
waiting on them
"voidcoder" wrote:
I do not understand why do you need TWO thread to
wait on ativity timers. One is just enough, see my
example. Also not clear why do you need to reset
events in your touch driver? This is done automatically
as part of windows input handling.
Btw why do you need SystemActivity? Isn't the
!UserActivity! what are you looking for?
"Anurag" <Anurag@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:49CEEE5B-3009-4372-9DC2-32CD4D485BDE@xxxxxxxxxxxxxxxx
Hello voidcoder,
This are my registry settings:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\ActivityTimers\SystemActivity]
"Timeout"=dword:A
In my backlight driver Init function I create two events with thier names
the return value is the handle to the existing events:
if((SysAct_Active = CreateEvent(NULL, FALSE,
FALSE,_T("PowerManager/SystemActivity_Active")))!= NULL)
{
if(ERROR_ALREADY_EXISTS == GetLastError())
NKDbgPrintfW(TEXT(" ERROR_ALREADY_EXISTS 1\r\n"));
else
NKDbgPrintfW(TEXT(" Event created 1 %d \r\n"),SysAct_Active);
}
else
NKDbgPrintfW(TEXT("Event not created 1\r\n"));
if((SysAct_Inactive = CreateEvent(NULL, FALSE,
FALSE,_T("PowerManager/SystemActivity_Inactive"))) != NULL)
{
if(ERROR_ALREADY_EXISTS == GetLastError())
NKDbgPrintfW(TEXT(" ERROR_ALREADY_EXISTS 2\r\n"));
else
NKDbgPrintfW(TEXT(" Event created 2 %d\r\n"),SysAct_Inactive);
}
else
NKDbgPrintfW(TEXT("Event not created 2 %d\r\n"));
// i create two threads
hThread1 = CreateThread( NULL, 0, System_Active, 0, 0, NULL); // thread
created as active
hThread2 = CreateThread( NULL, 0, System_Inactive, 0, CREATE_SUSPENDED,
NULL);// thread
//created in suspended state
NKDbgPrintfW(TEXT(" Both Threads created\r\n"));
the two threads are as follows:
static ULONG
System_Active(
PVOID Reserved
)
{
WaitForSingleObject( SysAct_Active, INFINITE );
NKDbgPrintfW(TEXT(" out of WaitForSingleObject:SystemActivity_Active\r\n"));
Signal_BKL(1); //control back_light
if(ResetEvent(SysAct_Active))
NKDbgPrintfW(TEXT("ASA : SysAct_Active Event reset\r\n"));
else
NKDbgPrintfW(TEXT("ASA : SysAct_Active Event could not reset\r\n"));
ResumeThread(hThread2);
SuspendThread(hThread1);
return(TRUE);
}
static ULONG
System_Inactive(
PVOID Reserved
)
{
WaitForSingleObject( SysAct_Inactive, INFINITE );
NKDbgPrintfW(TEXT(" out of WaitForSingleObject:SystemInactivity_Active
\r\n"));
Signal_BKL(0); //control back_light
if(ResetEvent(SysAct_Inactive))
NKDbgPrintfW(TEXT("ASA : SysAct_Inactive Event reset\r\n"));
else
NKDbgPrintfW(TEXT("ASA : SysAct_Inactive Event could not reset\r\n"));
ResumeThread(hThread1);
SuspendThread(hThread2);
return(TRUE);
}
In the touch driver MDD main.c I first open the handle to the event
if((SysAct_Reset =
OpenEvent(EVENT_ALL_ACCESS,FALSE,_T("PowerManager/SystemActivity_Active")))!=
NULL)
{
if(ERROR_ALREADY_EXISTS == GetLastError())
NKDbgPrintfW(TEXT(" ERROR_ALREADY_EXISTS 3\r\n"));
else
NKDbgPrintfW(TEXT("Reset Event created again %d \r\n"),SysAct_Reset);
}
else
NKDbgPrintfW(TEXT("Event not created 1\r\n"));
then in the touch IST i try to set the event
if(SetEvent(SysAct_Reset))
NKDbgPrintfW(TEXT("ASA:Reset event set\r\n"));
else
NKDbgPrintfW(TEXT("ASA:Reset event NOT set\r\n"));
when i touch the screen it does not set the activity timer event and my
backlight does not switch on.
I would certainly appreciate your valuable help over this.
Thankyou
"voidcoder" wrote:
Ops, typo in my prev post:
DWORD dwBacklightTimeout = ReadTimeoutFromRegistry(...);
while (TRUE)
{
WaitForSingleObject(hInactivityTimer, INFINITE);
if (WaitForSingleObject(hActivityTimer, dwBacklightTimeout) ==
WAIT_TIMEOUT)
{
TurnBacklightOff();
WaitForSingleObject(hActivityTimer, INFINITE);
TurnBacklightOn();
}
}
"voidcoder" <voidcoder@xxxxxxxxx> wrote in message news:ewg0qm2ZGHA.1560@xxxxxxxxxxxxxxxxxxxxxxx
I'm not sure what are you doing there. Post you code.
Have not used activity timers this way, but it should
be possible to use something like this:
DWORD dwBacklightTimeout = ReadTimeoutFromRegistry(...);
while (TRUE)
{
WaitForSingleObject(hInactivityTimer, INFINITE);
if (WaitForSingleObject(hActivityTimer, dwBacklightTimeout) ==
WAIT_OBJECT_0)
{
TurnBacklightOff();
WaitForSingleObject(hActivityTimer, INFINITE);
TurnBacklightOn();
}
}
"Anurag" <Anurag@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4810CF02-46E0-435B-9E63-BC98D849FEF9@xxxxxxxxxxxxxxxx
Hello Voidcoder,
Thankyou for reply !!!!
Actually I am able to acess the events in my backlight driver ie it does set
the activity event("PowerManager/SystemActivity_Active") during boot then
after 10 sec(set in registry) it sets the inactivity event
("PowerManager/SystemActivity_Inactive") and I am able to acknowledge it in
my backlight driver. I am trying to set the activity event in my touch driver
so that every time i touch the screen the activity event is set and the the
activity timer count initializes. Now this does not happen!! I am setting the
event as follows:
if(SetEvent(SysAct_Reset))
NKDbgPrintfW(TEXT("ASA:Reset event set\r\n"));
Note: SysAct_Reset is the handle to
"PowerManager/ActivityTimer/SystemActivity" event
what happens is that once the inactivity event is set the light goes off and
does not resume back. I am resetting the manual reset inactivity event
("PowerManager/SystemActivity_Inactive") by reset event.
What could be the issue ??? In anticipation of your reply ASAP.
"voidcoder" wrote:
Actually activity timers are named as follow:
PowerManager/ActivityTimer/$Activity$
PowerManager/$Activity$_Active
PowerManager/$Activity$_Inactive
Eg.
"PowerManager/ActivityTimer/SystemActivity"
"PowerManager/SystemActivity_Active"
"PowerManager/SystemActivity_Inactive"
Use OpenEvent() to access events.
"Anurag" <Anurag@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A2F1D358-DE0B-4FC6-B084-D283DAADF6F2@xxxxxxxxxxxxxxxx
Hello Voidcoder,
Thankyou for your reply .
certainly setting the power states would be much better however for the
purpose of curiosity I tried adding that registry entry
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\ActivityTimers\SystemActivity]
"Timeout"=dword:A
and then created the events with the same names i.e, SystemActivity_Active
&
SystemActivity_Inactive in my driver however these events get created. Now
according to WinCE documentation (wince help topic Activitytimers) Upon
initialization, the Power Manager reads the registry to acquire a list of
activity timer names and creates the following events:
A timer reset event.
An active status manual-reset event.
A manual-reset event.
hence when i create the events with thier names Createevent() should
return
ERROR_ALREADY_EXISTS however this doesn't happen the events get created.
why is it so????
What needs to be done in this case??
"Voidcoder" wrote:
I would advice to not touch the system activity
timer directly. Better build a simple driver and
handle the power IOCTLs. You will need to
handle IOCTL_POWER_SET ioctl this way:
IOCTL_POWER_SET - D0 -> turn backlight on
IOCTL_POWER_SET - D1 -> turn backlight off
"Anurag" <Anurag@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ADEEAC32-2DCE-4ABF-B45C-E83EC1BE1D1F@xxxxxxxxxxxxxxxx
Hello everybody,
I am trying to develop a screen saver like facility for my WINCE Image
i.e,
after a predifined time of inactivity the LCD backlight should be OFF
and
on some activity like a touch on the touchscren the backlight should
get ON
I reffered the wince documentation "activity timer "and find that
activity
timers can be used i.e, set an activity timer
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\ActivityTimers\SystemActivity]
"Timeout"=dword:A
"WakeSources"=multi_sz:"0x20"
and the power manager handles the events.. Also the event can be
.
- References:
- Re: LCD_Backlight
- From: Voidcoder
- Re: LCD_Backlight
- From: voidcoder
- Re: LCD_Backlight
- From: Anurag
- Re: LCD_Backlight
- From: voidcoder
- Re: LCD_Backlight
- From: voidcoder
- Re: LCD_Backlight
- From: Anurag
- Re: LCD_Backlight
- From: voidcoder
- Re: LCD_Backlight
- From: Anurag
- Re: LCD_Backlight
- From: Anurag
- Re: LCD_Backlight
- Prev by Date: Re: USB/RNDIS
- Next by Date: Re: How to turn off LCD backlight after a predefined user inactivi
- Previous by thread: Re: LCD_Backlight
- Next by thread: print preview support in WinCE
- Index(es):
Relevant Pages
|
|