acrome-lib
acrome-lib is a Python library for interfacing with the Acrome SMD Red hardware platform. It provides a high‑level SMDGateway class to manage the USB gateway and a collection of module wrappers for all supported add‑on devices (buttons, sensors, actuators, motors, etc.).
Features
-
Automatic module discovery (with fallback to
DEFAULT_MODULES) -
Convenient wrappers for:
- Digital inputs: Button, Joystick button
- Analog inputs: Potentiometer, QTR line sensor array, Light sensor, Distance sensor, IMU (accelerometer & gyroscope)
- Actuators: RGB LED, Buzzer, Motor (PWM, velocity, position, torque)
-
Extensible: easily add new module types by following the wrapper pattern
-
Built‑in testing: standalone test scripts under
tests/ensure compatibility
Installation
-
Clone this repository:
git clone https://github.com/MehmetBener/acrome-lib.git cd acrome-lib
-
(Optional) Install in editable mode:
pip install -e .
-
Ensure you have the Acrome Python SDK (
smd.red) installed via pip and your USB gateway drivers.
Usage
1. Initialize the Gateway
from smd_gateway import SMDGateway
from lib.usb_port_finder import USBPortFinder
# Auto‑detect the USB gateway
port = USBPortFinder.first_gateway()
if port is None:
raise RuntimeError("No USB gateway connected")
# Create gateway (overriding auto‑scan with DEFAULT_MODULES)
gw = SMDGateway(port, modules_override=None)
2. Create and Use Module Wrappers
from lib.button import Button
from lib.led import Led
from lib.distance import DistanceSensor
# ... other wrappers ...
# Example: Button on module index 0 (Button_5)
btn = Button(gw, module_id=0)
if btn.is_pressed():
print("Button pressed!")
# Example: Blink LED (module index 7 = RGB_5)
led = Led(gw, module_id=7)
led.blink(on_rgb=(0,255,0), off_rgb=(0,0,0), period=0.3, cycles=5)
# Example: Read distance (module index 4 = Distance_1)
dist = DistanceSensor(gw, module_id=4)
print("Distance (cm):", dist.read_cm())
3. Motor Control
from lib.motor import Motor
from smd.red import OperationMode
motor = Motor(gw, cpr=6533)
# PWM control
motor.run_pwm(duty=50, duration_s=1.0)
# Velocity control
motor.set_operation_mode(OperationMode.Velocity)
motor.enable_torque(True)
motor.set_shaft_rpm(120)
# Cleanup
gw.close()
Testing
All module wrappers include standalone test scripts under tests/. To run tests:
cd acrome-lib
# Example: test the QTR sensor wrapper
env/bin/python tests/test_qtr.py
Each script auto‑adds the project root to PYTHONPATH and uses modules_override to fix module IDs.
Contributing
- Fork the repository.
- Create a feature branch:
git checkout -b feature/YourFeature. - Commit your changes:
git commit -m "Add your feature". - Push to your fork:
git push origin feature/YourFeature. - Open a Pull Request.
Please run existing tests and add new ones for any functionality you introduce.
License
This project is licensed under the MIT License. See LICENSE for details.
Metadata
Release files for acrome-smd-python 0.1.0
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 |
|---|---|---|---|---|
| acrome_smd_python-0.1.0.tar.gz | 3.6 kB | Without provenance | Details for acrome_smd_python-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| acrome_smd_python-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for acrome_smd_python-0.1.0-py3-none-any.whl |
Total release size: 7.3 kB
Release files / acrome_smd_python-0.1.0.tar.gz
| Download URL | acrome_smd_python-0.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d458e993ebbbb71aa0feb5db9c8453f3f8354c7d1717197a0697ec9b1610cd9f
|
|
BLAKE2b-256 checksum How to use checksums |
3f20ec41f7ea522ebfb51e3546f5bddaff23244509710c06a8090433a8214760
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Release files / acrome_smd_python-0.1.0-py3-none-any.whl
| Download URL | acrome_smd_python-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70f8a98357dcdc700b2f957891f20bb8a850be77494ac9d43ffe745490293d27
|
|
BLAKE2b-256 checksum How to use checksums |
b35f9f25e7d1670c95e87c3c7ad9d71ef9e5323cbe44240c40f0f3bad195caa6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Security for acrome-smd-python 0.1.0
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.