Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help install install-dev install-editable reinstall test test-pytest-all test-all test-input test-output test-task test-verbose test-examples-syntax lint format clean clean-build clean-pyc clean-test coverage docs dist release examples
.PHONY: help install install-dev install-editable reinstall test test-pytest-all test-all test-input test-output test-task test-verbose test-examples-syntax lint format clean clean-build clean-pyc clean-test coverage docs dist release examples test-core test-web install-core install-web build-core build-web
.DEFAULT_GOAL := help

# Python interpreter detection
Expand Down Expand Up @@ -223,3 +223,53 @@ release: dist ## Package and upload a release
@echo "$(BLUE)Uploading to PyPI...$(NC)"
twine upload dist/*
@echo "$(GREEN)✓ Release uploaded$(NC)"

##@ Monorepo - Core Package

install-core: ## Install core package (packages/core)
@echo "$(BLUE)Installing core package...$(NC)"
cd packages/core && $(PYTHON) -m pip install -e .
@echo "$(GREEN)✓ Core package installed$(NC)"

test-core: ## Run core package tests
$(call check_command,pytest)
@echo "$(BLUE)Running core package tests...$(NC)"
$(PYTHON) -m pytest packages/core/tests/task/ packages/core/tests/module/input_module/ packages/core/tests/module/output_module/ -v
@echo "$(GREEN)✓ Core tests completed$(NC)"

build-core: ## Build core package distribution
@echo "$(BLUE)Building core package...$(NC)"
cd packages/core && $(PYTHON) -m pip install --upgrade build && $(PYTHON) -m build
@echo "$(GREEN)✓ Core package built$(NC)"

##@ Monorepo - Web Package

install-web: install-core ## Install web package (depends on core)
@echo "$(BLUE)Installing web package...$(NC)"
cd packages/web && $(PYTHON) -m pip install -e .
@echo "$(GREEN)✓ Web package installed$(NC)"

test-web: ## Run web package tests
$(call check_command,pytest)
@echo "$(BLUE)Running web package tests...$(NC)"
$(PYTHON) -m pytest packages/web/tests/ -v
@echo "$(GREEN)✓ Web tests completed$(NC)"

build-web: ## Build web package distribution
@echo "$(BLUE)Building web package...$(NC)"
cd packages/web && $(PYTHON) -m pip install --upgrade build && $(PYTHON) -m build
@echo "$(GREEN)✓ Web package built$(NC)"

##@ Monorepo - All Packages

install-all: install-core install-web ## Install all packages
@echo "$(GREEN)✓ All packages installed$(NC)"

test-monorepo: test-core test-web ## Run all package tests
@echo ""
@echo "$(GREEN)========================================$(NC)"
@echo "$(GREEN)✓ All monorepo tests passed!$(NC)"
@echo "$(GREEN)========================================$(NC)"

build-all: build-core build-web ## Build all packages
@echo "$(GREEN)✓ All packages built$(NC)"
193 changes: 68 additions & 125 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,169 +5,112 @@
[![Read the Docs (version)](https://img.shields.io/readthedocs/pymodi-plus/latest?style=flat-square)](https://pymodi-plus.readthedocs.io/en/latest/?badge=master)
[![GitHub Workflow Status (Build)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/build.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions)
[![GitHub LICENSE](https://img.shields.io/github/license/LUXROBO/pymodi-plus?style=flat-square&color=blue)](https://github.com/LUXROBO/pymodi-plus/blob/master/LICENSE)
[![Lines of Code](https://img.shields.io/tokei/lines/github/LUXROBO/pymodi-plus?style=flat-square)](https://github.com/LUXROBO/pymodi-plus/tree/master/modi_plus)

</div>

Description
===========
> Python API for controlling modular electronics, MODI+.
# PyMODI+ Monorepo

> Python API for controlling modular electronics, MODI+ - Desktop and Web support

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)
This monorepo contains two packages:

Build Status
------------
|master|develop|
|:---:|:---:|
| [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/build.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/build.yml?branch=develop)](https://github.com/LUXROBO/pymodi-plus/actions)
| Package | Description | PyPI |
|---------|-------------|------|
| **[packages/core](./packages/core/)** | Core library for desktop (USB/BLE) | `pymodi-plus` |
| **[packages/web](./packages/web/)** | Web extension for Pyodide/Browser | `pymodi-plus-web` |

System Support
--------------
| System | 3.7 | 3.8 | 3.9 | 3.10 | 3.11 |
| :---: | :---: | :---: | :---: | :---: | :---: |
| Linux | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_ubuntu.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_ubuntu.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_ubuntu.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_ubuntu.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_ubuntu.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions)
| Mac OS | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_macos.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_macos.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_macos.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_macos.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_macos.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions)
| Windows | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_windows.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_windows.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_windows.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_windows.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions) | [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/LUXROBO/pymodi-plus/unit_test_windows.yml?branch=master)](https://github.com/LUXROBO/pymodi-plus/actions)
## Quick Start

Contribution Guidelines
-----------------------
We appreciate all contributions. If you are planning to report bugs, please do so [here](https://github.com/LUXROBO/pymodi/issues). Feel free to fork our repository to your local environment, and please send us feedback by filing an issue.
### Desktop Usage (USB/BLE)

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.
```bash
# Install with all features
pip install pymodi-plus[all]

[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](CODE_OF_CONDUCT.md)

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](https://docs.anaconda.com/anaconda/install/), then:
# Or minimal install
pip install pymodi-plus
```
# 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).
```python
# 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()
led = bundle.leds[0]
led.turn_on()
```

[Optional] Specify how you would like to establish the connection between your machine and the network module.
### Web/Pyodide Usage

```python
# 1. Serial connection (via USB), it's the default connection method
bundle = modi_plus.MODIPlus(connection_type="serialport")
# In Pyodide environment
import micropip
await micropip.install('pymodi-plus-web')

# 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")
from modi_plus_web import MODIPlusWeb

modi = MODIPlusWeb()
modi.set_send_callback(js_send_function)
# ... use like regular MODIPlus
```

List and create connected modules' object.
```python
# List connected modules
print(bundle.modules)
## Development

# List connected leds
print(bundle.leds)
```bash
# Install all packages in development mode
make install-all

# Pick the first led object from the bundle
led = bundle.leds[0]
# Run all tests
make test-monorepo

# Build all packages
make build-all
```

Let's blink the LED 5 times.
```python
import time
### Package-specific commands

for _ in range(5):
# turn on for 0.5 second
led.turn_on()
time.sleep(0.5)
```bash
# Core package
make install-core
make test-core
make build-core

# turn off for 0.5 second
led.turn_off()
time.sleep(0.5)
# Web package
make install-web
make test-web
make build-web
```

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
```
## Architecture

Additional Usage
----------------
To diagnose MODI+ modules (helpful to find existing malfunctioning modules),
```
$ python -m modi_plus --inspect
pymodi-plus/
├── packages/
│ ├── core/ # pymodi-plus (PyPI)
│ │ ├── modi_plus/ # Core library
│ │ ├── tests/
│ │ └── setup.py
│ └── web/ # pymodi-plus-web (PyPI)
│ ├── modi_plus_web/
│ ├── tests/
│ └── setup.py
├── docs/ # Documentation
├── Makefile # Monorepo commands
└── pyproject.toml # Root configuration
```

To initialize MODI+ modules implicitly (set `i` flag to enable REPL mode),
```
$ python -im modi_plus --initialize
```
## Documentation

To see what other commands are available,
```
$ python -m modi_plus --help
```
- [Quick Start Guide](./docs/getting-started/QUICKSTART.md)
- [Env Module RGB Features](./docs/features/ENV_RGB_FEATURE.md)
- [Development Guide](./docs/development/MAKEFILE_GUIDE.md)
- [Web Package README](./packages/web/README.md)

## Contributing

Documentation
-------------
📚 **Complete documentation is available in the [docs/](./docs/) folder.**

### Quick Links
- 🚀 [Quick Start Guide](./docs/getting-started/QUICKSTART.md) - Get up and running quickly
- ✨ [Env Module RGB Features](./docs/features/ENV_RGB_FEATURE.md) - New RGB sensor support (v2.x+)
- 🛠️ [Development Guide](./docs/development/MAKEFILE_GUIDE.md) - Build, test, and contribute
- 📦 [Deployment Guide](./docs/deployment/DEPLOY_GUIDE_KOREAN.md) - Release to PyPI
- 🐛 [Troubleshooting](./docs/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%)
- ✅ **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](./docs/project/HISTORY.md) for complete changelog.

Contributing
------------
We welcome contributions! Please see:
- [Contributing Guidelines](./docs/getting-started/CONTRIBUTING.md)
- [Code of Conduct](./docs/getting-started/CODE_OF_CONDUCT.md)
- [Development Guide](./docs/development/TESTS_README.md)

License
-------
## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Loading
Loading