Skip to content

Releases: vihaanvp/MegaWrapper

v0.2.2

Choose a tag to compare

@vihaanvp vihaanvp released this 04 Jul 07:48

Ponytail audit — deleted 4 files, ~103 lines removed. Module-level global replaced with constructor kwarg.

Removed

  • set_mode() / get_mode() — global module-level mode switch deleted. Replaced by Board(backend="pyfirmata2"|"pyserial") constructor kwarg. Default remains pyfirmata2.
  • megawrapper/version.py — version now sourced from importlib.metadata.version("megawrapper").
  • megawrapper/utils.py — delay() and millis() moved inline into __init__.py.
  • examples/tank_drive.py — removed (9 → 8 examples).
  • tests/test_exceptions.py — duplicated coverage.

Changed

  • Board.__init__(port, stby, backend="pyfirmata2") — backend kwarg replaces set_mode().
  • Board.__repr__ simplified with getattr instead of mode branching.
  • motor.py — forward() / backward() call self.set_speed(speed).
  • servo.py — _validate_and_clamp_angle removed; angle clamping inlined.
  • sensor.py — I2C init deduplicated into _default_i2c() helper.
  • __init__.py — delay() / millis() inline via stdlib time; version via importlib.metadata.
  • All docs (README, CHANGELOG, wiki, AGENTS) updated for new API.

Notes

  • 91 tests total (90 passing, 1 pre-existing env-related skip).
  • Net: ~103 source lines removed, 4 files deleted.

v0.2.1

Choose a tag to compare

@vihaanvp vihaanvp released this 04 Jul 07:12

Bug fix release — auto_address pin conversion, multi-sensor example.

Fixed

  • auto_address() now converts integer GPIO pins to board pin objects
    before passing to DigitalInOut (Blinka compatibility)
  • Test updated to verify pin-object conversion

Added

  • examples/vl53l0x_multi_sensor.py — multiple VL53L0X sensors via auto_address
  • VL53L0X API section in README

v0.2.0

Choose a tag to compare

@vihaanvp vihaanvp released this 04 Jul 05:07

v0.2.0 (2026-07-04)

Major refactor and stabilization release — type hints, dual Firmata backend, optional deps, sensor support.

Added

  • Full type hints on all public APIs: Board, Motor, Servo, VL53L0X, delay, millis, exceptions.
  • Board.__repr__ — shows serial port + motor count (pyserial mode only; graceful fallback for pyfirmata2).
  • Board.has_active_board() — static check without raising.
  • Servo.__repr__ — three states: "Servo(not attached)", "Servo(pin=X, angle=unknown)", "Servo(pin=X, angle=Y)".
  • Dual Firmata backend — set_mode("pyserial") / set_mode("pyfirmata2") global switch (must be called before Board()). Built-in pyserial client removes hard dependency on pyfirmata2.
  • VL53L0X time-of-flight sensor — VL53L0X class in megawrapper.sensor, I2C-based, independent of Firmata/Board.
  • Optional dependency groups in pyproject.toml:
    • pip install -e '.[pyserial]' — built-in Firmata backend
    • pip install -e '.[sensor]' — VL53L0X sensor
  • New examples:
    • examples/pyserial_control.py — demonstrates pyserial backend
    • examples/vl53l0x_sensor.py — ToF distance readout
  • PyPI publish workflow — .github/workflows/publish.yml triggers on GitHub release.
  • Tests expanded to 92 — new test_sensor.py, pyserial-mode tests in test_board.py.

Changed

  • pyproject.toml: pyserial and adafruit-circuitpython-vl53l0x moved from hard deps → optional extras. Only pyfirmata2 remains required.
  • README.md rewritten — wiki-centric, examples table with descriptions, concise API overview.
  • AGENTS.md rewritten — accurate test count, dependency structure, architecture traps, testing quirks.
  • .gitignore: 94 lines → 13 (only patterns matching this project).
  • Internal cleanup: inlined single-use imports, removed dead analog-write branch (pins >= 16 unused).

Removed

  • examples/servo_test.py (90% overlap with endless_sweep.py)
  • examples/endless_servo_sweep.py (redundant with Servo.sweep())
  • requirements.txt (duplicates pyproject.toml)
  • tests/__init__.py (empty file)

Notes

  • Requires Python 3.8+, Arduino running StandardFirmata.
  • Hard dependency: pyfirmata2 only. Optional: pyserial (backend), adafruit-circuitpython-vl53l0x (sensor).
  • Not yet on PyPI — install from source: pip install -e . (add .[pyserial] / .[sensor] for extras).

v0.1.0

Choose a tag to compare

@vihaanvp vihaanvp released this 25 Jun 13:31

Changelog

v0.1.0 (2026-06-25)

Initial release of MegaWrapper — a unified Python library for Arduino-style DC motor and servo control over Firmata.

Added

  • Board — manages a serial connection to an Arduino running StandardFirmata.

    • Constructor accepts port and optional stby (standby pin for TB6612FNG).
    • get_active_board() static method for servo singleton access.
    • attach_motor() to create and register motor instances.
    • stop_all() to halt all motors on the board.
    • wake() / sleep() for standby pin control.
    • close() for clean teardown.
    • Context manager support (with Board(...) as board).
    • board.motors list updated automatically.
  • Motor — DC motor control via H-bridge (2 direction pins + 1 PWM pin).

    • forward(speed) / backward(speed) with percentage-based speed (0–100).
    • stop() (coast) and brake() (abrupt halt).
    • set_speed() to change speed without affecting direction.
    • speed, direction, name properties.
    • Informative __repr__().
  • Servo — standard servo control on PWM-capable pins.

    • attach(pin) / detach() for lifecycle management.
    • write(angle) with automatic clamping to 0–180.
    • read() returning the last commanded angle.
    • move_smooth(target, delay_ms) for stepped rotation.
    • sweep(start, end, step, delay_ms) for continuous sweeping.
    • pin and current_angle properties.
  • Utilities — delay(ms) and millis() Arduino-style helpers.

  • Exceptions — clean error hierarchy:

    • MegaWrapperError (base)
    • InvalidSpeedError (speed outside 0–100)
    • BoardConnectionError (Arduino unreachable)
    • StandbyNotConfiguredError (STBY pin not set)
  • Package infrastructure:

    • pyproject.toml with setuptools build configuration.
    • All dependencies (pyfirmata2, pyserial) declared and auto-installed.
    • MIT license.
    • Editable install via pip install -e .
  • Documentation:

    • README.md with quick-start examples and links to the wiki.
    • GitHub Wiki with 8 dedicated pages: Home, Board API, Motor API, Servo API, Utilities, Exceptions, Examples, Edge Cases & Notes.
    • AGENTS.md for LLM session guidance.
    • CHANGELOG.md (this file).
  • Testing:

    • 72 unit tests across 6 files.
    • All tests mock pyfirmata2.Arduino — no hardware required.
    • conftest.py resets _active_board and provides fresh pin mocks per test.

Notes

  • Not published on PyPI — install from source.
  • Requires Python 3.8+, Arduino running StandardFirmata.
  • This release merges and supersedes motor-like-arduino (v0.1.0) and servo-like-arduino (v0.2.0).