Name | ioemu JSON |
Version |
0.3.4
JSON |
| download |
home_page | https://tbs1-bo.github.io/ioemu/ |
Summary | IO Emulator with LEDs and buttons |
upload_time | 2024-11-30 09:23:14 |
maintainer | None |
docs_url | None |
author | Marco Bakera |
requires_python | <4.0,>=3.9 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ioemu
![screenshot](ioemu-screenshot.png)
The ioemu-project provides an emulator for input/output operations with simple electronic components like LEDs and push buttons.
## Installation and Upgrade
Use pip for a simple installation. For an update use `install --upgrade`.
- Linux, MacOS: `python3 -m pip install ioemu`
- Windows: `python -m pip install ioemu`
## Starting the emulator
First start the emulator by entering `ioemu` on the commandline. A Gui will show up.
![screenshot](ioemu-screenshot.png)
It contains a slider for analog values between 0 and 99, threee LEDs and two push buttons from left to right.
## LEDs
If the emulator is running, you can interact with it from any python program running on the same machine. First import the class `Emulator` from the `ioemu` package.
```python
from ioemu import Emulator
```
Now create an instance of the emulator and switch some LEDs on. They can be controlled by setting the `leds` attribute.
```python
emu = Emulator()
emu.leds = [True, False, True]
```
## Buttons
![screenshot](buttons.gif)
The emulator has two buttons. Their current state (pressed or not pressed) can be read from the attribute `buttons`. It's a bool array corresponding to the state of being pressed.
The following program lights up some LEDs depending on the button being pressed.
```python
emu = Emulator()
while True:
if emu.buttons[0]:
emu.leds = [False, True, True]
if emu.buttons[1]:
emu.leds = [True, True, False]
if not (emu.buttons[0] or emu.buttons[1]):
emu.leds = [False, False, False]
```
## Analog Value (0-99)
Let's look into a program that allows you to control the LEDs with the slider at the left. The current sliders value can be read from the `analog_value` attribute of the Emulator. Its value ranges from 0 to 99.
![image](analog_value.gif)
```python
import time
emu = Emulator()
led_on = 0
while True:
if 0 <= emu.analog_value < 25:
emu.leds = [False, False, False]
elif 25 <= emu.analog_value < 50:
emu.leds = [True, False, False]
elif 50 <= emu.analog_value < 75:
emu.leds = [True, True, False]
else:
emu.leds = [True, True, True]
```
## Demo
There is a demo program that can be started with `python -m ioemu.demo`. It will blink the LEDs and print the current button state as well as the analog value to console.
![demo](demo.gif)
You can find the source code in [demo.py](ioemu/demo.py).
## Bugs
If you find any bugs or have a feature request, feel free to file a ticket at the projects [bugtracker](https://github.com/tbs1-bo/ioemu/issues/new) on github.
Raw data
{
"_id": null,
"home_page": "https://tbs1-bo.github.io/ioemu/",
"name": "ioemu",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Marco Bakera",
"author_email": "marco@bakera.de",
"download_url": "https://files.pythonhosted.org/packages/af/5c/b7bbaac094be352c3167bdc354737a1d5aea1ab951e5e561629c4777d463/ioemu-0.3.4.tar.gz",
"platform": null,
"description": "\n# ioemu\n\n![screenshot](ioemu-screenshot.png)\n\nThe ioemu-project provides an emulator for input/output operations with simple electronic components like LEDs and push buttons.\n\n## Installation and Upgrade\n\nUse pip for a simple installation. For an update use `install --upgrade`. \n\n- Linux, MacOS: `python3 -m pip install ioemu`\n- Windows: `python -m pip install ioemu`\n\n## Starting the emulator\n\nFirst start the emulator by entering `ioemu` on the commandline. A Gui will show up.\n\n![screenshot](ioemu-screenshot.png)\n\nIt contains a slider for analog values between 0 and 99, threee LEDs and two push buttons from left to right.\n\n## LEDs\n\nIf the emulator is running, you can interact with it from any python program running on the same machine. First import the class `Emulator` from the `ioemu` package.\n\n\n```python\nfrom ioemu import Emulator\n```\n\nNow create an instance of the emulator and switch some LEDs on. They can be controlled by setting the `leds` attribute.\n\n\n```python\nemu = Emulator()\nemu.leds = [True, False, True]\n```\n\n## Buttons\n\n![screenshot](buttons.gif)\n\nThe emulator has two buttons. Their current state (pressed or not pressed) can be read from the attribute `buttons`. It's a bool array corresponding to the state of being pressed.\n\nThe following program lights up some LEDs depending on the button being pressed.\n\n\n```python\nemu = Emulator()\nwhile True:\n if emu.buttons[0]:\n emu.leds = [False, True, True]\n \n if emu.buttons[1]:\n emu.leds = [True, True, False]\n\n if not (emu.buttons[0] or emu.buttons[1]):\n emu.leds = [False, False, False]\n```\n\n## Analog Value (0-99)\n\nLet's look into a program that allows you to control the LEDs with the slider at the left. The current sliders value can be read from the `analog_value` attribute of the Emulator. Its value ranges from 0 to 99.\n\n![image](analog_value.gif)\n\n\n```python\nimport time\n\nemu = Emulator()\nled_on = 0\n\nwhile True:\n if 0 <= emu.analog_value < 25:\n emu.leds = [False, False, False]\n elif 25 <= emu.analog_value < 50:\n emu.leds = [True, False, False]\n elif 50 <= emu.analog_value < 75:\n emu.leds = [True, True, False]\n else:\n emu.leds = [True, True, True]\n```\n\n## Demo\n\nThere is a demo program that can be started with `python -m ioemu.demo`. It will blink the LEDs and print the current button state as well as the analog value to console.\n\n![demo](demo.gif)\n\nYou can find the source code in [demo.py](ioemu/demo.py).\n\n## Bugs\n\nIf you find any bugs or have a feature request, feel free to file a ticket at the projects [bugtracker](https://github.com/tbs1-bo/ioemu/issues/new) on github.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "IO Emulator with LEDs and buttons",
"version": "0.3.4",
"project_urls": {
"Homepage": "https://tbs1-bo.github.io/ioemu/",
"Repository": "https://github.com/tbs1-bo/ioemu"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "edac61c90f93aadaa833c4b6e7936f9068c2f29b9c81cfebb4055cbf121dfa7d",
"md5": "0c8e4ca203284915d24e790416832eee",
"sha256": "8df7895cfe545d41b3c87c071f09fdf6cccadcb2181a0b1eeb98fa53702564a9"
},
"downloads": -1,
"filename": "ioemu-0.3.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0c8e4ca203284915d24e790416832eee",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 30751,
"upload_time": "2024-11-30T09:23:12",
"upload_time_iso_8601": "2024-11-30T09:23:12.031161Z",
"url": "https://files.pythonhosted.org/packages/ed/ac/61c90f93aadaa833c4b6e7936f9068c2f29b9c81cfebb4055cbf121dfa7d/ioemu-0.3.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "af5cb7bbaac094be352c3167bdc354737a1d5aea1ab951e5e561629c4777d463",
"md5": "9acb4c59196cdb1aa6bf0284a37cdbd5",
"sha256": "9fdde8857fa3295ccbc889c46d578bef7268f23f5059bc2d36aca0e7087fc40c"
},
"downloads": -1,
"filename": "ioemu-0.3.4.tar.gz",
"has_sig": false,
"md5_digest": "9acb4c59196cdb1aa6bf0284a37cdbd5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 31674,
"upload_time": "2024-11-30T09:23:14",
"upload_time_iso_8601": "2024-11-30T09:23:14.178936Z",
"url": "https://files.pythonhosted.org/packages/af/5c/b7bbaac094be352c3167bdc354737a1d5aea1ab951e5e561629c4777d463/ioemu-0.3.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-30 09:23:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tbs1-bo",
"github_project": "ioemu",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ioemu"
}