Jump to content


Photo

Turning off Display and Backlight?

- - - - -

  • Please log in to reply
36 replies to this topic

#1
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex
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, 16 January 2005 - 05:07 PM.

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#2
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
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, 24 January 2005 - 07:33 AM.

  • 0

#3
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex

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)

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#4
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
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, 25 January 2005 - 06:25 AM.

  • 0

#5
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex

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, 25 January 2005 - 08:14 AM.

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#6
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
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 ?

  • 0

#7
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex

What SP do you use?

<{POST_SNAPBACK}>


I'm using the SPV C500...

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#8
Alex_le_brit

Alex_le_brit

    Diehard

  • Members
  • PipPipPipPip
  • 365 posts
  • Devices:SPV, SPV E200, HTC Universal
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.

  • 0

Posted Image


#9
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex

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...

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#10
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
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.

  • 0

#11
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex

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?

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#12
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
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

  • 0

#13
Marko31

Marko31

    Newbie

  • Members
  • Pip
  • 47 posts
  • Location:Dreamland
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.

  • 0
"I have no special talents. I am only passionately curious." Albert Einstein

#14
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
Try this, OpenNetCF must be installed.

( It based on Torchlite.exe)

Attached Files


  • 0

#15
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex

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

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#16
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex
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, 29 January 2005 - 02:18 AM.

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#17
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
deleted

Edited by dieter98, 29 January 2005 - 08:40 AM.

  • 0

#18
dieter98

dieter98

    Newbie

  • Members
  • Pip
  • 33 posts
Here is the code I played around with.
Maybee it looks a little bit confused, but was only for testing and I took the relevant things from it in another app.

Try to improve it or not.

Attached Files


  • 0

#19
gaplayer26

gaplayer26

    Regular

  • Members
  • PipPip
  • 102 posts
  • Location:UK, Essex
OK, thanks for the code! :D

  • 0
Garth

----------------------------------------------------------------------------------------------------
BTAutoSync WM5.0 [Bluetooth AutoSync] for Windows Mobile 5.0! - Schedule automatic AcitiveSync over Bluetooth

www.psychoman.co.uk

----------------------------------------------------------------------------------------------------

#20
Marko31

Marko31

    Newbie

  • Members
  • Pip
  • 47 posts
  • Location:Dreamland
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...x?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 !

  • 0
"I have no special talents. I am only passionately curious." Albert Einstein




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users