Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Screen Saver
PostPosted: Mon Aug 05, 2013 8:48 am 

Joined: Tue Jul 09, 2013 6:25 am
Posts: 4

Offline
Hi,

I was wondering if it's possible to have a screen saver on a iX T10A screen. I know there's a setting that turns the backlight off after a certain number of seconds, but I was hoping there's a way to get a specific screen to show after the certain number of seconds. Thanks for the help.


 Profile  
 
 Post subject: Re: Screen Saver
PostPosted: Mon Aug 05, 2013 9:48 am 

Joined: Tue Mar 13, 2012 9:53 am
Posts: 824

Offline
You could use C# code in a timer and have the HMI change screens. However, I do not know of a way to track how long it was since a operator used the screen. You would have to do some research and see if there is some C# function you could call that would give you the last time the touchscreen was pressed. Touchscreen input is treated the same way as mouse input is.

_________________
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer


 Profile  
 
 Post subject: Re: Screen Saver
PostPosted: Thu Jul 06, 2017 9:09 am 

Joined: Fri Nov 29, 2013 8:29 am
Posts: 2

Offline
Hi,
Can you find a solution this problem?
thanks for the help.


 Profile  
 
 Post subject: Re: Screen Saver
PostPosted: Thu Jul 06, 2017 4:15 pm 

Joined: Mon Jun 11, 2012 2:10 pm
Posts: 96

Offline
Hi,

I've never tried this, but take a look at: https://stackoverflow.com/questions/1037595/c-sharp-detect-time-of-last-user-interaction-with-the-os
Note on windows CE user32.dll and kernel32.dll are replaced with coredll.dll.

So time since last user interaction would be:
Code:
using System;
using System.Runtime.InteropServices;

public class SystemIdleTime
{
    [DllImport("coredll.dll")]
    private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);       

    [DllImport("coredll.dll")]
    private static extern uint GetLastError();

    internal struct LASTINPUTINFO
    {
        public uint cbSize;
        public uint dwTime;
    }

    // Time (as Timespan) since the last user input
    public static TimeSpan GetIdleTimespan()
    {
        return TimeSpan.FromMilliseconds(GetIdleTime());
    }

    // Time (in milliseconds) since the last user input
    public static uint GetIdleTime()
    {
        return ((uint)Environment.TickCount - GetLastInputTime());
    }

    // Get the Last input time in milliseconds
    public static uint GetLastInputTime()
    {
        LASTINPUTINFO lastInPut = new LASTINPUTINFO();
        lastInPut.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut);
        if (!GetLastInputInfo(ref lastInPut))
        {
            throw new Exception(GetLastError().ToString());
        }       
        return lastInPut.dwTime;
    }
}


To use this you could setup a threading timer to run in the background.
Code:
public class IdleTimer
{
    private static System.Threading.Timer checkIdle = null;
    private static bool timerActive = false;

    public static void Start()
    {
        if (checkIdle == null)
        {
            checkIdle = new System.Threading.Timer(checkIdle_Tick, null, 1000, 1000); // call timer function every 1000 milliseconds
            timerActive = true;
        }
        else if (!timerActive)
        {
            checkIdle.Change(1000, 1000); // call timer function every 1000 milliseconds
            timerActive = true;
        }
    }
    public static void Stop()
    {
        if ((checkIdle != null) && timerActive)
        {
            checkIdle.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); // disable timer
            timerActive = false;
        }
    }

    private static void checkIdle_Tick(Object state)
    {
        // change screen if idle for 30 minutes
        if (SystemIdleTime.GetIdleTime() >= 1800000)
        {
            Stop();
            Globals.Screen1.Show();
        }
    }
}

In the Screen1 closing event you would add a call to IdleTimer.Start();
In the Screen1 open event you would add a call to IdleTimer.Stop();
If Screen1 is not your startup screen, then in your startup screen's open event you would also add IdleTimer.Start();

_________________
Adam M.
Controls Engineer
FlexEnergy


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: