Jump to content

microbit.display.animate

From Compy Docs

Display an animation on the LED matrix. This is a blocking function, returning after it is done with the animation.

Function

Synopsis

microbit.display.animate(image, delay, stride)

Arguments

  • `image` — An image table with `width`, `height` and `data` fields.
  • `delay` — A number. The delay between animation frames in milliseconds.
  • `stride` — The number of pixels by which the display window is moving across the image.

Returns

A boolean value. True on success.

Example

heartbeat = {
  width = 10,
  height = 5,
  data = string.char(
      0,   0,   0,   0,   0,    0, 255,   0, 255,   0,
      0, 255,   0, 255,   0,  255,  64, 255,  64, 255,
      0, 255, 255, 255,   0,  255,  64,  64,  64, 255,
      0,   0, 255,   0,   0,    0, 255,  64, 255,   0,
      0,   0,   0,   0,   0,    0,   0, 255,   0,   0
  )
}
microbit.display.animate(heartbeat, 1000, 5)

Synopsis

microbit.display.animate(image, delay, stride, startingPosition)

Arguments

  • `image` — An image table with `width`, `height` and `data` fields.
  • `delay` — A number. The delay between animation frames in milliseconds.
  • `stride` — The number of pixels by which the display window is moving across the image.
  • `startingPosition` — The number of pixels to skip before starting the animation.

Returns

A boolean value. True on success.

Synopsis

microbit.display.animate(image, delay, stride, startingPosition, autoClear)

Arguments

  • `image` — An image table with `width`, `height` and `data` fields.
  • `delay` — A number. The delay between animation frames in milliseconds.
  • `stride` — The number of pixels by which the display window is moving across the image.
  • `startingPosition` — The number of pixels to skip before starting the animation.
  • `autoClear` — A boolean value. True if the display is to be cleared after finishing the animation, false if the last frame is to be retained on the display.

Returns

A boolean value. True on success.

See Also