Python API for controlling modular electronics, MODI+.
Project description
Description
Python API for controlling modular electronics, MODI+.
Features
PyMODI+ provides a control of modular electronics.
- Platform agnostic control of modules through serial connection
- Utilities of wireless connection with BLE (Bluetooth Low Engery)
Build Status
| master | develop |
|---|---|
System Support
| System | 3.7 | 3.8 | 3.9 | 3.10 | 3.11 |
|---|---|---|---|---|---|
| Linux | |||||
| Mac OS | |||||
| Windows |
Contribution Guidelines
We appreciate all contributions. If you are planning to report bugs, please do so here. Feel free to fork our repository to your local environment, and please send us feedback by filing an issue.
If you want to contribute to pymodi, be sure to review the contribution guidelines. This project adheres to pymodi's code of conduct. By participating, you are expected to uphold this code.
Installation
When installing PyMODI+ package, we highly recommend you to use Anaconda to manage the distribution. With Anaconda, you can use an isolated virtual environment, solely for PyMODI+.
[Optional] Once you install Anaconda, then:
# Install new python environment for PyMODI+ package, choose python version >= 3.7
conda create --name pymodi_plus python=3.7
# After you properly install the python environment, activate it
conda activate pymodi_plus
# Ensure that your python version is compatible with PyMODI+
python --version
Install the latest PyMODI+ if you haven't installed it yet:
python -m pip install pymodi-plus --user --upgrade
Usage
Import modi_plus package and create MODIPlus object (we call it "bundle", a bundle of MODI+ modules).
# Import modi_plus package
import modi_plus
"""
Create MODIPlus object, make sure that you have connected your network module
to your machine while other modules are attached to the network module
"""
bundle = modi_plus.MODIPlus()
[Optional] Specify how you would like to establish the connection between your machine and the network module.
# 1. Serial connection (via USB), it's the default connection method
bundle = modi_plus.MODIPlus(connection_type="serialport")
# 2. BLE (Bluetooth Low Energy) connection, it's wireless! But it can be slow :(
bundle = modi_plus.MODIPlus(conn_type="ble", network_uuid="YOUR_NETWORK_MODULE_UUID")
List and create connected modules' object.
# List connected modules
print(bundle.modules)
# List connected leds
print(bundle.leds)
# Pick the first led object from the bundle
led = bundle.leds[0]
Let's blink the LED 5 times.
import time
for _ in range(5):
# turn on for 0.5 second
led.turn_on()
time.sleep(0.5)
# turn off for 0.5 second
led.turn_off()
time.sleep(0.5)
If you are still not sure how to use PyMODI, you can play PyMODI tutorial over REPL:
$ python -m modi_plus --tutorial
As well as an interactive usage examples:
$ python -m modi_plus --usage
Additional Usage
To diagnose MODI+ modules (helpful to find existing malfunctioning modules),
$ python -m modi_plus --inspect
To initialize MODI+ modules implicitly (set i flag to enable REPL mode),
$ python -im modi_plus --initialize
To see what other commands are available,
$ python -m modi_plus --help
Documentation
📚 Complete documentation is available in the docs/ folder.
Quick Links
- 🚀 Quick Start Guide - Get up and running quickly
- ✨ Env Module RGB Features - New RGB sensor support (v2.x+)
- 🛠️ Development Guide - Build, test, and contribute
- 📦 Deployment Guide - Release to PyPI
- 🐛 Troubleshooting - Platform-specific issues and fixes
What's New in v0.4.0
- ✅ RGB Color Sensor Support for Env module v2.x+
- New properties:
red,green,blue,white,black - Color classification:
color_class(0-5) - Brightness measurement:
brightness(0-100%)
- New properties:
- ✅ Enhanced Testing - 94 tests across all platforms
- ✅ Python 3.8-3.13 Support - Wide version compatibility
- ✅ Improved CI/CD - GitHub Actions enhancements
See Release History for complete changelog.
Contributing
We welcome contributions! Please see:
License
This project is licensed under the MIT License - see the LICENSE file for details.
History
0.4.2 (2025-12-22)
- Feature
- Add RGB raw value properties for Env module v2.x+
- New properties:
raw_red,raw_green,raw_blue,raw_white(0-65535) - New property:
raw_rgbtuple (raw_red, raw_green, raw_blue, raw_white)
- New properties:
- Add
set_rgb_mode(mode, duration)method for Env module- RGB mode constants:
RGB_MODE_AMBIENT,RGB_MODE_ON,RGB_MODE_DUALSHOT
- RGB mode constants:
- Code style fixes for flake8 compatibility
0.4.0 (2025-11-19)
- Feature
- Add RGB support for Env module v2.x+
- New properties:
red,green,blue,white,black(0-100%) - New property:
rgb- returns tuple (red, green, blue) - New property:
color_class(0-5: unknown/red/green/blue/white/black) - New property:
brightness(0-100%) - Automatic version detection via
_is_rgb_supported()method - Raises
AttributeErrorwhen accessing RGB properties on v1.x modules
- New properties:
- Enhanced GitHub Actions workflows
- Support Python 3.8-3.13 across all platforms
- Platform-specific compatibility fixes (macOS, Windows)
- Improved CI/CD with conditional linting (flake8 for 3.8-3.11, ruff for 3.12+)
- Tests
- Add 31 new RGB-related tests
- Version compatibility tests
- RGB property tests
- Data type validation tests
- Total: 94 tests (all passing)
- Documentation
- Complete RGB feature documentation
- GitHub Actions compatibility guides
- Branch protection setup guide
0.3.0 (2023-01-19)
- Feature
- Add
draw_dotfunction on display module
- Patch
- Fix
write_textfunction error on display module if text length is 23 - Change module constructor argument from uuid to id
0.2.1 (2022-12-02)
- Patch
- Refactor
write_textinput type on display module
0.2.0 (2022-12-02)
- Feature
- Refactor getter/setter for each MODI+ module
0.1.1 (2022-11-23)
- Feature
- Change python minimum version to 3.7
0.1.0 (2022-11-22)
- Feature
- Add creation examples (brush, dodge)
- Add network, battery module functions
- Fix
play_musicfunction on speaker module - Add preset resource on speaker and display module
- Add search module time and timeout exception
0.0.2 (2022-11-18)
- Feature
- Change python minimum version to 3.9
0.0.1 (2022-11-15)
- Release initial version of the package on in-house GitHub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymodi_plus-0.4.2.tar.gz.
File metadata
- Download URL: pymodi_plus-0.4.2.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34f6369409c2a1380e43bb3d97a925443a8ed2ff3bde9dfc900fc8407867eb6c
|
|
| MD5 |
e37f337bcca521394d94bb362e6b8794
|
|
| BLAKE2b-256 |
1e2eddf6cb1e49d836077003d95b8317cc403da0f73839960ad170c7a9fc6e87
|
File details
Details for the file pymodi_plus-0.4.2-py2.py3-none-any.whl.
File metadata
- Download URL: pymodi_plus-0.4.2-py2.py3-none-any.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c706d08a7b8b5402cf03707eddc49caceb6c9f83b80e8ace553150d27b3224fa
|
|
| MD5 |
658f8a285aa8edd34a26ed351b54fcd0
|
|
| BLAKE2b-256 |
dad69ce0efe0ff213576b78c61891806d192817f53b6cfaebe2b30aaeb19440c
|