Skip to content

Commit 13ce3a2

Browse files
Update extension : update example notebook and rename jupyter_bluetooth_manager to ipymovehub.
1 parent 191d64d commit 13ce3a2

26 files changed

Lines changed: 35379 additions & 41 deletions
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
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",
2928
"\n",
3029
"# the robot's LED supports the following colors\n",
3130
"colors = [\n",
32-
"\n",
3331
" LedColor.pink,\n",
3432
" LedColor.purple,\n",
3533
" LedColor.blue,\n",
@@ -62,7 +60,7 @@
6260
{
6361
"data": {
6462
"application/vnd.jupyter.widget-view+json": {
65-
"model_id": "a58eafee0b6946458034ba2966c7d767",
63+
"model_id": "5e916fd00a0542169e70cf4eb25f3aa9",
6664
"version_major": 2,
6765
"version_minor": 0
6866
},
@@ -78,49 +76,48 @@
7876
"# number of concurrent \"lanes\"\n",
7977
"n_lanes = 4\n",
8078
"widget = MoveHubWidget(n_lanes=n_lanes)\n",
81-
"output = Output()\n",
8279
"display(widget)"
8380
]
8481
},
8582
{
8683
"cell_type": "code",
87-
"execution_count": 8,
84+
"execution_count": null,
8885
"id": "9b5f6086-3605-47ee-a170-57d3b97600e2",
8986
"metadata": {},
9087
"outputs": [],
9188
"source": [
9289
"# Case 1 : Execute this cell if there is no MoveHub connected\n",
93-
"widget.connect(output=output)"
90+
"widget.connect()"
9491
]
9592
},
9693
{
9794
"cell_type": "code",
98-
"execution_count": 9,
95+
"execution_count": null,
9996
"id": "514c7c39-8b62-4caa-a506-4abb79891592",
10097
"metadata": {},
10198
"outputs": [],
10299
"source": [
103100
"# Case 2 : Execute this cell if there is/are one/some MoveHub(s) connected\n",
104101
"# Choose one of them and paste its identifier\n",
105102
"widget.identifier = \"dcRIlxx9l8bQ3T6UVofW8Q==\"\n",
106-
"widget.connect(output=output, identifier=widget.identifier)"
103+
"widget.connect(identifier=widget.identifier)"
107104
]
108105
},
109106
{
110107
"cell_type": "code",
111-
"execution_count": 10,
108+
"execution_count": 6,
112109
"id": "e2b06dac-4056-435f-800a-60134c48c27e",
113110
"metadata": {},
114111
"outputs": [
115112
{
116113
"data": {
117114
"application/vnd.jupyter.widget-view+json": {
118-
"model_id": "a58eafee0b6946458034ba2966c7d767",
115+
"model_id": "5e916fd00a0542169e70cf4eb25f3aa9",
119116
"version_major": 2,
120117
"version_minor": 0
121118
},
122119
"text/plain": [
123-
"MoveHubWidget(identifier='dcRIlxx9l8bQ3T6UVofW8Q==', n_lanes=4)"
120+
"MoveHubWidget(n_lanes=4)"
124121
]
125122
},
126123
"metadata": {},
@@ -141,23 +138,38 @@
141138
},
142139
{
143140
"cell_type": "code",
144-
"execution_count": 11,
141+
"execution_count": null,
145142
"id": "62924267-c398-4274-8780-91739cdacafe",
146143
"metadata": {
147144
"scrolled": true
148145
},
149-
"outputs": [],
146+
"outputs": [
147+
{
148+
"name": "stdout",
149+
"output_type": "stream",
150+
"text": [
151+
"LedColor.pink\n"
152+
]
153+
},
154+
{
155+
"ename": "AttributeError",
156+
"evalue": "'int' object has no attribute 'set_led_async'",
157+
"output_type": "error",
158+
"traceback": [
159+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
160+
"\u001b[31mAttributeError\u001b[39m Traceback (most recent call last)",
161+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 2\u001b[39m lane = widget.n_lanes\n\u001b[32m 3\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m color \u001b[38;5;28;01min\u001b[39;00m colors:\n\u001b[32m 4\u001b[39m print(color)\n\u001b[32m 5\u001b[39m \u001b[38;5;66;03m#log(f\"set color to {color.value}\")\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m lane.set_led_async(color)\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m asyncio.sleep(\u001b[32m2\u001b[39m)\n",
162+
"\u001b[31mAttributeError\u001b[39m: 'int' object has no attribute 'set_led_async'"
163+
]
164+
}
165+
],
150166
"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);"
167+
"lane_proxy = MoveHubLaneProxy (movehub = widget, lane = 0, identifier = widget.identifier)\n",
168+
"for color in colors:\n",
169+
" print(color)\n",
170+
" #log(f\"set color to {color.value}\")\n",
171+
" await lane_proxy.set_led_async(color)\n",
172+
" await asyncio.sleep(2)"
161173
]
162174
},
163175
{
@@ -178,25 +190,13 @@
178190
"speed = 50\n",
179191
"d_forward = 200\n",
180192
"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",
188193
"\n",
189-
"widget.run_async_program(main, output=output);\n",
190-
"output"
194+
"for i in range(4):\n",
195+
" await lane_proxy.set_led_async(\"red\")\n",
196+
" await lane_proxy.motor_angle_multi_async(angle=d_forward, power_a=speed,power_b=speed)\n",
197+
" await lane_proxy.set_led_async(\"green\")\n",
198+
" await lane_proxy.motor_angle_multi_async(angle=d_rotate, power_a=speed,power_b=-1.0*speed)"
191199
]
192-
},
193-
{
194-
"cell_type": "code",
195-
"execution_count": null,
196-
"id": "86ec19bd-f82c-4181-819b-f862932610f2",
197-
"metadata": {},
198-
"outputs": [],
199-
"source": []
200200
}
201201
],
202202
"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)