btbricks 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. btbricks-0.2.1/.readthedocs.yaml +23 -0
  2. btbricks-0.2.1/CHANGELOG.md +41 -0
  3. btbricks-0.2.1/LICENSE +21 -0
  4. btbricks-0.2.1/MANIFEST.in +8 -0
  5. btbricks-0.2.1/PKG-INFO +232 -0
  6. btbricks-0.2.1/README.md +193 -0
  7. btbricks-0.2.1/btbricks/__init__.py +52 -0
  8. btbricks-0.2.1/btbricks/bt.py +1197 -0
  9. btbricks-0.2.1/btbricks/bthub.py +218 -0
  10. btbricks-0.2.1/btbricks/ctrl_plus.py +8 -0
  11. btbricks-0.2.1/btbricks.egg-info/PKG-INFO +232 -0
  12. btbricks-0.2.1/btbricks.egg-info/SOURCES.txt +44 -0
  13. btbricks-0.2.1/btbricks.egg-info/dependency_links.txt +1 -0
  14. btbricks-0.2.1/btbricks.egg-info/requires.txt +12 -0
  15. btbricks-0.2.1/btbricks.egg-info/top_level.txt +2 -0
  16. btbricks-0.2.1/docs/Makefile +13 -0
  17. btbricks-0.2.1/docs/conf.py +29 -0
  18. btbricks-0.2.1/docs/index.rst +14 -0
  19. btbricks-0.2.1/examples/ble-midi-esp/main.py +31 -0
  20. btbricks-0.2.1/examples/ble_uart_light_matrix_client.py +24 -0
  21. btbricks-0.2.1/examples/ble_uart_light_matrix_server.py +20 -0
  22. btbricks-0.2.1/examples/ble_uart_simple_central.py +19 -0
  23. btbricks-0.2.1/examples/ble_uart_simple_peripheral.py +20 -0
  24. btbricks-0.2.1/examples/inventor_ble_midi_guitar.py +110 -0
  25. btbricks-0.2.1/examples/midi_controller_example.py +56 -0
  26. btbricks-0.2.1/examples/rc_batmobile_spike_wheel.py +50 -0
  27. btbricks-0.2.1/examples/rc_extreme_offroader_spike_wheel.py +45 -0
  28. btbricks-0.2.1/examples/rc_hotrod_car_receiver.py +38 -0
  29. btbricks-0.2.1/examples/rc_hotrod_transmitter.py +54 -0
  30. btbricks-0.2.1/examples/rc_mecanum_wheels.py +45 -0
  31. btbricks-0.2.1/examples/rc_multi_snake_head.py +103 -0
  32. btbricks-0.2.1/examples/rc_multi_snake_seg_1.py +60 -0
  33. btbricks-0.2.1/examples/rc_receiver_example.py +61 -0
  34. btbricks-0.2.1/examples/rc_snake.py +66 -0
  35. btbricks-0.2.1/examples/rc_snake_with_simple_remote.py +91 -0
  36. btbricks-0.2.1/examples/rc_snake_with_spike_steering_wheel.py +90 -0
  37. btbricks-0.2.1/examples/rc_transmitter_example.py +63 -0
  38. btbricks-0.2.1/examples/uart_central_example.py +52 -0
  39. btbricks-0.2.1/examples/uart_peripheral_example.py +45 -0
  40. btbricks-0.2.1/pyproject.toml +61 -0
  41. btbricks-0.2.1/setup.cfg +4 -0
  42. btbricks-0.2.1/setup.py +76 -0
  43. btbricks-0.2.1/tests/__init__.py +1 -0
  44. btbricks-0.2.1/tests/test_bthub.py +102 -0
  45. btbricks-0.2.1/tests/test_constants.py +77 -0
  46. btbricks-0.2.1/tests/test_imports.py +94 -0
@@ -0,0 +1,23 @@
1
+ # Read the Docs configuration file
2
+
3
+ version: 2
4
+
5
+ build:
6
+ os: "ubuntu-20.04"
7
+ tools:
8
+ python: "3.10"
9
+
10
+ python:
11
+ version: 3.10
12
+ install:
13
+ - method: pip
14
+ path: .
15
+ extra_requirements:
16
+ - dev
17
+
18
+ sphinx:
19
+ configuration: docs/conf.py
20
+
21
+ formats:
22
+ - pdf
23
+ - epub
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial project setup
12
+ - Hub discovery and connection
13
+ - Message sending and receiving
14
+ - Protocol definitions for LEGO Bluetooth
15
+ - Comprehensive documentation with Sphinx
16
+ - Example scripts for common use cases
17
+ - Unit tests with pytest
18
+ - CI/CD pipeline with GitHub Actions
19
+
20
+ ### Changed
21
+
22
+ ### Deprecated
23
+
24
+ ### Removed
25
+
26
+ ### Fixed
27
+
28
+ ### Security
29
+
30
+ ## [0.1.0] - 2025-12-14
31
+
32
+ ### Added
33
+ - Initial release of btbricks
34
+ - Core Hub class for Bluetooth communication
35
+ - HubScanner for discovering LEGO hubs
36
+ - Protocol module with LEGO BT protocol implementation
37
+ - Exception hierarchy for error handling
38
+ - API documentation
39
+ - Quick start guide
40
+ - Development guide
41
+ - Examples for hub discovery, control, linking, and sensor reading
btbricks-0.2.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 btbricks contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include pyproject.toml
5
+ include .readthedocs.yaml
6
+ recursive-include docs *.rst *.py
7
+ recursive-include docs Makefile make.bat
8
+ recursive-include examples *.py
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.4
2
+ Name: btbricks
3
+ Version: 0.2.1
4
+ Summary: A MicroPython Bluetooth library for remote controlling LEGO hubs via BLE
5
+ Home-page: https://github.com/antonvh/btbricks
6
+ Author: Anton Vanhoucke
7
+ Author-email: Anton Vanhoucke <anton@antonsmindstorms.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/antonvh/btbricks
10
+ Project-URL: Documentation, https://docs.antonsmindstorms.com/en/latest/Software/btbricks/docs/index.html
11
+ Project-URL: Repository, https://github.com/antonvh/btbricks.git
12
+ Project-URL: Issues, https://github.com/antonvh/btbricks/issues
13
+ Keywords: micropython,bluetooth,ble,lego,hub,control
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Education
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: Implementation :: MicroPython
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Hardware
22
+ Requires-Python: >=3.7
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == "dev"
27
+ Requires-Dist: pytest-asyncio>=0.20.0; extra == "dev"
28
+ Requires-Dist: black>=23.0; extra == "dev"
29
+ Requires-Dist: flake8>=5.0; extra == "dev"
30
+ Requires-Dist: mypy>=1.0; extra == "dev"
31
+ Provides-Extra: docs
32
+ Requires-Dist: sphinx>=4.0; extra == "docs"
33
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
34
+ Requires-Dist: sphinx-autodoc-typehints>=1.12; extra == "docs"
35
+ Dynamic: author
36
+ Dynamic: home-page
37
+ Dynamic: license-file
38
+ Dynamic: requires-python
39
+
40
+ # btbricks
41
+
42
+ <img alt="btbricks logo" src="https://raw.githubusercontent.com/antonvh/btbricks/master/img/btbricks.png" width="200">
43
+
44
+ [![PyPI Version](https://img.shields.io/pypi/v/btbricks.svg)](https://pypi.org/project/btbricks/)
45
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
46
+ [![MicroPython](https://img.shields.io/badge/MicroPython-compatible-orange.svg)](https://micropython.org/)
47
+
48
+ A MicroPython Bluetooth library. It implements BLE (Bluetooth 5, Bluetooth Low Energy). Of the know BLE services, this library implements Nordic Uart Service (NUS), LEGO Service and MIDI service. The library contains both the BLE Central (client) and BLE Peripheral (server) classes.
49
+
50
+ These BLE services allow for controlling LEGO hubs, running official firmware. The services also allow creating custom Bluetooth peripherals: RC controllers, MIDI devices, etc. To control the LEGO hubs, you can best use a [hub expansion board, like the LMS-ESP32](https://www.antonsmindstorms.com/product/wifi-python-esp32-board-for-mindstorms/).
51
+
52
+ ## Table of Contents
53
+
54
+ - [Features](#features)
55
+ - [Installation](#installation)
56
+ - [Quick Start](#quick-start)
57
+ - [Documentation](#documentation-and-api-reference)
58
+ - [Supported Platforms](#supported-platforms)
59
+ - [Firmware Notes](#firmware-notes)
60
+ - [License](#license)
61
+ - [Author](#author)
62
+
63
+ ## Features
64
+
65
+ - 🔌 **BLE Communication**: Comprehensive Bluetooth Low Energy support via MicroPython's `ubluetooth`
66
+ - 🎮 **Hub Control**: Control LEGO MINDSTORMS hubs, SPIKE sets, and smart hubs over Bluetooth
67
+ - 📱 **Custom Peripherals**: Create RC controllers, MIDI controllers, and other BLE peripherals compatible with LEGO hubs
68
+ - 🚀 **MicroPython Ready**: Optimized for MicroPython on ESP32, LEGO SPIKE, and other platforms
69
+ - 📡 **LEGO Protocol**: Full support for LEGO Bluetooth protocols (LPF2, LPUP, CTRL+)
70
+ - 🎛️ **Multiple Interfaces**: Nordic UART, MIDI, RC control, and native LEGO hub communication
71
+ - ⚙️ **Advanced BLE**: Automatic MTU negotiation, descriptor handling, and efficient payload management
72
+
73
+ ## Installation
74
+
75
+ ### On LMS-ESP32
76
+
77
+ The module should be included in the latest Micropython firmware from <https://wwww.antonsmindstorms.com>. If not, use ViperIDE or Thonny and create a new file called rcservo.py.
78
+ Copy the contents from the same file in this repository inside.
79
+
80
+ ### On MicroPython device using `micropip` from PyPI
81
+
82
+ ```python
83
+ import micropip
84
+ await micropip.install("btbricks")
85
+ ```
86
+
87
+ Note: `micropip` must be available on the target board and may require an internet connection from the device.
88
+
89
+ ### On SPIKE Legacy or MINDSTORMS Robot Inventor
90
+
91
+ Use the installer script in mpy-robot-tools: <https://github.com/antonvh/mpy-robot-tools/blob/master/Installer/install_mpy_robot_tools.py>
92
+
93
+ ## Quick Start
94
+
95
+ ### Connect to a LEGO Hub
96
+
97
+ ```python
98
+ from btbricks import BtHub
99
+
100
+ # Create hub instance
101
+ hub = BtHub()
102
+
103
+ # Connect to a nearby hub
104
+ hub.connect()
105
+
106
+ if hub.is_connected():
107
+ # Set hub LED to green
108
+ hub.set_led_color(6) # GREEN constant
109
+
110
+ # Read accelerometer data
111
+ acc = hub.acc()
112
+ if acc:
113
+ print(f"Accelerometer: {acc}")
114
+
115
+ # Control motor on port A with 50% power
116
+ hub.dc("A", 50)
117
+
118
+ hub.disconnect()
119
+ ```
120
+
121
+ ### Create an RC Receiver (Hub-side)
122
+ Use the examples in the `examples/` folder for full, runnable code. Minimal receiver/transmitter snippets:
123
+
124
+ ```python
125
+ from btbricks import RCReceiver, R_STICK_HOR, R_STICK_VER
126
+ from time import sleep_ms
127
+
128
+ # Create RC receiver (advertises as "robot" by default)
129
+ rcv = RCReceiver(name="robot")
130
+
131
+ print("Waiting for RC transmitter to connect...")
132
+ try:
133
+ while True:
134
+ if rcv.is_connected():
135
+ steering = rcv.controller_state(R_STICK_HOR)
136
+ throttle = rcv.controller_state(R_STICK_VER)
137
+ print(f"Steering: {steering}, Throttle: {throttle}")
138
+ sleep_ms(100)
139
+ else:
140
+ sleep_ms(500)
141
+ except KeyboardInterrupt:
142
+ rcv.disconnect()
143
+ ```
144
+
145
+ ```python
146
+ from btbricks import RCTransmitter, L_STICK_HOR, R_STICK_VER
147
+ from time import sleep
148
+
149
+ # Create RC transmitter (central)
150
+ tx = RCTransmitter()
151
+
152
+ if tx.connect(name="robot"):
153
+ try:
154
+ while tx.is_connected():
155
+ # Set stick values in range [-100, 100]
156
+ tx.set_stick(L_STICK_HOR, 0)
157
+ tx.set_stick(R_STICK_VER, 50)
158
+ tx.transmit()
159
+ sleep(0.1)
160
+ except KeyboardInterrupt:
161
+ tx.disconnect()
162
+ ```
163
+
164
+ ### Create a MIDI Controller
165
+
166
+ ```python
167
+ from btbricks import MidiController
168
+ from time import sleep
169
+
170
+ # Create MIDI controller (advertises as "amh-midi" by default)
171
+ midi = MidiController(name="amh-midi")
172
+
173
+ print("MIDI controller started, connect from your DAW...")
174
+
175
+ try:
176
+ while True:
177
+ # Send MIDI note on: middle C (note 60), velocity 100
178
+ midi.note_on(60, 100)
179
+ sleep(0.5)
180
+
181
+ # Send MIDI note off
182
+ midi.note_off(60)
183
+ sleep(0.5)
184
+
185
+ # Or send a chord
186
+ midi.chord_on("C4", velocity=100, style="M") # C major chord
187
+ sleep(1)
188
+ midi.note_off(60) # Stop the chord
189
+
190
+ except KeyboardInterrupt:
191
+ print("MIDI controller stopped")
192
+ ```
193
+
194
+ ## Documentation and API reference
195
+
196
+ See the full documentation and API reference at:
197
+
198
+ https://docs.antonsmindstorms.com/en/latest/Software/btbricks/docs/index.html
199
+
200
+ ### Core Classes
201
+
202
+ - `BLEHandler`: Low-level Bluetooth communication
203
+ - `UARTCentral`: Nordic UART client mode
204
+ - `UARTPeripheral`: Nordic UART server mode
205
+ - `RCReceiver`: Receive RC control signals
206
+ - `RCTransmitter`: Send RC control signals
207
+ - `MidiController`: Send MIDI commands over BLE
208
+ - `BtHub`: High-level hub communication interface
209
+
210
+ ### Control Constants
211
+
212
+ - Sticks: `L_STICK_HOR`, `L_STICK_VER`, `R_STICK_HOR`, `R_STICK_VER`
213
+ - Triggers: `L_TRIGGER`, `R_TRIGGER`
214
+ - Buttons: `BUTTONS`
215
+ - Settings: `SETTING1`, `SETTING2`
216
+
217
+ ## Supported Platforms
218
+
219
+ - **LEGO MINDSTORMS EV3** (with MicroPython firmware)
220
+ - **LEGO SPIKE Prime/Prime Essential** (with MINDSTORMS firmware)
221
+ - **LEGO SPIKE Robot Inventor**
222
+ - **ESP32** with MicroPython
223
+ - Other MicroPython boards with `ubluetooth` support
224
+
225
+
226
+ ## License
227
+
228
+ MIT License
229
+
230
+ ## Author
231
+
232
+ Anton Vanhoucke
@@ -0,0 +1,193 @@
1
+ # btbricks
2
+
3
+ <img alt="btbricks logo" src="https://raw.githubusercontent.com/antonvh/btbricks/master/img/btbricks.png" width="200">
4
+
5
+ [![PyPI Version](https://img.shields.io/pypi/v/btbricks.svg)](https://pypi.org/project/btbricks/)
6
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+ [![MicroPython](https://img.shields.io/badge/MicroPython-compatible-orange.svg)](https://micropython.org/)
8
+
9
+ A MicroPython Bluetooth library. It implements BLE (Bluetooth 5, Bluetooth Low Energy). Of the know BLE services, this library implements Nordic Uart Service (NUS), LEGO Service and MIDI service. The library contains both the BLE Central (client) and BLE Peripheral (server) classes.
10
+
11
+ These BLE services allow for controlling LEGO hubs, running official firmware. The services also allow creating custom Bluetooth peripherals: RC controllers, MIDI devices, etc. To control the LEGO hubs, you can best use a [hub expansion board, like the LMS-ESP32](https://www.antonsmindstorms.com/product/wifi-python-esp32-board-for-mindstorms/).
12
+
13
+ ## Table of Contents
14
+
15
+ - [Features](#features)
16
+ - [Installation](#installation)
17
+ - [Quick Start](#quick-start)
18
+ - [Documentation](#documentation-and-api-reference)
19
+ - [Supported Platforms](#supported-platforms)
20
+ - [Firmware Notes](#firmware-notes)
21
+ - [License](#license)
22
+ - [Author](#author)
23
+
24
+ ## Features
25
+
26
+ - 🔌 **BLE Communication**: Comprehensive Bluetooth Low Energy support via MicroPython's `ubluetooth`
27
+ - 🎮 **Hub Control**: Control LEGO MINDSTORMS hubs, SPIKE sets, and smart hubs over Bluetooth
28
+ - 📱 **Custom Peripherals**: Create RC controllers, MIDI controllers, and other BLE peripherals compatible with LEGO hubs
29
+ - 🚀 **MicroPython Ready**: Optimized for MicroPython on ESP32, LEGO SPIKE, and other platforms
30
+ - 📡 **LEGO Protocol**: Full support for LEGO Bluetooth protocols (LPF2, LPUP, CTRL+)
31
+ - 🎛️ **Multiple Interfaces**: Nordic UART, MIDI, RC control, and native LEGO hub communication
32
+ - ⚙️ **Advanced BLE**: Automatic MTU negotiation, descriptor handling, and efficient payload management
33
+
34
+ ## Installation
35
+
36
+ ### On LMS-ESP32
37
+
38
+ The module should be included in the latest Micropython firmware from <https://wwww.antonsmindstorms.com>. If not, use ViperIDE or Thonny and create a new file called rcservo.py.
39
+ Copy the contents from the same file in this repository inside.
40
+
41
+ ### On MicroPython device using `micropip` from PyPI
42
+
43
+ ```python
44
+ import micropip
45
+ await micropip.install("btbricks")
46
+ ```
47
+
48
+ Note: `micropip` must be available on the target board and may require an internet connection from the device.
49
+
50
+ ### On SPIKE Legacy or MINDSTORMS Robot Inventor
51
+
52
+ Use the installer script in mpy-robot-tools: <https://github.com/antonvh/mpy-robot-tools/blob/master/Installer/install_mpy_robot_tools.py>
53
+
54
+ ## Quick Start
55
+
56
+ ### Connect to a LEGO Hub
57
+
58
+ ```python
59
+ from btbricks import BtHub
60
+
61
+ # Create hub instance
62
+ hub = BtHub()
63
+
64
+ # Connect to a nearby hub
65
+ hub.connect()
66
+
67
+ if hub.is_connected():
68
+ # Set hub LED to green
69
+ hub.set_led_color(6) # GREEN constant
70
+
71
+ # Read accelerometer data
72
+ acc = hub.acc()
73
+ if acc:
74
+ print(f"Accelerometer: {acc}")
75
+
76
+ # Control motor on port A with 50% power
77
+ hub.dc("A", 50)
78
+
79
+ hub.disconnect()
80
+ ```
81
+
82
+ ### Create an RC Receiver (Hub-side)
83
+ Use the examples in the `examples/` folder for full, runnable code. Minimal receiver/transmitter snippets:
84
+
85
+ ```python
86
+ from btbricks import RCReceiver, R_STICK_HOR, R_STICK_VER
87
+ from time import sleep_ms
88
+
89
+ # Create RC receiver (advertises as "robot" by default)
90
+ rcv = RCReceiver(name="robot")
91
+
92
+ print("Waiting for RC transmitter to connect...")
93
+ try:
94
+ while True:
95
+ if rcv.is_connected():
96
+ steering = rcv.controller_state(R_STICK_HOR)
97
+ throttle = rcv.controller_state(R_STICK_VER)
98
+ print(f"Steering: {steering}, Throttle: {throttle}")
99
+ sleep_ms(100)
100
+ else:
101
+ sleep_ms(500)
102
+ except KeyboardInterrupt:
103
+ rcv.disconnect()
104
+ ```
105
+
106
+ ```python
107
+ from btbricks import RCTransmitter, L_STICK_HOR, R_STICK_VER
108
+ from time import sleep
109
+
110
+ # Create RC transmitter (central)
111
+ tx = RCTransmitter()
112
+
113
+ if tx.connect(name="robot"):
114
+ try:
115
+ while tx.is_connected():
116
+ # Set stick values in range [-100, 100]
117
+ tx.set_stick(L_STICK_HOR, 0)
118
+ tx.set_stick(R_STICK_VER, 50)
119
+ tx.transmit()
120
+ sleep(0.1)
121
+ except KeyboardInterrupt:
122
+ tx.disconnect()
123
+ ```
124
+
125
+ ### Create a MIDI Controller
126
+
127
+ ```python
128
+ from btbricks import MidiController
129
+ from time import sleep
130
+
131
+ # Create MIDI controller (advertises as "amh-midi" by default)
132
+ midi = MidiController(name="amh-midi")
133
+
134
+ print("MIDI controller started, connect from your DAW...")
135
+
136
+ try:
137
+ while True:
138
+ # Send MIDI note on: middle C (note 60), velocity 100
139
+ midi.note_on(60, 100)
140
+ sleep(0.5)
141
+
142
+ # Send MIDI note off
143
+ midi.note_off(60)
144
+ sleep(0.5)
145
+
146
+ # Or send a chord
147
+ midi.chord_on("C4", velocity=100, style="M") # C major chord
148
+ sleep(1)
149
+ midi.note_off(60) # Stop the chord
150
+
151
+ except KeyboardInterrupt:
152
+ print("MIDI controller stopped")
153
+ ```
154
+
155
+ ## Documentation and API reference
156
+
157
+ See the full documentation and API reference at:
158
+
159
+ https://docs.antonsmindstorms.com/en/latest/Software/btbricks/docs/index.html
160
+
161
+ ### Core Classes
162
+
163
+ - `BLEHandler`: Low-level Bluetooth communication
164
+ - `UARTCentral`: Nordic UART client mode
165
+ - `UARTPeripheral`: Nordic UART server mode
166
+ - `RCReceiver`: Receive RC control signals
167
+ - `RCTransmitter`: Send RC control signals
168
+ - `MidiController`: Send MIDI commands over BLE
169
+ - `BtHub`: High-level hub communication interface
170
+
171
+ ### Control Constants
172
+
173
+ - Sticks: `L_STICK_HOR`, `L_STICK_VER`, `R_STICK_HOR`, `R_STICK_VER`
174
+ - Triggers: `L_TRIGGER`, `R_TRIGGER`
175
+ - Buttons: `BUTTONS`
176
+ - Settings: `SETTING1`, `SETTING2`
177
+
178
+ ## Supported Platforms
179
+
180
+ - **LEGO MINDSTORMS EV3** (with MicroPython firmware)
181
+ - **LEGO SPIKE Prime/Prime Essential** (with MINDSTORMS firmware)
182
+ - **LEGO SPIKE Robot Inventor**
183
+ - **ESP32** with MicroPython
184
+ - Other MicroPython boards with `ubluetooth` support
185
+
186
+
187
+ ## License
188
+
189
+ MIT License
190
+
191
+ ## Author
192
+
193
+ Anton Vanhoucke
@@ -0,0 +1,52 @@
1
+ """
2
+ btbricks - A MicroPython Bluetooth library for controlling LEGO hubs.
3
+
4
+ This package provides tools for remote controlling LEGO hubs and linking
5
+ smart hubs through the official LEGO Bluetooth protocol. You can also
6
+ use it to create custom Bluetooth peripherals like RC controllers or MIDI
7
+ devices compatible with LEGO hubs.
8
+ """
9
+
10
+ __version__ = "0.1.0"
11
+ __author__ = "Anton Vanhoucke"
12
+ __license__ = "MIT"
13
+
14
+ from .bt import (
15
+ BLEHandler,
16
+ UARTCentral,
17
+ UARTPeripheral,
18
+ RCReceiver,
19
+ RCTransmitter,
20
+ MidiController,
21
+ R_STICK_HOR,
22
+ R_STICK_VER,
23
+ L_STICK_HOR,
24
+ L_STICK_VER,
25
+ BUTTONS,
26
+ L_TRIGGER,
27
+ R_TRIGGER,
28
+ SETTING1,
29
+ SETTING2,
30
+ )
31
+ from .bthub import BtHub
32
+ from .ctrl_plus import SmartHub
33
+
34
+ __all__ = [
35
+ "BLEHandler",
36
+ "UARTCentral",
37
+ "UARTPeripheral",
38
+ "RCReceiver",
39
+ "RCTransmitter",
40
+ "MidiController",
41
+ "R_STICK_HOR",
42
+ "R_STICK_VER",
43
+ "L_STICK_HOR",
44
+ "L_STICK_VER",
45
+ "BUTTONS",
46
+ "L_TRIGGER",
47
+ "R_TRIGGER",
48
+ "SETTING1",
49
+ "SETTING2",
50
+ "BtHub",
51
+ "SmartHub",
52
+ ]