Jump to content

Turning off Display and Backlight?


Guest gaplayer26

Recommended Posts

Guest gaplayer26

I've managed to turn the backlight off / on - no problem, but I cannot turn the actual display itselft off.

Has anyone managed to do this? The example in Peter Foots blog does not work for the smartphone, only the iPAQ :D

   <DllImport("coredll")> _

Private Shared Function DevicePowerNotify( _

ByVal pvDevice As String, _

ByVal deviceState As PowerState, _

ByVal DeviceFlags As Integer)

    End Function


Private Enum PowerState

        PwrDeviceUnspecified = -1

        'full on

        D0 = 0

        'low power

        D1 = 1

        'standby

        D2 = 2

        'sleep

        D3 = 3

        'off

        D4 = 4

        PwrDeviceMaximum = 5

    End Enum


'---Force backlight off...

DevicePowerNotify("BKL1:", PowerState.D3, 1) '---D4 powers off the display AND the keypad which is no good

Any help appreciated! :D

Edited by gaplayer26
Link to comment
Share on other sites

  • 2 weeks later...
Guest dieter98

I think u only can use registry changings.

I used this example to set backlight to half power in an application.

the problem is, that on keypresses gets full power.

so I set the registry setting for backlicht time to 0.

But this only works , after a reset.

How I can tell driver for backlight that value changed programmatically ?

I founf this in C:

void SetBacklight(int value)

{

HKEY hKey = NULL;

DWORD dwDisposition = 0;

if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("ControlPanel\\Backlight"),0, NULL,

0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)

{

// Set backlight value for AC and Battery power

if (RegSetValueEx(hKey, _T("ACBrightNess"), 0, REG_DWORD, (PBYTE) &value,

sizeof(REG_DWORD)) == ERROR_SUCCESS)

{

if (RegSetValueEx(hKey, _T("BrightNess"), 0, REG_DWORD, (PBYTE)&value,

sizeof(REG_DWORD)) == ERROR_SUCCESS)

{

// Signal display driver to update

HANDLE hBackLightEvent = CreateEvent( NULL, FALSE, TRUE,

TEXT("BackLightChangeEvent"));

if (hBackLightEvent)

{

SetEvent(hBackLightEvent);

CloseHandle(hBackLightEvent);

}

}

}

}

}

But I need to use the Backlightchangeevent in VB.Net.

Changing registry values in VB.net is done.(with OpenNetCF)

But never worked with events before .

Tried a C to VB converter, but doesnt work.

anyone so kind to give me the complete code to use the backlightchangevent in VB.net ?

Edited by dieter98
Link to comment
Share on other sites

Guest gaplayer26
anyone so kind to give me the complete code to use the backlightchangevent in VB.net ?

<{POST_SNAPBACK}>

The code in my first post should do just what you want - Power off the dislplay backlight (you can choose halfbright, off etc by setting D value).

DevicePowerNotify("BKL1:", PowerState.D3, 1)
This will power off the dislpay light and keep it off, even if the user presses a key... To restore normal functionality (backllight comes on during keypress):
DevicePowerNotify("BKL1:", PowerState.PowerDeviceUnspecified, 1)

Link to comment
Share on other sites

Guest dieter98

Ok, but I mean something other.

The code works fine, I can set backlicht to half power an my SP3.

Problem is , that keypresses overide it , on keypresses backlight goes to full power for the defined time in settings.

So i changed the setting for backlight in registry to 0 programmatically.

But this has only effect after a reset, cause driver backlight has not got the changes.

Therefore is the backlightchangeevent.

U see it at the end of the code i posted.

But is C# , i tried to translate it to VB.Net, but failed.

Never worked with events before.

So I requested the full code in VB.net to raise theat event.

After this , keypresses have no effect to the settings from ur code.

// Signal display driver to update

HANDLE hBackLightEvent = CreateEvent( NULL, FALSE, TRUE,

TEXT("BackLightChangeEvent"));

if (hBackLightEvent)

{

SetEvent(hBackLightEvent);

CloseHandle(hBackLightEvent);

}

Edited by dieter98
Link to comment
Share on other sites

Guest gaplayer26
Problem is , that keypresses overide it , on keypresses backlight goes to full power for the defined time in settings.

hmm, strange. If I use:

DevicePowerNotify("BKL1:", PowerState.D3, 1)

The backlight stays off, even if the user presses a keypress... :cry:

I think we (at least I do!) need Uncle Pete's (Peter Foot) help :D

Edited by gaplayer26
Link to comment
Share on other sites

Guest dieter98

I used value 2 , so display goes to half brightness (Imate SP3),

but on keypresses to full power.

i also tried the exampele form OpenNETCF with

SetPowerRequirement("BKL1:", 2, 1, IntPtr.Zero, 0)

but is the same.

What SP do you use?

I think for my the only way is the Backlightchangeevent

to sent registry value to driver.

But failed in translate code from C to VBNet.

anyone can post the VB code to use this event ?

Link to comment
Share on other sites

Guest Alex_le_brit

Sorry to possibly hijack this thread, but would this type of code be useful for dimming the backlight when watching something on Pocket TV? I notice if I'm watching in the dark that the standard backlight setting is too bright for dark scenes, and no amount of adjusting the picture brightness or contrast helps this. If I could set the backlight to lower power it would be much improved.

