MATRIX-Lite-Py
MATRIX Lite Python is a library that allows users of varying skill levels to easily program their MATRIX Device.
Roadmap
- Leds
- Sensors
- IMU
- Humidity
- Pressure
- UV
- GPIO
- Microphones
- Hal Mics
- ALSA Mics (available through any ALSA wrapper)
- NFC (separate library)
Installation
Ensure you have a Raspberry Pi, attached with a MATRIX device, that's flashed with Raspbian.
1. Install MATRIX HAL
https://matrix-io.github.io/matrix-documentation/matrix-hal/getting-started/installation-package/
2. Install Python 3
To call your scripts with python 3, use
python3 YOUR_SCRIPT.py
sudo apt-get install python3-pip
3. Upgrade PIP
python3 -m pip install --upgrade pip
4. Install matrix-lite-py
python3 -m pip install --user matrix-lite
Usage
The matrix-lite package contains a matrix_lite & _matrix_hal Python module. _matrix_hal is the direct HAL implementation. matrix_lite contains small abstractions for _matrix_hal.
Everloop
from matrix_lite import led
import time
# Get LED count
print('This device has ' + str(led.length) + ' Leds')
# A single string, object, or tuple will set all LEDs
# Below are different ways of expressing a color (number values are from 0-255)
led.set('blue')
led.set('#0000ff')
# Objects and tuples can utilize the white LED
led.set({'r':0, 'g':0, 'b':255, 'w':0 })
led.set((0,0,255,0))
# LEDs off
led.set('black')
led.set([])
led.set()
led.set({})
# Arrays set individual LEDs
led.set(['red', 'gold', 'purple', {}, 'black', '#6F41C1', 'blue', {'g':255}])
# Arrays can simulate motion
everloop = ['black'] * led.length
everloop[0] = {'b':100}
while True:
everloop.append(everloop.pop(0))
led.set(everloop)
time.sleep(0.050)
Sensors
from matrix_lite import sensors
import time
# Sensors will update with each .read() call
while True:
# Each .read() returns a dictionary
print(sensors.imu.read())
print(sensors.uv.read())
print(sensors.humidity.read())
print(sensors.pressure.read())
time.sleep(5/1000)
GPIO
from matrix_lite import gpio
# Read GPIO pin 0 (digital)
gpio.setFunction(0, 'DIGITAL')
gpio.setMode(0, 'input')
print('Pin 0 is: ' + str(gpio.getDigital(0)))
# Set GPIO pin 1 (digital)
gpio.setFunction(1, 'DIGITAL')
gpio.setMode(1, 'output')
gpio.setDigital(1, 'ON')
# Set GPIO pin 2 (PWM)
gpio.setFunction(2, 'PWM')
gpio.setMode(2, 'output')
gpio.setPWM({
"pin": 2,
"percentage": 25,
"frequency": 50, # min 36
})
# Set Servo Angle pin 3
gpio.setFunction(3, 'PWM')
gpio.setMode(3, 'output')
gpio.setServoAngle({
"pin": 3,
"angle": 90,
# min_pulse_ms (minimum pulse width for a PWM wave in milliseconds)
"min_pulse_ms": 0.8,
})
Building Locally For Development
Make sure you have MATRIX HAL & Python 3 installed.
If you want to contribute to matrix-lite-py, below are the steps to build locally. Each step should take place on your Raspberry Pi.
Download the repository.
git clone https://github.com/matrix-io/matrix-lite-py
Install pybind11.
sudo python3 -m pip install pybind11
Compile and install the matrix_lite python package with your changes.
cd matrix-lite-py
sudo python3 -m pip install ./
Metadata
Release files for matrix-lite 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| matrix-lite-0.0.8.tar.gz | 10.9 kB | Without provenance | Details for matrix-lite-0.0.8.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| matrix_lite-0.0.8-cp37-cp37m-linux_armv7l.whl | CPython 3.7 | CPython 3.7 pymalloc | linux armv7l | Details for matrix_lite-0.0.8-cp37-cp37m-linux_armv7l.whl |
| matrix_lite-0.0.8-cp37-cp37m-linux_armv6l.whl | CPython 3.7 | CPython 3.7 pymalloc | linux armv6l | Details for matrix_lite-0.0.8-cp37-cp37m-linux_armv6l.whl |
| matrix_lite-0.0.8-cp35-cp35m-linux_armv7l.whl | CPython 3.5 | CPython 3.5 pymalloc | linux armv7l | Details for matrix_lite-0.0.8-cp35-cp35m-linux_armv7l.whl |
| matrix_lite-0.0.8-cp35-cp35m-linux_armv6l.whl | CPython 3.5 | CPython 3.5 pymalloc | linux armv6l | Details for matrix_lite-0.0.8-cp35-cp35m-linux_armv6l.whl |
Total release size: 8.2 MB
Release files / matrix-lite-0.0.8.tar.gz
| Download URL | matrix-lite-0.0.8.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a761fb31e059f72c568c44a6771dc9f9cd6050221b48ca171d2f882eb71181a4
|
|
BLAKE2b-256 checksum How to use checksums |
ca09dc1b23f758583b168165eab553f3300fae309820d51a1a5031f96e6d2e73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Release files / matrix_lite-0.0.8-cp37-cp37m-linux_armv7l.whl
| Download URL | matrix_lite-0.0.8-cp37-cp37m-linux_armv7l.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc linux armv7l |
|
SHA-256 checksum How to use checksums |
7c7864cf45a83838f6e0f12c9801eb7b045f350ce6fd290995c6c8a589e4e7f5
|
|
BLAKE2b-256 checksum How to use checksums |
66c7e90c58adcbda7c0e3e4f564309d51f7be1ab85625168a7d50698f85c8045
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Release files / matrix_lite-0.0.8-cp37-cp37m-linux_armv6l.whl
| Download URL | matrix_lite-0.0.8-cp37-cp37m-linux_armv6l.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc linux armv6l |
|
SHA-256 checksum How to use checksums |
05d787ef7a2e3bdff6af1152e627d098d2ea8223aae80e1cda32f65dc735b6c7
|
|
BLAKE2b-256 checksum How to use checksums |
3dd1b8d292f7c714aca469359c0e79e7689be625f6b58e85968cdedae4bf6d39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Release files / matrix_lite-0.0.8-cp35-cp35m-linux_armv7l.whl
| Download URL | matrix_lite-0.0.8-cp35-cp35m-linux_armv7l.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc linux armv7l |
|
SHA-256 checksum How to use checksums |
4fc57c3a8cc9c19628a4605290f3082998a364385b0a1a339771d5ff6ab8480b
|
|
BLAKE2b-256 checksum How to use checksums |
a97e49cf325266075d6622b0e86b6e3ca4109bb8c6d35892ce37405e3b2984de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Release files / matrix_lite-0.0.8-cp35-cp35m-linux_armv6l.whl
| Download URL | matrix_lite-0.0.8-cp35-cp35m-linux_armv6l.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc linux armv6l |
|
SHA-256 checksum How to use checksums |
e1d1461dbac55940907b8bf2e052db07657f494e7aad9c6e1c7c343931df6a5e
|
|
BLAKE2b-256 checksum How to use checksums |
4ec3d5f3ff97c8f1fab1d54fca307e607a85337fd6f71149de380532f34c67ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
|
Security for matrix-lite 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.