https://github.com/niklasf/python-asyncdgt
Communicate asynchronously with DGT boards
https://github.com/niklasf/python-asyncdgt
Last synced: about 1 year ago
JSON representation
Communicate asynchronously with DGT boards
- Host: GitHub
- URL: https://github.com/niklasf/python-asyncdgt
- Owner: niklasf
- License: gpl-3.0
- Created: 2015-09-13T11:40:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T19:53:47.000Z (over 3 years ago)
- Last Synced: 2025-03-26T15:42:26.914Z (about 1 year ago)
- Language: Python
- Homepage: http://pythonhosted.org/asyncdgt/
- Size: 83 KB
- Stars: 15
- Watchers: 4
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
asyncdgt: Communicate asynchronously with DGT boards
====================================================
asyncdgt uses asyncio to communicate asynchronously with a DGT electronic
chess board.
`View reference documentation `_.
.. image:: https://badge.fury.io/py/asyncdgt.svg
:target: https://pypi.python.org/pypi/asyncdgt
.. image:: https://travis-ci.org/niklasf/python-asyncdgt.svg
:target: https://travis-ci.org/niklasf/python-asyncdgt
Example
-------
Create an event loop and a connection to the DGT board.
.. code:: python
import asyncio
loop = asyncio.get_event_loop()
dgt = asyncdgt.auto_connect(loop, ["/dev/ttyACM*"])
Register some `pyee `__ event handlers. They
will be called whenever a board gets connected, disconnected or the position
changed.
.. code:: python
@dgt.on("connected")
def on_connected(port):
print("Board connected to {0}!".format(port))
@dgt.on("disconnected")
def on_disconnected():
print("Board disconnected!")
@dgt.on("board")
def on_board(board):
print("Position changed:")
print(board)
print()
Get some information outside of an event handler using the coroutine
``get_version()``.
.. code:: python
print("Version:", loop.run_until_complete(dgt.get_version()))
Run the event loop.
.. code:: python
try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
dgt.close()
loop.close()
See ``asyncdgt/__main__.py`` for the complete example. Run with
``python -m asyncdgt /dev/ttyACM0``.
Hardware
--------
Tested with the following boards:
* DGT e-Board 3.1
* DGT e-Board 3.1 Bluetooth
Clocks:
* DGT Clock 3000
Dependencies
------------
* Python 3.4
* `pyee `__
* `pyserial `_
``pip install -r requirements.txt``
Related projects
----------------
* `python-chess `_,
a general purpose chess library.
* `picochess `_,
a standalone chess computer for DGT boards. Some of the DGT protocol handling
has been shamelessly extracted from their code.
License
-------
python-asyncdtg is licensed under the GPL3. See the ``LICENSE.txt`` file for
the full license text.