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.

Z-Stack Lighting button1(P2.0) bug fix

Other Parts Discussed in Thread: PMP

Dear TI,

Please find the below code,Even you press the button (P2.0) very fast or slow we wont get 1sec,less than 5 secs and greater than 5 secs.we need to flip the logic to make it work.

Actual Code :

/********************************************************************* 

* @fn      zllSampleLight_HandleKeys 

* @brief   Handles all key events for this device. 

 * @param   shift - true if in shift/alt. 

* @param   keys - bit field for key events. 

* @return  none 

*/

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;  

 }  

} #else //HAL_BOARD_CC2530EB ?

If we change the logic as below it will show the requied time.( as we getting the clock from free running rollover count of the MAC backoff timer)

Corrected Code:

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 )  

 {    

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;    

}     

}   else //key released  

 {      

keyPressTime = osal_getClock();  

} #else //HAL_BOARD_CC2530EB ?

Thanks and Regards

Lakshman,PMP,PMI-RMP