Skip to main content

MicroPython distribution package for pysm

Project description

upysm

upysm is the MicroPython distribution channel for pysm, a finite state machine library.

Use pysm directly on regular Python. Use upysm when installing the same library on MicroPython.

The library source still belongs to pysm. upysm is not a fork and does not carry separate application code; it publishes MicroPython install artifacts from selected pysm releases.

Install on MicroPython

Modern mip/mpremote install:

mpremote mip install https://pgularski.github.io/upysm/

Pin a specific version when you want repeatable device builds:

mpremote mip install https://pgularski.github.io/upysm/0.4.0/

From the MicroPython REPL:

import mip
mip.install('https://pgularski.github.io/upysm/')

Legacy upip install:

import upip
upip.install('upysm')

The installed package imports as pysm, because the API is the upstream library API:

from pysm import Event, State, StateMachine

Example

from pysm import Event, State, StateMachine

on = State('on')
off = State('off')

sm = StateMachine('sm')
sm.add_state(on, initial=True)
sm.add_state(off)
sm.add_transition(on, off, events=['off'])
sm.add_transition(off, on, events=['on'])
sm.initialize()

assert sm.state == on
sm.dispatch(Event('off'))
assert sm.state == off
sm.dispatch(Event('on'))
assert sm.state == on

For the full API, see the pysm documentation.

Maintainer release notes live in RELEASING.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upysm-0.4.1.tar.gz (12.8 kB view details)

Uploaded Source

File details

Details for the file upysm-0.4.1.tar.gz.

File metadata

  • Download URL: upysm-0.4.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for upysm-0.4.1.tar.gz
Algorithm Hash digest
SHA256 b1dbba3c7509c9f1c26184f8eff118976fa9e0e77bd97ec86eff2806636e4d5d
MD5 3bf4a41a45cc738beabd542321c4752c
BLAKE2b-256 7c211b6c1b240844ffd904362cd13cee75e309465a25492a44d5686bf816c812

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page