Skip to content

Commit 3d0b235

Browse files
Update example notebook and rename jupyter_bluetooth_manager to ipymovehub.
1 parent 191d64d commit 3d0b235

5 files changed

Lines changed: 25 additions & 69 deletions

File tree

examples/test-widget-with-ipykernel.ipynb renamed to examples/test-widget-with-xeus-python.ipynb

Lines changed: 21 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
"outputs": [],
2424
"source": [
2525
"import asyncio\n",
26-
"from jupyter_bluetooth_manager import MoveHubWidget,LedColor,Port, Sensor\n",
27-
"from ipywidgets import Output\n",
26+
"from ipymovehub import MoveHubWidget,LedColor,Port, Sensor\n",
2827
"from IPython.display import display\n",
28+
"from ipymovehub.movehub import MoveHubLaneProxy\n",
2929
"\n",
3030
"# the robot's LED supports the following colors\n",
3131
"colors = [\n",
32-
"\n",
3332
" LedColor.pink,\n",
3433
" LedColor.purple,\n",
3534
" LedColor.blue,\n",
@@ -58,75 +57,44 @@
5857
"metadata": {
5958
"scrolled": true
6059
},
61-
"outputs": [
62-
{
63-
"data": {
64-
"application/vnd.jupyter.widget-view+json": {
65-
"model_id": "a58eafee0b6946458034ba2966c7d767",
66-
"version_major": 2,
67-
"version_minor": 0
68-
},
69-
"text/plain": [
70-
"MoveHubWidget(n_lanes=4)"
71-
]
72-
},
73-
"metadata": {},
74-
"output_type": "display_data"
75-
}
76-
],
60+
"outputs": [],
7761
"source": [
7862
"# number of concurrent \"lanes\"\n",
7963
"n_lanes = 4\n",
8064
"widget = MoveHubWidget(n_lanes=n_lanes)\n",
81-
"output = Output()\n",
8265
"display(widget)"
8366
]
8467
},
8568
{
8669
"cell_type": "code",
87-
"execution_count": 8,
70+
"execution_count": null,
8871
"id": "9b5f6086-3605-47ee-a170-57d3b97600e2",
8972
"metadata": {},
9073
"outputs": [],
9174
"source": [
9275
"# Case 1 : Execute this cell if there is no MoveHub connected\n",
93-
"widget.connect(output=output)"
76+
"widget.connect()"
9477
]
9578
},
9679
{
9780
"cell_type": "code",
98-
"execution_count": 9,
81+
"execution_count": null,
9982
"id": "514c7c39-8b62-4caa-a506-4abb79891592",
10083
"metadata": {},
10184
"outputs": [],
10285
"source": [
10386
"# Case 2 : Execute this cell if there is/are one/some MoveHub(s) connected\n",
10487
"# Choose one of them and paste its identifier\n",
10588
"widget.identifier = \"dcRIlxx9l8bQ3T6UVofW8Q==\"\n",
106-
"widget.connect(output=output, identifier=widget.identifier)"
89+
"widget.connect(identifier=widget.identifier)"
10790
]
10891
},
10992
{
11093
"cell_type": "code",
111-
"execution_count": 10,
94+
"execution_count": null,
11295
"id": "e2b06dac-4056-435f-800a-60134c48c27e",
11396
"metadata": {},
114-
"outputs": [
115-
{
116-
"data": {
117-
"application/vnd.jupyter.widget-view+json": {
118-
"model_id": "a58eafee0b6946458034ba2966c7d767",
119-
"version_major": 2,
120-
"version_minor": 0
121-
},
122-
"text/plain": [
123-
"MoveHubWidget(identifier='dcRIlxx9l8bQ3T6UVofW8Q==', n_lanes=4)"
124-
]
125-
},
126-
"metadata": {},
127-
"output_type": "display_data"
128-
}
129-
],
97+
"outputs": [],
13098
"source": [
13199
"display(widget)"
132100
]
@@ -141,23 +109,19 @@
141109
},
142110
{
143111
"cell_type": "code",
144-
"execution_count": 11,
112+
"execution_count": null,
145113
"id": "62924267-c398-4274-8780-91739cdacafe",
146114
"metadata": {
147115
"scrolled": true
148116
},
149117
"outputs": [],
150118
"source": [
151-
"output = Output()\n",
152-
"async def main(lane, log, identifier):\n",
153-
"\n",
154-
" for color in colors:\n",
155-
" print(color)\n",
156-
" log(f\"set color to {color.value}\")\n",
157-
" await lane.set_led_async(color)\n",
158-
" await asyncio.sleep(2)\n",
159-
"\n",
160-
"widget.run_async_program(main,output=output);"
119+
"lane_proxy = MoveHubLaneProxy (movehub = widget, lane = 0, identifier = widget.identifier)\n",
120+
"for color in colors:\n",
121+
" print(color)\n",
122+
" #log(f\"set color to {color.value}\")\n",
123+
" await lane_proxy.set_led_async(color)\n",
124+
" await asyncio.sleep(2)"
161125
]
162126
},
163127
{
@@ -178,25 +142,13 @@
178142
"speed = 50\n",
179143
"d_forward = 200\n",
180144
"d_rotate = 300\n",
181-
"output = Output()\n",
182-
"async def main(lane,log, identifier):\n",
183-
" for i in range(4):\n",
184-
" await lane.set_led_async(\"red\")\n",
185-
" await lane.motor_angle_multi_async(angle=d_forward, power_a=speed,power_b=speed)\n",
186-
" await lane.set_led_async(\"green\")\n",
187-
" await lane.motor_angle_multi_async(angle=d_rotate, power_a=speed,power_b=-1.0*speed)\n",
188145
"\n",
189-
"widget.run_async_program(main, output=output);\n",
190-
"output"
146+
"for i in range(4):\n",
147+
" await lane_proxy.set_led_async(\"red\")\n",
148+
" await lane_proxy.motor_angle_multi_async(angle=d_forward, power_a=speed,power_b=speed)\n",
149+
" await lane_proxy.set_led_async(\"green\")\n",
150+
" await lane_proxy.motor_angle_multi_async(angle=d_rotate, power_a=speed,power_b=-1.0*speed)"
191151
]
192-
},
193-
{
194-
"cell_type": "code",
195-
"execution_count": null,
196-
"id": "86ec19bd-f82c-4181-819b-f862932610f2",
197-
"metadata": {},
198-
"outputs": [],
199-
"source": []
200152
}
201153
],
202154
"metadata": {

ipymovehub/_version.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file is auto-generated by Hatchling. As such, do not:
2+
# - modify
3+
# - track in version control e.g. be sure to add to .gitignore
4+
__version__ = VERSION = '0.1.0'

0 commit comments

Comments
 (0)