Skip to content

Commit 125e4db

Browse files
committed
Fix up docs
1 parent e8aeb9e commit 125e4db

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed

README.rst

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ Installing from PyPI
3535
.. note:: This library is not available on PyPI yet. Install documentation is included
3636
as a standard element. Stay tuned for PyPI availability!
3737

38-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
39-
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
40-
4138
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
4239
PyPI <https://pypi.org/project/adafruit-circuitpython-ble_midi/>`_. To install for current user:
4340

@@ -63,7 +60,55 @@ To install in a virtual environment in your current project:
6360
Usage Example
6461
=============
6562

66-
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
63+
.. code-block:: python
64+
65+
"""
66+
This example sends MIDI out. It sends NoteOn and then NoteOff with a random pitch bend.
67+
"""
68+
69+
import time
70+
import random
71+
import adafruit_ble
72+
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
73+
import adafruit_ble_midi
74+
import adafruit_midi
75+
from adafruit_midi.control_change import ControlChange
76+
from adafruit_midi.note_off import NoteOff
77+
from adafruit_midi.note_on import NoteOn
78+
from adafruit_midi.pitch_bend import PitchBend
79+
80+
# Use default HID descriptor
81+
midi_service = adafruit_ble_midi.MIDIService()
82+
advertisement = ProvideServicesAdvertisement(midi_service)
83+
# advertisement.appearance = 961
84+
85+
ble = adafruit_ble.BLERadio()
86+
if ble.connected:
87+
for c in ble.connections:
88+
c.disconnect()
89+
90+
midi = adafruit_midi.MIDI(midi_out=midi_service, out_channel=0)
91+
92+
print("advertising")
93+
ble.start_advertising(advertisement)
94+
95+
while True:
96+
print("Waiting for connection")
97+
while not ble.connected:
98+
pass
99+
print("Connected")
100+
while ble.connected:
101+
midi.send(NoteOn(44, 120)) # G sharp 2nd octave
102+
time.sleep(0.25)
103+
a_pitch_bend = PitchBend(random.randint(0, 16383))
104+
midi.send(a_pitch_bend)
105+
time.sleep(0.25)
106+
# note how a list of messages can be used
107+
midi.send([NoteOff("G#2", 120), ControlChange(3, 44)])
108+
time.sleep(0.5)
109+
print("Disconnected")
110+
print()
111+
ble.start_advertising(advertisement)
67112
68113
Contributing
69114
============

docs/index.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
27-
the toctree above for use later.
28-
2926
.. toctree::
3027
:caption: Related Products
3128

32-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
33-
the toctree above for use later.
29+
Circuit Playground Bluefruit <https://www.adafruit.com/product/4333>
30+
Adafruit CLUE nRF52840 Express <https://www.adafruit.com/product/4500>
3431

3532
.. toctree::
3633
:caption: Other Links

0 commit comments

Comments
 (0)