usys: Add examples.

This commit is contained in:
Laurens Valk
2022-12-01 14:21:12 +01:00
parent 31d3872405
commit 553490874b
2 changed files with 14 additions and 6 deletions
+10
View File
@@ -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
+4 -6
View File
@@ -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.
"""