@@ -21,7 +21,7 @@ Introduction
21
21
:target: https://github.com/psf/black
22
22
:alt: Code Style: Black
23
23
24
- Slimmed down implementation of prompt_toolkit for CircuitPython
24
+ Slimmed down implementation of ` prompt_toolkit < https://github.com/prompt-toolkit/python-prompt-toolkit >`_ for CircuitPython
25
25
26
26
27
27
Dependencies
@@ -36,39 +36,13 @@ This is easily achieved by downloading
36
36
or individual libraries can be installed using
37
37
`circup <https://github.com/adafruit/circup >`_.
38
38
39
- .. todo :: Describe the Adafruit product this library works with. For PCBs, you can also add the
40
- image from the assets folder in the PCB's GitHub repo.
41
-
42
- `Purchase one from the Adafruit shop <http://www.adafruit.com/products/ >`_
43
39
Installing from PyPI
44
40
=====================
45
- .. note :: This library is not available on PyPI yet. Install documentation is included
46
- as a standard element. Stay tuned for PyPI availability!
47
-
48
- .. todo :: Remove the above note if PyPI version is/will be available at time of release.
49
-
50
- On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
51
- PyPI <https://pypi.org/project/adafruit-circuitpython-prompt-toolkit/> `_.
52
- To install for current user:
53
-
54
- .. code-block :: shell
55
-
56
- pip3 install adafruit-circuitpython-prompt-toolkit
57
-
58
- To install system-wide (this may be required in some cases):
59
-
60
- .. code-block :: shell
61
-
62
- sudo pip3 install adafruit-circuitpython-prompt-toolkit
63
41
64
- To install in a virtual environment in your current project:
65
-
66
- .. code-block :: shell
67
-
68
- mkdir project-name && cd project-name
69
- python3 -m venv .venv
70
- source .env/bin/activate
71
- pip3 install adafruit-circuitpython-prompt-toolkit
42
+ This library is available in PyPI for CircuitPython tools that need it. If you
43
+ actually want to use it on CPython (not CircuitPython), then we recommend the
44
+ full `prompt_toolkit <https://github.com/prompt-toolkit/python-prompt-toolkit >`_
45
+ library that is also on PyPI.
72
46
73
47
Installing to a Connected CircuitPython Device with Circup
74
48
==========================================================
@@ -96,8 +70,25 @@ Or the following command to update an existing version:
96
70
Usage Example
97
71
=============
98
72
99
- .. todo :: Add a quick, simple example. It and other examples should live in the
100
- examples folder and be included in docs/examples.rst.
73
+ .. code-block :: python
74
+
75
+ # This example works over the second CDC and supports history.
76
+
77
+ import usb_cdc
78
+
79
+ # Rename import to make the rest of the code compatible with CPython's prompt_toolkit library.
80
+ import adafruit_prompt_toolkit as prompt_toolkit
81
+
82
+ # If the second CDC is available, then use it instead.
83
+ serial = usb_cdc.console
84
+ if usb_cdc.data:
85
+ serial = usb_cdc.data
86
+
87
+ session = prompt_toolkit.PromptSession(input = serial, output = serial)
88
+
89
+ while True :
90
+ response = prompt_toolkit.prompt(" $ " )
91
+ print (" ->" , response, file = serial)
101
92
102
93
Documentation
103
94
=============
0 commit comments