Screenshots

This service takes screenshots and returns them in 8-bit ARGB format. The resulting images are lists of bytearrays, but can easily be converted to PNGs using pypng:

import png
image = Screenshot(pebble).grab_image()
png.from_array(image).save('screenshot.png')
class libpebble2.services.screenshot.Screenshot(pebble)

Takes a screenshot from the watch.

Parameters:pebble (PebbleConnection) – The pebble of which to take a screenshot.
grab_image()

Takes a screenshot. Blocks until completion, or raises a ScreenshotError on failure.

While this method is executing, “progress” events will periodically be emitted with the following signature:

(downloaded_so_far, total_size)
Returns:A list of bytearrays in RGB8 format, where each bytearray is one row of the image.
register_handler(event, handler)

Registers a handler to be triggered by an event

Parameters:
  • event – The event to handle
  • handler – The handler callable.
Returns:

A handle that can be used to unregister the handler.

unregister_handler(handle)

Unregisters an event handler.

Parameters:handle – The handle returned from register_handler()
wait_for_event(event, timeout=10)

Block waiting for the given event. Returns the event params.

Parameters:
  • event – The event to handle.
  • timeout – The maximum time to wait before raising TimeoutError.
Returns:

The event params.