Home › Forums › Software Development › Keep eyex on while screen is off
Tagged: turn off screen, user presence
- This topic has 7 replies, 3 voices, and was last updated 9 years, 10 months ago by Gal Sont.
- AuthorPosts
- 28/11/2014 at 13:07 #2124Gal SontParticipant
I have an eyex working with Microsoft surface pro 3. everything is working fine but when the tablet goes to sleep mode or when it doesn’t recognize the eyes it turns off and doesn’t turn back on until I turn the screen on.
While the screen is off the usb port has power, i verified with other devices.
How can I keep the camera and the emitters on?
Thank you.28/11/2014 at 17:54 #2125AndersParticipantHi Gal,
if the tablet goes to sleep the eye tracker should go to sleep as well. If you want to keep the tracker on, I think the best way would be to configure the tablet so that it never goes to sleep.But I didn’t quite get the part about not recognizing the eyes. Does the tracker shut down if there are no eyes in front of it?
28/11/2014 at 19:08 #2127Gal SontParticipantThank you for your prompt reply.
What I basically want is when the eyetracker doesn’t recognize eyes (move away from tablet, close your eyes, etc) i want to turn off the display and when the eyetracker recognizes eyes again, to turn the display back on.
All the code is working except the eyex turns itself off…
There are 10 seconds from the moment the screen shuts down till the Eyex shuts down as well. within these 10 seconds evertything works perfectly! ๐03/12/2014 at 07:06 #2137Gal SontParticipantHi,
Any thoughts regarding this?
Thanks.03/12/2014 at 08:46 #2138Robert [Tobii]ParticipantHi Gal,
Sorry for late reply. We have done some brief testing to see if this can be accomplished by using the GetThreadExecutionState function on an application level, but not come up with any working solution yet.
I read earlier that Microsoft arranged a hackathon where one of the teams helped Steve Gleason to be able to turn on/off his Surface tablet using his eyes. You probably read this too: http://blogs.microsoft.com/firehose/2014/07/31/oneweek-hackathon-outcome-as-individual-parts-we-were-good-together-we-were-so-much-better/
“For the eye-controlled Surface on/off feature, the team came up with a firmware edit to make it possible.”Even though Steve does not use exactly the same Tobii eye tracking solution as you, maybe this Microsoft team can share some knowledge about what they had to do to keep the eye tracker running even though the tablet is asleep. That would be in line with their new open strategy.
04/12/2014 at 06:07 #2143Gal SontParticipantThank you for your effort.
Hence starts the hunt to find the right person to speak to in Microsoft…04/12/2014 at 09:01 #2144Robert [Tobii]ParticipantI have asked in-house if anyone has the contact to the right person at Microsoft, so if we find the contact information we can send it to you. We have also checked how the EyeX Engine handles sleep mode/away mode. The default setting is to turn off the eye tracker to save battery, but there might be some changes that can be done there. Both those options will obviously take some time.
Meanwhile, it would be good to know exactly what code you use to turn off the screen. Does the tablet go into sleep mode, away more or something else? Moreover, would it be a short-term option for you to “fake” turning off/on the screen just by showing/hiding a black always-on-top window? We have used that method when prototyping this concept, to avoid the problems with sleep mode/away mode and get a swift response from the computer when entering in front of it.
05/12/2014 at 07:12 #2159Gal SontParticipantHi,
These changes would be most welcomed ๐
Thank you for your idea, this is currently what I do + reducing the brightness to minimum. This solution is 80% good as the screen is still quite bright in a dark room. I like perfection ๐In the meanwhile I reached the right person in Microsoft and will update here on any progress.
Here is the code for turning the screen on / off and setting brightness and gamma to minimum (brightness works only on tablets / laptops so use gamma for pc):
usage – TurnScreenOnOff(true);[DllImport("user32.dll")] private static extern int SendMessage(uint hWnd, int hMsg, int wParam, int lParam); private static byte originalBritness; private static RAMP originalGamma; private static int WM_SYSCOMMAND = 0x0112; private static int SC_MONITORPOWER = 0xF170; //Using the system pre-defined MSDN constants that can be used by the SendMessage() function . private static uint HWND_BROADCAST = 0xffff; public enum MonitorState { MonitorStateOn = -1, MonitorStateOff = 2, MonitorStateStandBy = 1 } [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hWnd); [DllImport("gdi32.dll")] public static extern bool SetDeviceGammaRamp(IntPtr hDC, ref RAMP lpRamp); [DllImport("gdi32.dll")] static extern bool GetDeviceGammaRamp(IntPtr hdc, ref RAMP lpRamp); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct RAMP { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public UInt16[] Red; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public UInt16[] Green; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public UInt16[] Blue; } public static void SetGamma(int gamma) { if (gamma <= 256 && gamma >= 1) { RAMP ramp = new RAMP(); ramp.Red = new ushort[256]; ramp.Green = new ushort[256]; ramp.Blue = new ushort[256]; for (int i = 1; i < 256; i++) { int iArrayValue = i * (gamma + 128); if (iArrayValue > 65535) iArrayValue = 65535; ramp.Red[i] = ramp.Blue[i] = ramp.Green[i] = (ushort)iArrayValue; } SetDeviceGammaRamp(GetDC(IntPtr.Zero), ref ramp); } } private static void SetBrightness(byte targetBrightness) { ManagementScope scope = new ManagementScope(@"root\WMI"); SelectQuery query = new SelectQuery("WmiMonitorBrightnessMethods"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); ManagementObjectCollection objects = searcher.Get(); foreach (ManagementObject obj2 in objects) { obj2.InvokeMethod("WmiSetBrightness", new object[] { uint.MaxValue, targetBrightness }); break; } objects.Dispose(); searcher.Dispose(); } private static byte GetBrightness() { ManagementScope scope = new ManagementScope(@"root\WMI"); SelectQuery query = new SelectQuery("WmiMonitorBrightness"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); ManagementObjectCollection objects = searcher.Get(); byte propertyValue = 0; foreach (ManagementObject obj2 in objects) { propertyValue = (byte)obj2.GetPropertyValue("CurrentBrightness"); break; } objects.Dispose(); searcher.Dispose(); return propertyValue; } public static void TurnScreenOnOff(bool turnOff) { if (turnOff) { //originalBritness = GetBrightness(); //GetDeviceGammaRamp(GetDC(IntPtr.Zero), ref originalGamma); //SetBrightness(0); //SetGamma(1); //blankBlackWindow.Show(); SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (int)MonitorState.MonitorStateStandBy); } else { //SetBrightness(originalBritness); //SetDeviceGammaRamp(GetDC(IntPtr.Zero), ref originalGamma); //blankBlackWindow.Close(); SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (int)MonitorState.MonitorStateOn); } }
- AuthorPosts
- You must be logged in to reply to this topic.