{"id":15611603,"url":"https://github.com/pgularski/upysm","last_synced_at":"2025-04-28T12:21:39.063Z","repository":{"id":72864545,"uuid":"163832503","full_name":"pgularski/upysm","owner":"pgularski","description":"Versatile and flexible Python State Machine library - Micropython Port","archived":false,"fork":false,"pushed_at":"2019-01-02T17:18:09.000Z","size":6,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T09:31:32.850Z","etag":null,"topics":["finite-state-machine","fsm","fsm-library","micropython","micropython-esp32","mit-license","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgularski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-02T11:28:40.000Z","updated_at":"2024-10-02T14:41:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"2bdfd1c4-3f9c-4bfb-9ee0-9f3f8979436e","html_url":"https://github.com/pgularski/upysm","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"60331406f200c7609f55a37da343cd47795b08f7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fupysm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fupysm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fupysm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fupysm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgularski","download_url":"https://codeload.github.com/pgularski/upysm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251311341,"owners_count":21569011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finite-state-machine","fsm","fsm-library","micropython","micropython-esp32","mit-license","python"],"created_at":"2024-10-03T06:05:44.157Z","updated_at":"2025-04-28T12:21:39.045Z","avatar_url":"https://github.com/pgularski.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# upysm\nVersatile and flexible Python State Machine library - Micropython Port\n\nThis repository is basically a set of tools to build and deploy (to pypi) the\nMicropython Port of the [pysm](https://github.com/pgularski/pysm) library.\n\nIt's successfully tested against the ESP-32S ESP-WROOM-32 NodeMCU board.\n\n# Installation\n\n```python\nimport upip\nupip.install('upysm')\n```\n\n# Usage\nBasic usage:\n\n```python\nimport machine\nimport time\nfrom pysm import State, StateMachine, Event\n\nled = machine.Pin(2, machine.Pin.OUT)\n\n\ndef on_enter(state, event):\n    led.value(1)\n    time.sleep(0.1)\n\ndef on_exit(state, event):\n    led.value(0)\n    time.sleep(0.1)\n\non = State('on')\noff = State('off')\n\nsm = StateMachine('sm')\nsm.add_state(on, initial=True)\nsm.add_state(off)\n\nsm.add_transition(on, off, events=['off'])\nsm.add_transition(off, on, events=['on'])\n\non.handlers = {'enter': on_enter, 'exit': on_exit}\noff.handlers = {'enter': on_enter, 'exit': on_exit}\n\nsm.initialize()\n\nassert sm.state == on\nsm.dispatch(Event('off'))\nassert sm.state == off\nsm.dispatch(Event('on'))\nassert sm.state == on\n\n```\n\nFor more examples and API description refer to the [pysm documentation](http://pysm.readthedocs.io/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgularski%2Fupysm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgularski%2Fupysm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgularski%2Fupysm/lists"}