Strategy for animating a lot of "LED's" - thread?, UIView animations? NSOperation? (iPhone)

Posted by RickiG on Stack Overflow See other posts from Stack Overflow or by RickiG
Published on 2010-03-26T08:30:08Z Indexed on 2010/03/26 9:43 UTC
Read the original article Hit count: 322

Filed under:
|

Hi

I have to do some different views containing 72 LED lights. I built an LED Class so I can loop through the LED's and set them to different colors (Green, Red, Orange, Blue None etc.). The LED then loads the appropriate .png.

This works fine, I loop over the LED's and set them. Now I know that at some time they will need to not just turn on/off change color, but will have to turn on with a small delay. Like an equalizer.

I have a 5-10 views containing the 72 LED's and I would like to achieve the above with the minimum amount of memory/CPU strain.

for(LED *l in self.ledArray) {

    [l display:Green];
}

I simply loop as shown above and inside the LED is a switch case that does the correct logic. If this were actual LED's and a microController I would use sleep(100) or similar in the loop, but I would really like to avoid stuff like that for obvious reasons.

I was thinking that doing a performOnThread withDelay would really be consuming, so would UIView animation changing the alpha and NSOperation would also be a lot of lifting for a small feature.

Is there a both efficient and clever way to go around this?

Thanks for any inspiration given:)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsthread