• AVR Freaks

Waking up controller with button press from Screen

Author
ryanjones
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2019/01/07 13:51:21
  • Location: 0
  • Status: offline
2019/02/19 15:11:58 (permalink)
0

Waking up controller with button press from Screen


Background:
Using a PIC32MZ2064DAG169 w/ the MEBII and the DM5000 (5" Screen).
Harmony version: 2.06


For the project that I'm working on I'd like to be able to put the controller into sleep mode and turn off the display and then get it to wake up again when the touchscreen is pressed.
I've managed to get the screen off and the controller to sleep after a timeout, but am having issues turning everything back on again when I press the touchscreen.


void Pwr_GotoSleep() {
    Pwr_TurnOffScreen();
    SYS_MESSAGE("Going to sleep\r\n");
    WDTCONSET = 0x8000;
    asm volatile("wait");
    Pwr_WakeUp();
    Pwr_TurnOnScreen();
}

void Pwr_WakeUp(void) {
    SYS_MESSAGE("Woke up from sleep\r\n");
    PLIB_DEVCON_SystemUnlock(DEVCON_ID_0);
    PLIB_RESET_NmiEventClear(RESET_ID_0, WDTS_NMI);
    PLIB_DEVCON_SystemLock(DEVCON_ID_0);
}

void Pwr_TurnOffScreen(void) {
    TM4301B_BACKLIGHTOff();
}

void Pwr_TurnOnScreen(void) {
    TM4301B_BACKLIGHTOn();
}


Then I have a timer that fires every second to toggle a heartbeat LED, and I also use that to see if we've hit our screen timeout.

touchScreenTimeoutCount++;

if (SCREEN_TIMEOUT_ENABLED == true && touchScreenTimeoutCount >= SCREEN_TIMEOUT) {
    Pwr_GotoSleep();
}


I've also overridden the touchUpHandler to reset the touchscreen timeout and wake up the screen when touched (and this worked fine until I introduced the code to put the PIC to sleep)

void touchUpHandler(const SYS_INP_TouchStateEvent * const evt) {
    if (screenOff) {
        screenOff = false;
        Pwr_TurnOnScreen();
    }
    touchScreenTimeoutCount = 0;
}

// Further in the app init
SYS_INP_InputListener inputListener;
inputListener.handleTouchDown = &touchDownHandler;
inputListener.handleTouchUp = &touchUpHandler;
inputListener.handleTouchMove = &touchMoveHandler;
SYS_INP_AddListener(&inputListener);


This is where I'm running to my problem. I can see that the PIC wakes up at the end of the timeout and then goes back to sleep.
And nothing happens when I touch the screen.

Is there some way of enabling interrupts on touching the screen the wakes the PIC from it's sleep mode?
Or if not, has anyone done anything like this before and has some advice.

Thanks
#1
barbiani
Super Member
  • Total Posts : 246
  • Reward points : 0
  • Status: offline
Re: Waking up controller with button press from Screen 2019/02/19 16:30:41 (permalink)
0
Maybe use an analog comparator interrupt?
#2
Jump to:
© 2021 APG vNext Commercial Version 4.5