1
0
mirror of https://github.com/undera/pylgbst.git synced 2020-11-18 19:37:26 -08:00

Cosmetics

This commit is contained in:
Andrey Pokhilko 2020-06-27 13:56:01 +03:00
parent 3c2f0b493b
commit 93e1573e64
3 changed files with 10 additions and 6 deletions

View File

@ -2,9 +2,9 @@
_Move Hub is central controller block of [LEGO® Boost Robotics Set](https://www.lego.com/themes/boost)._ _Move Hub is central controller block of [LEGO® Boost Robotics Set](https://www.lego.com/themes/boost)._
In fact, Move Hub is just Bluetooth hardware, all manipulations are done with commands passed through Bluetooth Low Energy (BLE) wireless protocol. One of ways to issue these commands is to write Python program using this library. In fact, Move Hub is just Bluetooth hardware, all manipulations are made with commands passed through Bluetooth Low Energy (BLE) wireless protocol. One of ways to issue these commands is to write Python program using this library.
Best way to start is to look into [`demo.py`](examples/demo.py) file, and run it (assuming you have installed library). The best way to start is to look into [`demo.py`](examples/demo.py) file, and run it (assuming you have installed library).
If you have Vernie assembled, you might run scripts from [`examples/vernie`](examples/vernie) directory. If you have Vernie assembled, you might run scripts from [`examples/vernie`](examples/vernie) directory.
@ -55,12 +55,13 @@ Each peripheral kind has own methods to do actions and/or get sensor data. See [
## Bluetooth Backend Prerequisites ## Bluetooth Backend Prerequisites
You have following options to install as Bluetooth backend: You have following options to install as Bluetooth backend (some of them might require `sudo` on Linux):
- `pip install pygatt` - [pygatt](https://github.com/peplin/pygatt) lib, works on both Windows and Linux - `pip install pygatt` - [pygatt](https://github.com/peplin/pygatt) lib, works on both Windows and Linux
- `pip install gatt` - [gatt](https://github.com/getsenic/gatt-python) lib, supports Linux, does not work on Windows - `pip install gatt` - [gatt](https://github.com/getsenic/gatt-python) lib, supports Linux, does not work on Windows
- `pip install gattlib` - [gattlib](https://bitbucket.org/OscarAcena/pygattlib) - supports Linux, does not work on Windows, requires `sudo` - `pip install gattlib` - [gattlib](https://bitbucket.org/OscarAcena/pygattlib) - supports Linux, does not work on Windows, requires `sudo`
- `pip install bluepy` - [bluepy](https://github.com/IanHarvey/bluepy) lib, supports Linux, including Raspbian, which allows connection to the hub from the Raspberry PI - `pip install bluepy` - [bluepy](https://github.com/IanHarvey/bluepy) lib, supports Linux, including Raspbian, which allows connection to the hub from the Raspberry PI
- `pip install bleak` - [bleak](https://github.com/hbldh/bleak) lib, supports Linux/Windows/MacOS
Running on Windows requires [Bluegiga BLED112 Bluetooth Smart Dongle](https://www.silabs.com/products/wireless/bluetooth/bluetooth-low-energy-modules/bled112-bluetooth-smart-dongle) hardware piece, because no other hardware currently works on Windows with Python+BLE. Running on Windows requires [Bluegiga BLED112 Bluetooth Smart Dongle](https://www.silabs.com/products/wireless/bluetooth/bluetooth-low-energy-modules/bled112-bluetooth-smart-dongle) hardware piece, because no other hardware currently works on Windows with Python+BLE.
@ -69,7 +70,7 @@ _Please let author know if you have discovered any compatibility/preprequisite d
Depending on backend type, you might need Linux `sudo` to be used when running Python. Depending on backend type, you might need Linux `sudo` to be used when running Python.
### Bluetooth Connection Options ### Bluetooth Connection Options
There is optional parameter for `MoveHub` class constructor, accepting instance of `Connection` object. By default, it will try to use whatever `get_connection_auto()` returns. You have several options to manually control that: There is an optional parameter for `MoveHub` class constructor, accepting instance of `Connection` object. By default, it will try to use whatever `get_connection_auto()` returns. You have several options to manually control that:
- use `pylgbst.get_connection_auto()` to attempt backend auto-choice, autodetect uses - use `pylgbst.get_connection_auto()` to attempt backend auto-choice, autodetect uses
- use `BlueGigaConnection()` - if you use BlueGiga Adapter (`pygatt` library prerequisite) - use `BlueGigaConnection()` - if you use BlueGiga Adapter (`pygatt` library prerequisite)
@ -77,6 +78,7 @@ There is optional parameter for `MoveHub` class constructor, accepting instance
- use `GattoolConnection()` - if you use GattTool Backend on Linux (`pygatt` library prerequisite) - use `GattoolConnection()` - if you use GattTool Backend on Linux (`pygatt` library prerequisite)
- use `GattLibConnection()` - if you use GattLib Backend on Linux (`gattlib` library prerequisite) - use `GattLibConnection()` - if you use GattLib Backend on Linux (`gattlib` library prerequisite)
- use `BluepyConnection()` - if you use Bluepy backend on Linux/Raspbian (`bluepy` library prerequisite) - use `BluepyConnection()` - if you use Bluepy backend on Linux/Raspbian (`bluepy` library prerequisite)
- use `BleakConnection()` - if you use Bleak backend (`bleak` library prerequisite)
- pass instance of `DebugServerConnection` if you are using [Debug Server](#debug-server) (more details below). - pass instance of `DebugServerConnection` if you are using [Debug Server](#debug-server) (more details below).
All the functions above have optional arguments to specify adapter name and MoveHub mac address. Please look function source code for details. All the functions above have optional arguments to specify adapter name and MoveHub mac address. Please look function source code for details.

View File

@ -14,7 +14,7 @@ def demo_led_colors(movehub):
log.info("LED colors demo") log.info("LED colors demo")
# We get a response with payload and port, not x and y here... # We get a response with payload and port, not x and y here...
def colour_callback(**named): def colour_callback(named):
log.info("LED Color callback: %s", named) log.info("LED Color callback: %s", named)
movehub.led.subscribe(colour_callback) movehub.led.subscribe(colour_callback)

View File

@ -1,5 +1,7 @@
import logging
from examples.vernie import Vernie
from pylgbst.peripherals import VisionSensor from pylgbst.peripherals import VisionSensor
from . import *
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)