After going through the two different versions I remembered that the last thing I wanted to implement was varying the brightness of each LED to ramp up/off to the set BRIGHTNESS level. This would simulate incandescent bulbs by 'fading' up the LED (and also fade off).
This is the suspect code:
Code:temp VAR WORD speed CON 6 ;----[Initialize]------------------------------------------------ FOR x = 0 to (LEDcount - 1) ; load the periods from EEPROM READ OnTimes+x, OnTime(x) READ OffTimes+x, OffTime(x) #IFDEF USE_RANDOM_SEQUENCE READ RandPeriods+(x<<1), WORD RandPeriod(x) #ENDIF NEXT X ;----[Main Program Loop]----------------------------------------- Main: x = (x + 1) // LEDcount IF LoopLED(x) < OnTime(x) THEN READ Brightness + x, temp IF Bright(x) < temp THEN Bright(x) = Bright(x) + speed ELSE Bright(x) = temp ENDIF ELSE IF Bright(x) > 0 THEN Bright(x) = Bright(x) - speed ELSE Bright(x) = 0 ENDIF ENDIF LoopLED(x) = (LoopLED(x) + 1) // (OnTime(x) + OffTime(x)) #IFDEF USE_RANDOM_SEQUENCE RandPeriod(x) = RandPeriod(x) - 1 IF RandPeriod(x) = 0 THEN READ RandPeriods+(x<<1), WORD RandPeriod(x) RANDOM RND OnTime(x) = (MAX_ON - MIN_ON)* RND.HighByte / 255 + MIN_ON OffTime(x)= (MAX_OFF - MIN_OFF)* RND.LowByte / 255 + MIN_OFF ENDIF #ENDIF IF x != (LEDcount - 1) THEN Main Waiting: IF !TMR0IF THEN Waiting TMR0 = 99 TMR0IF = 0 GOTO Main




Bookmarks