|
15 | 15 | }, |
16 | 16 | { |
17 | 17 | "cell_type": "code", |
18 | | - "execution_count": 1, |
| 18 | + "execution_count": null, |
19 | 19 | "id": "762d552a-dafd-4b4b-9b0c-8b6612d2415b", |
20 | 20 | "metadata": { |
21 | 21 | "scrolled": true |
22 | 22 | }, |
23 | 23 | "outputs": [], |
24 | 24 | "source": [ |
25 | | - "import asyncio \n", |
26 | | - "from bluetooth_manager import MoveHubWidget,LedColor,Port, Sensor\n", |
| 25 | + "import asyncio\n", |
| 26 | + "from jupyter_bluetooth_manager import MoveHubWidget,LedColor,Port, Sensor\n", |
27 | 27 | "from ipywidgets import Output\n", |
28 | 28 | "from IPython.display import display\n", |
29 | 29 | "\n", |
30 | 30 | "# the robot's LED supports the following colors\n", |
31 | 31 | "colors = [\n", |
32 | | - " \n", |
| 32 | + "\n", |
33 | 33 | " LedColor.pink,\n", |
34 | 34 | " LedColor.purple,\n", |
35 | 35 | " LedColor.blue,\n", |
|
53 | 53 | }, |
54 | 54 | { |
55 | 55 | "cell_type": "code", |
56 | | - "execution_count": 2, |
| 56 | + "execution_count": null, |
57 | 57 | "id": "aae633ad-bbb2-45c2-a1ff-5fab18146172", |
58 | 58 | "metadata": { |
59 | 59 | "scrolled": true |
|
76 | 76 | ], |
77 | 77 | "source": [ |
78 | 78 | "# number of concurrent \"lanes\"\n", |
79 | | - "n_lanes = 4 \n", |
| 79 | + "n_lanes = 4\n", |
80 | 80 | "widget = MoveHubWidget(n_lanes=n_lanes)\n", |
81 | 81 | "output = Output()\n", |
82 | 82 | "display(widget)" |
|
164 | 164 | "d_forward = 200\n", |
165 | 165 | "d_rotate = 300\n", |
166 | 166 | "output = Output()\n", |
167 | | - "async def main(lane,log): \n", |
| 167 | + "async def main(lane,log):\n", |
168 | 168 | " for i in range(4):\n", |
169 | 169 | " await lane.set_led_async(\"red\")\n", |
170 | 170 | " await lane.motor_angle_multi_async(angle=d_forward, power_a=speed,power_b=speed)\n", |
171 | 171 | " await lane.set_led_async(\"green\")\n", |
172 | 172 | " await lane.motor_angle_multi_async(angle=d_rotate, power_a=speed,power_b=-1.0*speed)\n", |
173 | | - " \n", |
| 173 | + "\n", |
174 | 174 | "movehub.run_async_program(main, output=output);\n", |
175 | 175 | "output" |
176 | 176 | ] |
|
207 | 207 | "def on_up(lane, log):\n", |
208 | 208 | " # run sync but NON blocking\n", |
209 | 209 | " lane.motor_time_multi(10, 50, 50)\n", |
210 | | - " \n", |
| 210 | + "\n", |
211 | 211 | "def on_down(lane, log):\n", |
212 | 212 | " # run sync but NON blocking\n", |
213 | 213 | " lane.motor_time_multi(10, -50, -50)\n", |
214 | | - " \n", |
| 214 | + "\n", |
215 | 215 | "def on_left(lane, log):\n", |
216 | 216 | " # run sync but NON blocking\n", |
217 | 217 | " lane.motor_time_multi(10, -50, 50)\n", |
218 | | - " \n", |
| 218 | + "\n", |
219 | 219 | "def on_right(lane, log):\n", |
220 | 220 | " # run sync but NON blocking\n", |
221 | 221 | " lane.motor_time_multi(10, 50, -50)\n", |
222 | | - " \n", |
| 222 | + "\n", |
223 | 223 | "def on_stop(lane, log):\n", |
224 | 224 | " # run sync but NON blocking\n", |
225 | 225 | " lane.motor_time_multi(0, 0, 0)\n", |
226 | | - " \n", |
| 226 | + "\n", |
227 | 227 | "button_up.on_click(lambda _: movehub.run_program(on_up, output=output))\n", |
228 | 228 | "button_down.on_click(lambda _: movehub.run_program(on_down, output=output))\n", |
229 | 229 | "button_left.on_click(lambda _: movehub.run_program(on_left, output=output))\n", |
|
312 | 312 | " from bqplot import pyplot as plt\n", |
313 | 313 | " from bqplot import topo_load\n", |
314 | 314 | " import numpy\n", |
315 | | - " \n", |
| 315 | + "\n", |
316 | 316 | " output = Output()\n", |
317 | | - " \n", |
| 317 | + "\n", |
318 | 318 | " duration = 10.0\n", |
319 | 319 | " dt = 0.10\n", |
320 | 320 | " clip_value = 200\n", |
|
369 | 369 | " log(f\"set color to {color.value}\")\n", |
370 | 370 | " await lane.set_led_async(color)\n", |
371 | 371 | " await asyncio.sleep(0.5)\n", |
372 | | - " \n", |
| 372 | + "\n", |
373 | 373 | "\n", |
374 | 374 | "speed = 26\n", |
375 | 375 | "d_forward = 200\n", |
376 | 376 | "d_rotate = 300\n", |
377 | | - "async def drive(lane, output): \n", |
| 377 | + "async def drive(lane, output):\n", |
378 | 378 | " for i in range(4):\n", |
379 | 379 | " await lane.motor_angle_multi_async(angle=d_forward, power_a=speed,power_b=speed)\n", |
380 | 380 | " await lane.motor_angle_multi_async(angle=d_rotate, power_a=speed,power_b=-1.0*speed)\n", |
|
0 commit comments