ioemu
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.
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.
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.
emu = Emulator()
emu.leds = [True, False, True]
Buttons
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.
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.
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.
You can find the source code in demo.py.
Bugs
If you find any bugs or have a feature request, feel free to file a ticket at the projects bugtracker on github.
Metadata
Release files for ioemu 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ioemu-0.3.4.tar.gz | 31.7 kB | Without provenance | Details for ioemu-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ioemu-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for ioemu-0.3.4-py3-none-any.whl |
Total release size: 62.4 kB
Release files / ioemu-0.3.4.tar.gz
| Download URL | ioemu-0.3.4.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fdde8857fa3295ccbc889c46d578bef7268f23f5059bc2d36aca0e7087fc40c
|
|
BLAKE2b-256 checksum How to use checksums |
af5cb7bbaac094be352c3167bdc354737a1d5aea1ab951e5e561629c4777d463
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Linux/5.10.226-1-MANJARO
|
Release files / ioemu-0.3.4-py3-none-any.whl
| Download URL | ioemu-0.3.4-py3-none-any.whl |
|---|---|
| Size | 30.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8df7895cfe545d41b3c87c071f09fdf6cccadcb2181a0b1eeb98fa53702564a9
|
|
BLAKE2b-256 checksum How to use checksums |
edac61c90f93aadaa833c4b6e7936f9068c2f29b9c81cfebb4055cbf121dfa7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Linux/5.10.226-1-MANJARO
|
Security for ioemu 0.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.