As I no longer have a pi-top to work with, I am no longer maintaining this code base. If you'd like to see it changed and updated in some significant way, you'll need to fork the repo and continuing working off your own instance of it.
Are you interested in running a non-Raspbian based distribution on your pi-top device? If so, then this is the repository for you. After running into various difficulties when it came to making the existing pi-top package scripts working on Arch Linux.
As a result of this I decided to roll my own script in python that provides an easy interface for managing various aspects of the pi-top within non-Raspbian operating systems.
This script supports controlling/querying the following aspects of the Pi-Top Hub controller:
- Backlight
- Battery
- Speaker
This script has been written and tested on a Pi-Top system using a Raspberry Pi 3. It may work with a Pi-Top Ceed and it may work with an Raspberry Pi 2, but I have neither device in my possession and am unable to adequately test as a result.
In theory this script will work on Raspbian provided the appropriate system mods are made. However it is primarily designed to facilitate making Pi-Top work on non Raspbian based distributions. To that end, this script has been primarily tested using Arch Linux.
Python 3 and the smbus and spidev modules are required to run this script.
You can either run these scripts as root or install an appropriate udev rule which provides access to non-root users. An example of a possible udev rule is included as part of this repository.
Each call to ptctl.py requires at least two arguments: A device and a command.
Calls to the speaker device require a third parameter which represents the bus address of the specific speaker. For example on my pi-top which only has a single speaker connected to the hub, the address is 0x72. The device of your speaker can be narrowed down by running the following command:
i2cdetect -y 1
Speaker addresses typically range from 0x71 and up.
The available devices and commands are:
-
battery
- state
- capacity (returns percentage of battery remaining)
- time (returns estimated time for discharing/charging)
-
backlight
- state
- increase (increases brightness unless its already 10)
- decrease (decreases brightness unless its already 1)
- off
- on (turns on the backlight and sets brightness to 5)
- 1 thru 10 (represents tbe absolute brightness value)
-
speaker
- mono [hex address of speaker]
- left [hex address of speaker]
- right [hex address of speaker]
-
system
- state
- off (turns off the hub - should be executed only during shutdown)
-
lid
- state