diff --git a/doc/main/micropython/usys.rst b/doc/main/micropython/usys.rst index e14f9bb..aabfe84 100644 --- a/doc/main/micropython/usys.rst +++ b/doc/main/micropython/usys.rst @@ -16,4 +16,14 @@ This MicroPython module is a subset of the `sys module`_ in Python. .. autodata:: usys.stderr :annotation: +Examples +--------------- + +The ``stdin`` stream can be used to capture input via the Pybricks Code +input/output window. See the `keyboard input`_ project to learn how this works. +This approach can be extended to exchange data with any `other device`_ as well. + +.. _keyboard input: https://pybricks.com/projects/tutorials/wireless/hub-to-device/pc-keyboard/ +.. _other device: https://pybricks.com/projects/tutorials/wireless/hub-to-device/ + .. _sys module: https://docs.python.org/3.5/library/sys.html diff --git a/src/usys/__init__.py b/src/usys/__init__.py index 70f1d46..0f0cf6d 100644 --- a/src/usys/__init__.py +++ b/src/usys/__init__.py @@ -11,14 +11,12 @@ This module provides a subset of the standard Python ``sys`` module. from uio import FileIO as _FileIO -# REVISIT: most functions are excluded since they aren't useful for Pybricks - stdin: _FileIO = _FileIO() """ -Stream object (:class:`uio.FileIO`) that receives input from a connected +This is a stream object (:class:`uio.FileIO`) that receives input from a connected terminal, if any. -Writing may modify newline characters. Use ``usys.stdin.buffer`` instead if +Writing may modify newline characters. Use ``stdin.buffer`` instead if this is undesirable. Also see :func:`micropython.kbd_intr` to disable ``KeyboardInterrupt`` if you @@ -27,10 +25,10 @@ are passing binary data via ``stdin``. stdout: _FileIO = _FileIO() """ -Stream object (:class:`uio.FileIO`) that sends output to a connected terminal, +This is a stream object (:class:`uio.FileIO`) that sends output to a connected terminal, if any. -Reading may modify newline characters. Use ``usys.stdout.buffer`` instead if +Reading may modify newline characters. Use ``stdout.buffer`` instead if this is undesirable. """