import jcontrol.io.Display;
import jcontrol.io.Resource;
import jcontrol.lang.ThreadExt;

/**
 * <p>Draws an animated picture on the lcd.</p> 
 *
 * <p>(C) DOMOLOGIC Home Automation GmbH 2003</p>
 */
public class AnimationExample extends Thread {
  /** number of animation images */  
  final int IMAGE_COUNT = 34;
  /** lcd access */
  Display lcd =  new Display();
    
  /**
   * Thread that continuously draws pictures on the lcd
   * to achieve an animation effect.
   * @see java.lang.Runnable#run()
   */
  public void run() {
    for (;;) {
      try {
        for (int i=0; i<IMAGE_COUNT; i++) {
          String name = "anim00";
          if (i<10) {
            name = name.concat("0").concat(String.valueOf(i));
          } else {
            name = name.concat(String.valueOf(i));
          }
          lcd.drawImage(new Resource(name.concat(".jcif")),32,0);
          ThreadExt.sleep(100); // wait 100 millis
        }
      } catch (Exception e) {}
    }
  }

  /**
   * Main Method. Program execution starts here.
   */
  public static void main(String[] args) {
    // create and start animation thread
    new AnimationExample().start();
  }
}
