Pi-top Python SDK.


Keywords
pi-top, raspberrypi, battery, pi-topos, python, python3
License
Apache-2.0
Install
pip install pitop.display==0.26.3.post1

Documentation

GitHub tag (latest by date) GitHub release (latest by date) PyPI release Latest Build Status Documentation Language grade: Python Language grade: Javascript Codecov pre-commit.ci status

pi-top Python SDK (Preview)

A simple, modular interface for interacting with a pi-top and its related accessories and components.

Supports all pi-top devices:

https://github.com/pi-top/pi-top-Python-SDK/raw/master/docs/_static/overview/devices.jpg

Supports pi-top Maker Architecture (PMA):

https://github.com/pi-top/pi-top-Python-SDK/raw/master/docs/_static/overview/pma.jpg

Supports all pi-top peripherals:

https://github.com/pi-top/pi-top-Python-SDK/raw/master/docs/_static/overview/peripherals.jpg

Status: Active Development

This SDK is currently in active development. Please be patient while we work towards v1.0.0!

Backwards Compatibility

When this library reaches v1.0.0, we will aim to maintain backwards-compatibility thereafter. Until then, every effort will be made to ensure stable support, but it cannot be guaranteed. Breaking changes will be clearly documented.

About

This SDK aims to provide an easy-to-use framework for managing a pi-top. It includes several Python 3 packages and modules for interfacing with a range of pi-top devices and peripherals. It also contains CLI utilities for interacting with your pi-top using the terminal.

The SDK is included out-of-the-box with pi-topOS.

Ensure that you keep your system up-to-date to enjoy the latest features and bug fixes.

You can easily connect different components of the system using the modules available in the library:

from time import sleep
from pitop import UltrasonicSensor
from pitop import Pitop

pitop = Pitop()
utrasonic = UltrasonicSensor("D1")

while True:
    pitop.miniscreen.display_text(utrasonic.distance)
    sleep(0.1)

Check out the API Recipes chapter of the documentation for ideas on how to get started.

This repository also contains a 'pi-top' command-line interface (CLI) for some SDK functionality:

$ pi-top oled write "Hey! I'm a $(pt devices hub)"

A 'pt' alias is also provided for quicker typing:

$ pt oled write "Hey! I'm a $(pt devices hub)"

Check out the CLI chapter of the documentation for ideas on how to get started.

Installation

OS

The pi-top Python SDK is installed out of the box with pi-topOS, which is available from pi-top.com. To install on Raspberry Pi OS or other operating systems, see the Getting Started chapter.

pip

The SDK is also available on PyPI.

On ARM devices, such as the Raspberry Pi, you need to include pi-top's repository to meet all the dependencies:

pip3 install pitop --extra-index-url=https://packagecloud.io/pi-top/pypi/pypi/simple

On non-ARM devices, you can omit the extra-index-url flag:

pip3 install pitop

You can also install a pitop subpackage directly in case you don't need the whole SDK:

pip3 install pitop.pma

Development

To install the SDK in development mode run the script dev-install.sh in the root of the repo:

./dev-install.sh

The script installs the subpackages in a particular order, given the dependencies between them. Also, the --extra-index-url parameter is added to install the onnxruntime package instead of building it from scratch for some architectures.

In case of build errors, you might need to install the gfortran package:

sudo apt install -y gfortran

Documentation

Comprehensive documentation is available here.

Contributing

Please refer to the Contributing document in this repository for information on contributing to the project.

See the contributors page on GitHub for more info on contributors.