anki_vector.screen

Vector’s LCD Screen that displays his face.

The screen is 184 x 96 color (RGB565) pixels. The active area is 23.2mm x 12.1mm.

Functions

convert_image_to_screen_data(pil_image)

Convert an image into the correct format to display on Vector’s face.

convert_pixels_to_screen_data(pixel_data, …)

Convert a sequence of pixel data to the correct format to display on Vector’s face.

dimensions()

Return the dimension (width, height) of the Screen.

Classes

ScreenComponent(robot)

Handles messaging to control Vector’s screen

anki_vector.screen.dimensions()

Return the dimension (width, height) of the Screen.

import anki_vector

screen_dimensions = anki_vector.screen.SCREEN_WIDTH, anki_vector.screen.SCREEN_HEIGHT
Returns

A tuple of ints (width, height)

anki_vector.screen.convert_image_to_screen_data(pil_image)

Convert an image into the correct format to display on Vector’s face.

import anki_vector

try:
    from PIL import Image
except ImportError:
    sys.exit("Cannot import from PIL: Do `pip3 install --user Pillow` to install")

with anki_vector.Robot() as robot:
    # Load an image
    image_file = Image.open('../examples/face_images/cozmo_image.jpg')

    # Convert the image to the format used by the Screen
    screen_data = anki_vector.screen.convert_image_to_screen_data(image_file)
    robot.screen.set_screen_with_image_data(screen_data, 4.0)
Parameters

pil_image (Image) – The image to display on Vector’s face

Returns

A bytes object representing all of the pixels (16bit color in rgb565 format)

anki_vector.screen.convert_pixels_to_screen_data(pixel_data, image_width, image_height)

Convert a sequence of pixel data to the correct format to display on Vector’s face.

Parameters
  • pixel_data (list) – sequence of triplets representing rgb values, should be ints from 0-255

  • image_width (int) – width of the image defined by the pixel_data

  • image_height (int) – height of the image defined by the pixel_data

import anki_vector
from anki_vector.screen import convert_pixels_to_screen_data
from PIL import Image

image_file = Image.open('../examples/face_images/cozmo_image.jpg')
image_data = image_file.getdata()
pixel_bytes = convert_pixels_to_screen_data(image_data, image_file.width, image_file.height)
Returns

A bytes object representing all of the pixels (16bit color in rgb565 format)

Raises
class anki_vector.screen.ScreenComponent(robot)

Handles messaging to control Vector’s screen

set_screen_to_color(solid_color, duration_sec, interrupt_running=True)

Set Vector’s Screen (his “face”). to a solid color.

import anki_vector
import time

with anki_vector.Robot() as robot:
    duration_s = 4.0
    robot.screen.set_screen_to_color(anki_vector.color.Color(rgb=[255, 128, 0]), duration_sec=duration_s)
    time.sleep(duration_s)
Parameters
  • solid_color (Color) – Desired color to set Vector’s Screen.

  • duration_sec (float) – The number of seconds the color should remain on Vector’s face.

  • interrupt_running (bool) – Set to true so any currently-streaming animation will be aborted in favor of this.

set_screen_with_image_data(image_data, duration_sec, interrupt_running=True)

Display an image on Vector’s Screen (his “face”).

import anki_vector
import time

try:
    from PIL import Image
except ImportError:
    sys.exit("Cannot import from PIL: Do `pip3 install --user Pillow` to install")

with anki_vector.Robot() as robot:
    # Load an image
    image_file = Image.open('../examples/face_images/cozmo_image.jpg')

    # Convert the image to the format used by the Screen
    screen_data = anki_vector.screen.convert_image_to_screen_data(image_file)

    duration_s = 4.0
    robot.screen.set_screen_with_image_data(screen_data, duration_s)
    time.sleep(duration_s)
Parameters
  • image_data (bytes) – A bytes object representing all of the pixels (16bit color in rgb565 format)

  • duration_sec (float) – The number of seconds the image should remain on Vector’s face.

  • interrupt_running (bool) – Set to true so any currently-streaming animation will be aborted in favor of this.