Screen Saver

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
BKirch
Posts: 4
Joined: Tue Jul 09, 2013 6:25 am

Screen Saver

Post by BKirch »

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.

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

Re: Screen Saver

Post by mark.monroe »

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

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

Re: Screen Saver

Post by entronic »

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

AMitchneck
Posts: 137
Joined: Mon Jun 11, 2012 2:10 pm

Re: Screen Saver

Post by AMitchneck »

Hi,

I've never tried this, but take a look at: https://stackoverflow.com/questions/103 ... ith-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: Select all

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: Select all

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

Post Reply