class WakeUp - Wake-Up Interrupt

The ordinary GPIOs of the EC600/EC800E series do not support double-edge trigger interrupts, and do not support interrupts to wake up the module during sleep. WakeUp has no pull-up/pull-down restrictions, supports double-edge trigger interrupts and waking up the module during sleep by default. The usage is as follows:

Constructor

class pm.WakeUp(WakeupID, pull)

Parameter:

  • WakeupID - The wakeup number to control, described as follows:
    EC800E:
    WAKEUP2 - Pin 79
    WAKEUP3 - Pin 109 (unavailable for EC800ECN_LE&LQ&LC)
    WAKEUP4 - Pin 108 (unavailable for EC800ECN_LE&LQ&LC)
    WAKEUP5 - Pin 19

    EC600E:
    WAKEUP2 - Pin 9
    WAKEUP3 - Pin 51
    WAKEUP4 - Pin 50
    WAKEUP5 - Pin 39

  • pull - Pull-up/pull-down mode, int type, described as follows:
    PULL_DISABLE – Floating mode 0
    PULL_PU – Pull-up mode 1
    PULL_PD – Pull-down mode 2

Example:

from pm import WakeUp  
def fun(level):
    print(str(level))

wake=WakeUp(WakeUp.WAKEUP5,WakeUp.PULL_PD) 
wake.set_callback(fun)# Set callback, callback only returns level  
wake.enable()# Enable interrupt  

wake.read() #Read pin level

Methods

wake.enable

wake.enable() 

This method is used to enable the WakeUp interrupt. When a rising or falling edge is detected on the WakeUp pin, the callback will be executed.

Return Value:

Returns integer value 0 for success, -1 for failure.

wake.disable

wake.disable()

This method is used to disable the interrupt and disable the interrupt associated with the WakeUp object.

Return Value:

Returns integer value 0 for success, -1 for failure.

wake.read

wake.read()  

This method is used to read the current pin level.

Return Value:

Returns pin level, 0 means low pin level, 1 means high pin level.

wake.deinit

wake.deinit()

Disable WakeUp function.

Return Value:

Returns integer value 0 for success, -1 for failure.

wake.set_callback

wake.set_callback(fun)

This method is used to set the callback. After the interrupt is triggered, this callback will be executed and return the level.

Parameter:

  • fun - Callback function with prototype:

    fun(level)
    

    Callback function parameter description:

    • level:0: low level, 1: high level.
Module WakeUp Pin Description
EC800E WAKEUP2 - Pin 79
WAKEUP3 - Pin 109 (unavailable for EC800ECN_LE&LQ&LC)
WAKEUP4 - Pin 108 (unavailable for EC800ECN_LE&LQ&LC)
WAKEUP5 - Pin 19
EC600E WAKEUP2 - Pin 9
WAKEUP3 - Pin 51
WAKEUP4 - Pin 50
WAKEUP5 - Pin 39