Log in or register to post comments

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 9, 2015 - 6:57pm #1

Vuforia SDK Version: 4.0.103 -

Description with steps to reproduce:

Hi.

 

Try as I might I can't get the Screen.sleepTImeout to change to SleepTimeout.SystemSetting.

 

I've tried calling both ResetSleepMode and setting the sleepTimeout manually every frame but it is never staying set. 

 

        if (Screen.sleepTimeout != SleepTimeout.SystemSetting) {
            Debug.Log ("Reset sleep mode from update ");
            QCARRuntimeUtilities.ResetSleepMode ();
            Screen.sleepTimeout = SleepTimeout.SystemSetting;
        }

 

Battery usage is a genuine concern for my project so not being able to AT LEAST dim the screen is annoying to say the least.

There has been another thread on this topic but appeared not to have a resolution. So from that thread,

 

Yes, Vuforia forces this setting on startup, although afaik, this is not new in 2.8.
 
However, you can re-set this setting in the OnInitialized callback of the ITrackerEventHandler interface (you just need to implement a script implementing such interface and attch it to the ARCamera). We even expose Utility functions to do that:
QCARRuntimeUtilities.DisableSleepMode()
QCARRuntimeUtilities.ResetSleepMode()

I tried the advice in this thread to no avail. 

 

Any help would be greatly appreciated.

Scott

 

-

Development OS (Mac OS X, Windows, Linux): OSX -

Mobile OS and Version: 8.2 -

Mobile Device Manufacturer and Model name: iPad Air 2 -

Do the Vuforia Sample Applications show the same behavior?:

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 15, 2015 - 6:56am #11

Would the screen NOT dim because I'm connected to the debugger I wonder (out loud)?

 yes, you typically need to disconnect the device from the USB port to ensure normal screen dim.

(although you may want to check on the Apple / iOS website to obtain more accurate info on specific "screen dim modes" with device connected to USB, as this specific topic is out of the Vuforia scope).

 

 

Can the screen dim and NOT auto-lock.

As far as I can tell, the default behaviour of most iOS devices is to auto-lock some time (e.g. 20 seconds or so) after the initial screen dim; however, there may exist special options to enable different behaviours such as "screen dim without auto-lock". Again, having a look at some Apple / iOS specialized website might give you some extra hints on the subject.

 

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 13, 2015 - 5:18pm #10

hi again, so for slow reply. Hectic times.

 

Without trying your code I've found that the power dimming does in fact work, athough when connected to the debugger the power setting (value) apparently wasn't changing. Would the screen NOT dim because I'm connected to the debugger I wonder (out loud)?

 

For thesmoment I have had to scrap screen dimming as the screen also auto-locks, and we may need to block access to the HOME button.  Can the screen dim and NOT auto-lock.  Desired behaviour would be that the screen dims to half or off and comes back on when the screen is tapped.

 

Thanks for for help. I will still try out your code when I can.

 

Scott

 

 

 

 

 

 

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 5:30am #9

I've just tried this (attached to the ARCamera):

public class SleepControl : MonoBehaviour {

    // Use this for initialization
    void Start () {
        QCARBehaviour qcar = (QCARBehaviour)FindObjectOfType( typeof(QCARBehaviour) );
        qcar.RegisterQCARStartedCallback( OnQCARStarted );
    }

    private void OnQCARStarted() {
        Debug.Log ("Screen timeout before reset: " + Screen.sleepTimeout);

        QCARRuntimeUtilities.ResetSleepMode();

        Debug.Log ("New screen timeout " + Screen.sleepTimeout);
    }
}

and this seems to work for me; it prints the message "New screen timeout 120" and then it dims the screen after 120 seconds.

could you try the same?

 

 

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 5:05am #8

My auto-lock was set to 2 mins.

 

 

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 4:47am #7

That should not matter; in fact, it is OK to attach the script to the ARCamera; as long as you use the QCARStarted callback as per previous posts;

Have you also checked your device settings ?

On iOS devices, this is controlled in:

Settings >General >Auto-Lock

and you can typically set the time to 1, 2, 3, 4, or 5 Minutes or "Never";   if it is set to Never, it will not dim the screen

 

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 3:56am #6

The script in question is attached to the ARCamera btw.....so that could possibly have some order-of-initialisation issues??

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 3:54am #5

Thanks again but still not working for me at least.

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 3:31am #4

Back to my previous message:

you can try

qcar.RegisterQCARStartedCallback(  OnQCARStarted );

which triggers the callback when QCAR has "started" (and not just "initialized").

 

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 2:26am #3

Thanks for your reply.  Yes I tried the OnInitialized callback.

QCARRuntimeUtilities.ResetSleepMode()m not working?

April 10, 2015 - 1:22am #2

Hi,

the old thread you refer to, suggests that you should call ResetSleepMode() in the ITrackerEventHandler OnInitialized callback;

Vuforia 4.0.103 however introduces a new callback mechanism, whereby you can register an initialization and a QCAR started callback, like in the following example:

void Start()
{

    QCARBehaviour qcar = (QCARBehaviour) FindObjectOfType ( typeof (QCARBehaviour) );

    qcar.RegisterQCARStartedCallback(  OnQCARStarted );
}

private void OnQCARStarted()
{
    // call resetSleepMode here ...

}

 

Have you tried that ?

Log in or register to post comments