Jump to content

Keep the backlight on :D


Recommended Posts

Posted

Hi all

A HUGE thanks to my contact at O for his help with this :P

This is one that people should find useful (I know I will).

(note : only appears to work on the SPV, E100 & E200 Smartphones - not the others)

As most of you will know, whilst an app is running if you don't press a key for a while the backlight timer kicks in and the screen dims, eventually dimming to off - or alternately the Home Page timeout kicks in and the phone returns to the home page.

If you want to keep the backlight completely on in an app AND stop the timeout to the homescreen altogether (very useful for games),

first include these 2 headers:-

#include "windows.h"

#include "tpcshell.h"[/code] then create a global variable :-
[code]DWORD lastTimerReset;
and then in your main app/game loop add this code :-
// every 9 seconds 

if(GetTickCount() - lastTimerReset> 9000)

{

// this keeps the backlight on, but only on spv, e100, e200

#define   EVENT_DISPLAYOFF TEXT("TIMEOUTDISPLAYOFF")



HANDLE g_hDispEvent = CreateEvent(NULL, FALSE, FALSE, EVENT_DISPLAYOFF);

SetEvent(g_hDispEvent); //LCD frontlight on



::SHIdleTimerReset();

lastTimerReset = GetTickCount();

}[/code]

Basically every 9 seconds the code is run to stop the timers kicking in - why 9 seconds? I hear you cry. Well the lowest standard setting on backlight or home page timers is 10 seconds, so resetting them every 9 will do :)

happy coding,

muff

  • 2 weeks later...
Guest neilarmstrong
Posted

Anyone know a solution that works on the C500 (Smartphone OS 2003 SE)?

I've been trying to use both:

SystemIdleTimerReset

SHIdleTimerReset

...but they don't work. They stop the home screen from kicking in...but they don't stop the backlight from dimming. Unfortunately a bug in GAPI causes games to freeze when the backlight dims :)

Posted

I'll be posting up a C500 version soon now, I'm just working on some other stuff, and then I'll be fully testing then C500 fix before a post

Posted

as promised, C500 code

header include at the top

#include "pm.h"
at the start of the winmain function
HANDLE hPower;  

hPower = SetPowerRequirement(TEXT("BKL1:"), D0, POWER_NAME, NULL, 0);[/code] and on the way out of the winmain function (so it's called as the app closes)
[code]ReleasePowerRequirement(hPower);

and that's about it really

I personally use it in conjunction with the previous code so that the backlight stays on, and neither 2k2 or 2k3 drop out to homescreens

of course the 2k3 code is partitioned to only be included in the 2k3 build - the PowerRequirement functions are only usable on 2k3 systems

one thing you should be aware of with using this code, is that if the app/game loses focus for any reason (incoming call for example) , the backlight will remain on until you close that app/game

I've tried doing the release and then restating it when losing / gaining focus, but that didn't appear to work for me

happy coding

muff

Guest neilarmstrong
Posted

I can confirm that the code posted by Muff works on C500!! Fantastic!

I'd tried it before Muff posted his solution but stupidly I forgot to put the TEXT macro around the "BKL1:". D'oh!!!

One thing I would suggest is for people who want to write code that works on both SP 2002 and SP 2003....use GetProcAddress instead of #include

// Copied from pm.h


typedef enum _CEDEVICE_POWER_STATE {


    PwrDeviceUnspecified = -1,


    D0 = 0, // Full On: full power,  full functionality


    D1,     // Low Power On: fully functional at low power/performance


    D2,     // Standby: partially powered with automatic wake


    D3,     // Sleep: partially powered with device initiated wake


    D4,     // Off: unpowered


    PwrDeviceMaximum


} CEDEVICE_POWER_STATE, *PCEDEVICE_POWER_STATE;




#define POWER_NAME (DWORD)(0x00000001)


#define POWER_FORCE (DWORD)(0x00001000)




typedef DWORD (*RELEASEPOWERREQUIREMENT)( 


   HANDLE hPowerReq );


typedef HANDLE (*SETPOWERREQUIREMENT)(


   PVOID pvDevice,


   CEDEVICE_POWER_STATE DeviceState,	


   ULONG DeviceFlags,


   PVOID pvSystemState,


   ULONG StateFlags );
At application startup...
HANDLE HdlPower = NULL;


HINSTANCE HdlCoreDll = LoadLibrary( TEXT("coredll.dll") );


if ( HdlCoreDll )


{


   SETPOWERREQUIREMENT PtrFunc = (SETPOWERREQUIREMENT)GetProcAddress( HdlCoreDll, TEXT("SetPowerRequirement") );


   if ( PtrFunc )


   {  


      HdlPower = (*PtrFunc)(TEXT("BKL1:"), D0, POWER_NAME, NULL, 0);


   }


   FreeLibrary( HdlCoreDll );


}
At application shutdown...
HINSTANCE HdlCoreDll = LoadLibrary( TEXT("coredll.dll") );


if ( HdlCoreDll )


{


   RELEASEPOWERREQUIREMENT PtrFunc = (RELEASEPOWERREQUIREMENT)GetProcAddress( HdlCoreDll, TEXT("ReleasePowerRequirement") );


   if ( PtrFunc )


   {  


      (*PtrFunc)( HdlPower );


   }


   FreeLibrary( HdlCoreDll );


}

Guest neilarmstrong
Posted

Does anyone know how to stop backlight dimming on PocketPC 2002?

I presume the SetPowerRequirement will work on PocketPC 2003....however, I haven't yet tested it.

Posted
Does anyone know how to stop backlight dimming on PocketPC 2002?

I presume the SetPowerRequirement will work on PocketPC 2003....however, I haven't yet tested it.

yup this does indeed work on the PPC :lol: (well it does on the m1000 anyway)

dont think it stops the actual power off timer of the device, but that's probably not too bad a thing, can't imagine just leaving something running in battery mode anyway

thanks for your variation on the c500 code above as well - now you can compile for 2k2 and still get the benefit of the power work around on 2k3 phones

2k2 compiled code tends to run slightly faster than a 2k3 compile of the code for some reason - so the fact that we can have 2k2 compile with the backlight code workaround is great news :lol:

(also nice to see someone else sharing code :))

  • 2 weeks later...
