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 an image into the correct format to display on Vector’s face. |
|
Convert a sequence of pixel data to the correct format to display on Vector’s face. |
Return the dimension (width, height) of the Screen. |
Classes
|
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)
-
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
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
ValueError – Invalid Dimensions
ValueError – Bad image_width
ValueError – Bad image_height
-
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)
-
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
-