mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Cosmetics
This commit is contained in:
parent
24797cae51
commit
b4f5481fbe
@ -337,8 +337,8 @@ Then push green button on MoveHub, so permanent BLE connection will be establish
|
|||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
|
- https://github.com/LEGO/lego-ble-wireless-protocol-docs - true docs for LEGO BLE protocol
|
||||||
- https://github.com/JorgePe/BOOSTreveng - initial source of protocol knowledge
|
- https://github.com/JorgePe/BOOSTreveng - initial source of protocol knowledge
|
||||||
- https://github.com/LEGO/lego-ble-wireless-protocol-docs - true docs of BLE protocol
|
|
||||||
- https://github.com/spezifisch/sphero-python/blob/master/BB8joyDrive.py - example with another approach to bluetooth libs
|
- https://github.com/spezifisch/sphero-python/blob/master/BB8joyDrive.py - example with another approach to bluetooth libs
|
||||||
|
|
||||||
Some things around visual programming:
|
Some things around visual programming:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
from pylgbst.constants import COLORS, COLOR_NONE, COLOR_BLACK, COLOR_CYAN, COLOR_BLUE
|
from pylgbst.constants import COLOR_NONE, COLOR_BLACK, COLOR_CYAN, COLOR_BLUE
|
||||||
from pylgbst.movehub import MoveHub
|
from pylgbst.movehub import MoveHub
|
||||||
from pylgbst.peripherals import ColorDistanceSensor
|
from pylgbst.peripherals import ColorDistanceSensor
|
||||||
|
|
||||||
@ -47,12 +47,3 @@ class Automata(object):
|
|||||||
def backward(self):
|
def backward(self):
|
||||||
self.__hub.motor_AB.angled(830, -0.25)
|
self.__hub.motor_AB.angled(830, -0.25)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
automata = Automata()
|
|
||||||
|
|
||||||
for x in range(16):
|
|
||||||
automata.feed_tape()
|
|
||||||
print (x, COLORS[automata.get_color()])
|
|
||||||
|
|
||||||
# time.sleep(1000)
|
|
||||||
|
@ -7,6 +7,7 @@ log = logging.getLogger('pylgbst')
|
|||||||
|
|
||||||
|
|
||||||
def get_connection_bluegiga(controller=None, hub_mac=None):
|
def get_connection_bluegiga(controller=None, hub_mac=None):
|
||||||
|
del controller # to prevent code analysis warning
|
||||||
from pylgbst.comms.cpygatt import BlueGigaConnection
|
from pylgbst.comms.cpygatt import BlueGigaConnection
|
||||||
|
|
||||||
return BlueGigaConnection().connect(hub_mac)
|
return BlueGigaConnection().connect(hub_mac)
|
||||||
@ -29,6 +30,7 @@ def get_connection_gattlib(controller='hci0', hub_mac=None):
|
|||||||
|
|
||||||
return GattLibConnection(controller).connect(hub_mac)
|
return GattLibConnection(controller).connect(hub_mac)
|
||||||
|
|
||||||
|
|
||||||
def get_connection_bluepy(controller='hci0', hub_mac=None):
|
def get_connection_bluepy(controller='hci0', hub_mac=None):
|
||||||
from pylgbst.comms.cbluepy import BluepyConnection
|
from pylgbst.comms.cbluepy import BluepyConnection
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ MSG_DEVICE_SHUTDOWN = 0x02 # sent when hub shuts down by button hold
|
|||||||
MSG_PING_RESPONSE = 0x03
|
MSG_PING_RESPONSE = 0x03
|
||||||
MSG_PORT_INFO = 0x04
|
MSG_PORT_INFO = 0x04
|
||||||
MSG_PORT_CMD_ERROR = 0x05
|
MSG_PORT_CMD_ERROR = 0x05
|
||||||
|
|
||||||
|
|
||||||
MSG_SET_PORT_VAL = 0x81
|
MSG_SET_PORT_VAL = 0x81
|
||||||
MSG_PORT_STATUS = 0x82
|
MSG_PORT_STATUS = 0x82
|
||||||
MSG_SENSOR_SUBSCRIBE = 0x41
|
MSG_SENSOR_SUBSCRIBE = 0x41
|
||||||
|
@ -244,3 +244,7 @@ class MoveHub(object):
|
|||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
return self.info[info_type]
|
return self.info[info_type]
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
if self.connection and self.connection.is_alive():
|
||||||
|
self.connection.disconnect()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user