I'm on an SPV Classic, which I notice already has two backlight settings, full power and then a dimmed setting which comes on about a second before the backlight auto powers off.

Link to comment
Share on other sites

Guest gaplayer26
Sorry to possibly hijack this thread, but would this type of code be useful for dimming the backlight when watching something on Pocket TV? I notice if I'm watching in the dark that the standard backlight setting is too bright for dark scenes, and no amount of adjusting the picture brightness or contrast helps this. If I could set the backlight to lower power it would be much improved.

I'm on an SPV Classic, which I notice already has two backlight settings, full power and then a dimmed setting which comes on about a second before the backlight auto powers off.

<{POST_SNAPBACK}>

Should do, worth a try...

Link to comment
Share on other sites

Guest dieter98

Dim hevent As IntPtr = OpenNETCF.Win32.Core.CreateEvent(False, False, "BackLightChangeEvent")

If (Not IsNothing(hevent)) Then

OpenNETCF.Win32.Core.SetEvent(hevent)

OpenNETCF.Win32.Core.ResetEvent(hevent)

End If

now I can set backlight on SP on half, keypresses dont override it, and ending my apps BacklightTimeout is reset to old behavior.

But if another app ( camera etc,) request full backlight it is full so lang app is in foreground.

Link to comment
Share on other sites

Guest gaplayer26
Dim hevent As IntPtr = OpenNETCF.Win32.Core.CreateEvent(False, False, "BackLightChangeEvent")

        If (Not IsNothing(hevent)) Then

            OpenNETCF.Win32.Core.SetEvent(hevent)

            OpenNETCF.Win32.Core.ResetEvent(hevent)

        End If

now I can set backlight on SP on half, keypresses dont override it, and ending my apps BacklightTimeout is reset to old behavior.

But if another app ( camera etc,) request full backlight it is full so lang app is in foreground.

<{POST_SNAPBACK}>

Is that the entire code?

Link to comment
Share on other sites

Guest dieter98

No , that is to fire the backlightchangeevent.

I do so:

read registry vallue current user\controlpanel\backlight\batterietimeout

write 0 in this place

use ur posted code to set backlight to half

my code above for backlight changeevent

to stop all :

write old backlightvalue back

backlightchangeevent

to normal settings from ur code

must use OpenNetCF

tried a lot of use event with normal VB.Net, but all failed, oenNet works

so my code looks a little confused at moment, for that many tries I made

Link to comment
Share on other sites

Guest gaplayer26
gaplayer26 if you succeed to do the trick with the SPV C500 can you write an How to do step by step ?

Thx in advance

sorry for my pidgin english.

<{POST_SNAPBACK}>

Thanks, but dieter98 appears to be the one with the solution! :D If I do succeed I will post the source :D

Try this, OpenNetCF must be installed.

( It based on Torchlite.exe)

<{POST_SNAPBACK}>

Can you post the source to this?

Thanks

:P

Link to comment
Share on other sites

Guest gaplayer26

Yes please, if you could post some source code, that'd be great - I'm getting very close to inflicting bodily harm to myself... :|

Edited by gaplayer26
Link to comment
Share on other sites

Guest Marko31

Thx for your reply ! :D

well i can't get Backlight.exe to work with my SPV C500, you say that you have to install opencf.net, but how to ?

I have download SmartDeviceFramework12 here at http://www.opennetcf.org/CategoryView.aspx?category=Home

But i can get it to works with my windows sp2, it says Microsoft visual studio.net 2003 with the compact framework is required ...

Anyway thx dieter98 and gaplayer26 for the aswers !

Link to comment
Share on other sites

Guest gaplayer26
I tried to build a cab for this all, but got error:

Cabwiz.exe  could not be invoked

Whats wrong ??

<{POST_SNAPBACK}>

You need to use CabwizSP for smartphone builds. It's part of the WM2003 SDK.

I use it like this from a batch file/command line:

"C:\Program Files\Windows CE Tools\wce420\SMARTPHONE 2003\Tools\cabwizsp.exe" "D:\Data\My Documents\Visual Studio Projects\****PROGRAM HERE***\obj\Debug\***PROGRAM INF HERE***.inf" /dest "D:\Data\My Documents\Visual Studio Projects\****PROGRAM HERE***\obj\Debug" /err CabWiz.SMP.log /cpu ARMV4

Link to comment
Share on other sites

Guest dieter98

Found this out also, but in batch file there isd a complete different path for cabwiz.

How to tell VSNet the right path, didnt found out it.

To lazy to type in batch.

Hey, but now a can copy and past from ur post!

But there is also the new pass to set in the inf file at several places.

But how to set the right path in VS , so that i must not do all that changes in the bat and inf file ?

Edited by dieter98
Link to comment
Share on other sites

Guest dieter98
Thx for your reply ! :D

well i can't get Backlight.exe to work with my SPV C500, you say that you have to install opencf.net, but how to ?

I have download SmartDeviceFramework12 here at http://www.opennetcf.org/CategoryView.aspx?category=Home

But i can get it to works with my windows sp2, it says Microsoft visual studio.net 2003 with the compact framework is required ...

Anyway thx dieter98 and gaplayer26 for the aswers !

<{POST_SNAPBACK}>

here is a simple verion without opnnet, plz try it.

BackLite.exe

Link to comment
Share on other sites

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.