A template for projects using the Ardusimple SDK, a custom MicroPython firmware distribution with pre-installed utilities and hardware abstractions. The goal is to enhance developer experience (DX) and application development by integrating modern tooling like type hints, linter, formatter, testing and production build pipeline.
This template already contains stubs for extra modules shipped with the Ardusimple's firmware, as utoml and sdk.
Start a new project using this template. Fill up the pyproject.toml file with the information of your project.
Setup virtual environment and install dependencies and types with a single command:
make setupMake sure to have Black Formatter active in your IDE.
Run tests with a single make command
make testMicroPython macros and modules like machine are mocked in tests/conftest.py. Add additional module mocks as needed:
sys.modules['utime'] = MagicMock()
sys.modules['network'] = MagicMock()For specific assertions and function behavior, mock and patch in individual tests using unittest.
from unittest.mock import MagicMock, patch
from blink import Blinker
@patch('blink.ticks_diff')
def test_led_blink(ticks_diff):
"""Should blink pin 2s @ 1Hz"""
ticks_diff.side_effect = [0, 1000, 2000]
pin = MagicMock()
blinker = Blinker(pin=pin)
blinker.blink(time=2000, freq=1)
pin_values = [call.args[0] for call in pin.value.call_args_list]
assert pin.value.call_count == 4
assert pin_values == [1, 0, 1, 0]Your application can be compiled into .mpy files for better performance and memory usage when deployed on MicroPython devices.
Be sure you have mpy-cross and Make installed.
make build
make rebuild # Build a clean new version
make clean-build # Optional. Remove build directory