public static List<List<LED>> GetNeededLEDs(Animation ani) { List<List<LED>> involvedLEDs = new List<List<LED>>(); for(int i = 0; i < ani.AnimationModel.Count; i++) { List<LED> involvedGridLEDs = Grid.GetNeededLEDs(ani.AnimationModel[i]); involvedLEDs.Add(involvedGridLEDs); } return involvedLEDs; }
public void Load(string text, int time) // Loads a text with.. { // ..its animation.time animation = Animation.GenerateAnimation(text, time); }
public void Load(Animation an) // Loads an animation { animation = an; Animation_UpdateRequested = true; }
private void Drive(DriveMode dm) // Drives the LEDs { switch (dm) { case DriveMode.Animation: // Animation Mode { if (!running) { running = true; Stopwatch sw = new Stopwatch(); while (!finish) { if (animation == null) { running = false; return; } Animation operation = new Animation(animation); Animation_UpdateRequested = false; DefaultConfiguartion(); List<List<LED>> leds = Animation.GetNeededLEDs(operation); while(!Animation_UpdateRequested) { for (int i = 0; i < operation.AnimationModel.Count; i++) { sw.Restart(); while (sw.ElapsedMilliseconds < operation.Durations[i]) { for (int j = 0; j < leds[i].Count; j++) { UpdateLED(leds[i][j]); UpdateLED(leds[i][j], !leds[i][j].State); } if (cancelAnimation.IsCancellationRequested) { running = false; return; } } sw.Stop(); } } } running = false; } } break; case DriveMode.Static: // Static Mode { if (!running) { running = true; while (!finish) { if (image == null) { running = false; return; } Grid operation = new Grid(image.Map); Image_UpdateRequested = false; DefaultConfiguartion(); List<LED> leds = Grid.GetNeededLEDs(operation); while(!Image_UpdateRequested) { for (int i = 0; i < leds.Count; i++) { UpdateLED(leds[i]); UpdateLED(leds[i], !leds[i].State); if (cancelAnimation.IsCancellationRequested) { running = false; return; } } } } running = false; } } break; } }
public Animation(Animation _animation_) { animation = _animation_.AnimationModel; durations = _animation_.Durations; }