• AVR Freaks

Waking up controller with button press from Screen

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)

Waking up controller with button press from Screen

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() {
    SYS_MESSAGE("Going to sleep\r\n");
    WDTCONSET = 0x8000;
    asm volatile("wait");

void Pwr_WakeUp(void) {
    SYS_MESSAGE("Woke up from sleep\r\n");

void Pwr_TurnOffScreen(void) {

void Pwr_TurnOnScreen(void) {

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.


if (SCREEN_TIMEOUT_ENABLED == true && touchScreenTimeoutCount >= SCREEN_TIMEOUT) {

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;
    touchScreenTimeoutCount = 0;

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

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.

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)
Maybe use an analog comparator interrupt?
Jump to:
© 2021 APG vNext Commercial Version 4.5