/*which pattern are we currently indicating for this LED pair*/
/*这段是来选择哪种pattern显示,有gActiveLEDs里面的Type来决定*/
if ( lLED->Type == IT_StateIndication)
{
/* this is a STATE indication */
lPattern = &theSink.theLEDTask->gStatePatterns[ lLED->Index] ;
}
else
{ /*is an event indication*/
lPattern = &theSink.theLEDTask->pEventPatterns [ lLED->Index ] ;
}
/* get which of the LEDs we are interested in for the pattern we are dealing with */
/* 这个函数主要是取出使用哪个LED,首先检测LEDtask里面的gTheActiveFiltersH,
gTheActiveFiltersL,如果有event使能就检测相应gEventFilters里面的colour是否是
LED_COL_EITHER,如果不是就强制使用gEventFilters里定义的LED.*/
lColour = LedsGetPatternColour ( lPattern ) ;
/*get the state of the LED we are dealing with*/
/*省略掉theSink.theLEDTask->后,
实际上lOldState=gActiveLEDS[gStatePatterns[gActiveLEDS[id]->Index]->LED_A].OnOrOff
或者是lOldState=gActiveLEDS[pEventPatterns[gActiveLEDS[id]->Index]->LED_A].OnOrOff */
lOldState = theSink.theLEDTask->gActiveLEDS [ lPattern->LED_A ].OnOrOff ;
/* is LED currently off? */
if (lOldState == LED_OFF)/*当前led关着*/
{
/* led is off so start the new pattern by turning LED on */
lTime = LED_SCALE_ON_OFF_TIME(lPattern->OnTime) ;/* Ontime*10*倍数才是真正的时间,倍数在feature_config_type里定义 */
/* #define LED_SCALE_ON_OFF_TIME(x) (uint16)((x * 10) << theSink.features.LedTimeMultiplier )*/
LED_DEBUG(("LED: set ON time [%x]\n",lTime)) ;
/*Increment the number of flashes*/
lLED->NumFlashesComplete++ ;/*NumFlashesComplete 应该是当前flash数的记录,估计是个递减的。*/