Guest Paul [MVP]
Posted

ReleasePowerRequirement doesn't seem to work for me on the C500...

P

Posted
"]ReleasePowerRequirement doesn't seem to work for me on the C500...

P

yeah, not really convinced that the command works properly on the C500

certainly in testing minimising an app, with a ReleasePowerRequirement on the WM_KILLFOCUS didn't appear to do anything :/

maybe this is to do with the way the C500 handles it's power functions?

  • 4 weeks later...
Guest 0Namal0
Posted

Any update on that issue on c500 ???

I have implemented the first part (SPV 1G) with success, thx muff, but I am awaiting a new device ^_^ and would like to find a way on c500 ..

thanks guys,

Phil.

Posted
Any update on that issue on c500 ???

I have implemented the first part (SPV 1G) with success, thx muff, but I am awaiting a new device ^_^ and would like to find a way on c500 ..

thanks guys,

Phil.

erm, the c500 code is also above :D

Guest 0Namal0
Posted

Hi Muff,

Sorry if I misunderstood the posts (being french, that helps ^_^), but I thought Paul and yourself were saying the code you posted for C500 didn't actually work ...

Anyway I'll try it myself, better than wasting others' time ...

Thanks a bunch,

Phil

Guest AllanHvass
Posted

Not being a developer myself, does anyone have an actual app containing the code that they can post? It would be great to use when driving in car to keep the backlight on.

It doesn't have to have any user interface, just run it, at it keeps backlight on. And if possible, some mechanism for terminating the app as well, without using a task manager.

THANKS A GAZILLION!!!

Allan Hvass

Posted

I have an application that I have put in the startup folder and it changes the backlight timeout to never when the SPV is charging, however when you disconnect the charging it goes back to the original setting.

There is no credits on the app and I do not remember where I got it from.

Hope it helps.

AutoBackLight.CAB

Guest rikwebb
Posted

mmmmm,

Wonder if you could use the code above as a wrapper for your apps??

call your wrapper - this calls the app you want to run, and when you quit it - runs the final part to turn it off again

I will see if I get some time to have a play..

Rik

Guest AllanHvass
Posted

To Gazzaw: Yeah, I've already tried that app (and several others, incl. the Orneta ones), and they work as advertise, i.e. they DO change the backlight timeout setting to Never while running, problem is, that on models prior to the SPVe200, the phone simply doesn't respect that, it turns off backlight still (sometimes it works correctly when using a charger, but not consistently, and never when running off battery or in a car kit).

Since several in this thread have tested the code, they must have some kind of prototype, that could easily be adjusted to a selfcontained app.

The wrapper thing that rikwebb suggests would be ideal for the application I have in mind (Mapopolis), since that's exactly what I want to achieve. A wrapper where you could parameterize (even just through a registry setting) the app to call would make it very generic. Except if you just want your phone to stay lit e.g. while in a car kit, withour running any particular app.

I would be hugely thankful for such an app. Bow in the dust, etc. - you get the picture :wink:

  • 1 month later...
Posted

I've no idea how but my backlight has decided to stay permanently on. I've not input any codes or anything, how do I turn it off?

  • 1 month later...
Posted

if i sound simple all appologise, but im new to this. only had my C500 3 weeks. so where exactly do you put this code in the phone and what do you write it in to be able to put it in the phone?

hawko [-o<

  • 4 weeks later...
  • 11 months later...
Guest bitbank
Posted

I've found a way to keep the backlight on and the machine from sleeping which seems to work on all versions of Windows desktop and mobile.

Every 9 seconds (as suggested above), do the following:

keybd_event(VK_F24, 0, KEYEVENTF_KEYUP, 0);

This creates a "virtual" keypress (actually a key release) of a non-existant key and fools the system into thinking that the user is doing it.

Seems to work fine on all devices I've tested.

Larry B.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.