This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

zstack home 1.2.1一个按键的长短按如何实现?

请问TI大牛:

zstack home 1.2.1中一个按键的长短按如何实现?最好详细点,谢谢啦,急等。。。

  • 请在官网下载Z-Stack Light 协议栈,在里面Zlight的设备里面,实现了这个功能,你可以看下

    static void zllSampleLight_HandleKeys( byte shift, byte keys )
    {
    (void)shift; // Intentionally unreferenced parameter
    #ifdef HAL_BOARD_ZLIGHT
    // Zlight has only a single button
    static uint32 keyPressTime = 0;
    if ( keys )
    {
    keyPressTime = osal_getClock();
    }
    else //key released
    {
    if ( keyPressTime )
    {
    keyPressTime = ( osal_getClock() - keyPressTime );
    if ( keyPressTime <= KEY_HOLD_SHORT_INTERVAL )
    {
    zllTarget_PermitJoin( PERMIT_JOIN_DURATION );
    }
    else if ( keyPressTime > KEY_HOLD_LONG_INTERVAL )
    {
    zllTarget_ClassicalCommissioningStart();
    }
    else
    {
    zllTarget_ResetToFactoryNew();
    }
    keyPressTime = 0;
    }
    }

  • 位置在哪里呢?在工程里面搜索了半天都没有搜索到这个方法