Announcement

Collapse
No announcement yet.

sys_sleep() problems

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • sys_sleep() problems

    Hello, currently i'm trying to make a 'standby' function, where my screen (gen4-uLCD-43DCT-CLB) will turn off after not detecting any touch input for X seconds.

    For this i've tried using disp_Disconnect(), but that doesn't turn the screen off for less power draw in the way i would have liked, so i tried sys_Sleep(units), mainly because of the description in the processors Internal Functions Reference
    If "units" is 1 to 65535, the display will sleep for that period of time, or will be woken when touch screen is touched.
    But the display doesn't wake up after having been touched, am i missing something?

    Another question, what exactly is the difference between sys_Sleep() and sys_DeepSleep()?, their descriptions in the reference document are more or less the same.


  • #2
    Hi, welcome to the forum.

    You can implement it as shown in the code below. Please read the comments to be guided.

    Sample Code
    Code:
    var sleepTime := 5000;     // time in milliseconds for the display to sleep if there is no touch event
    
    func main()
    
        putstr("Mounting...\n");
        if (!(file_Mount()))
            while(!(file_Mount()))
                putstr("Drive not mounted...");
                pause(200);
                gfx_Cls();
                pause(200);
            wend
        endif
        gfx_Cls();
        gfx_Set(SCREEN_MODE,LANDSCAPE) ;
        touch_Set(TOUCH_ENABLE);
    
        print("Display module running ...");
        sys_SetTimerEvent(TIMER0, sleep); // calls "sleep" func when TIMER0 goes to 0
        sys_SetTimer(TIMER0,sleepTime);   // starts countdown in TIMER0 starting from the setTime value
    
        repeat
             processTouch();
             //your code
        forever
    endfunc
    
    // Timer Event handler
    func sleep()
         sys_Sleep(65535);          // sleeps in 65535 secs if not touched
    endfunc
    
    //Touch Event handler
    func processTouch()
        var touchState;
        var im;
    
        touchState := touch_Get(TOUCH_STATUS);
        im := img_Touched(hndl, -1);
    
        if(touchState)  sys_SetTimer(TIMER0,sleepTime);   // if there is touch event, reset the timer
                                                  
    endfunc
    Hope this will help and Best regards.

    Vince_4D

    Comment

    Working...
    X