mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 17:14:41 +00:00
usys: Add examples.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user