1
0
mirror of https://github.com/undera/pylgbst.git synced 2020-11-18 19:37:26 -08:00
2017-09-17 22:03:38 +03:00
2017-09-17 22:03:38 +03:00
2017-09-17 22:03:38 +03:00
2017-09-13 21:00:46 +03:00
2017-09-17 22:03:38 +03:00
2017-09-13 13:46:13 +03:00
2017-09-17 22:03:38 +03:00
2017-09-17 21:12:59 +03:00
2017-09-16 00:46:37 +03:00

Python library to interact with LEGO Move Hub

Best way to start is to look into demo.py file, and run it.

If you have Vernie assembled, you might look into and run scripts from vernie directory.

Features

  • auto-detect and connect for Bluetooth device
  • auto-detects devices connected to Hub
  • angled and timed movement for motors
  • LED color change
  • motors: angled and timed movement, rotation sensor subscription
  • push button status subscription
  • tilt sensor subscription: 2 axis, 3 axis, bump detect modes
  • color & distance sensor: several modes to measure distance, color and luminosity
  • battery voltage subscription available
  • permanent Bluetooth connection server for faster debugging

Usage

Install library like this:

pip install https://github.com/undera/pylgbst/archive/0.2.tar.gz

Then instantiate MoveHub object and start invoking its methods. Following is example to just print peripherals detected on Hub:

from pylgbst import MoveHub

hub = MoveHub()

for device in hub.devices:
    print(device)

TODO: more usage instructions

General Information

connection params hub's devices detect process & fields to access them general subscription modes & granularity info

Motors

Motor Rotation Sensors

Tilt Sensor

Color & Distance Sensor

Tip: laser pointer pointing to sensor makes it trigger distance sensor

LED

Push Button

Power Voltage & Battery

Debug Server

sudo python -c "from pylgbst.comms import *; \
    import logging; logging.basicConfig(level=logging.DEBUG); \
    DebugServer(BLEConnection().connect()).start()"

Roadmap

  • handle device detach and device attach events on ports C/D
  • experiment with motor commands, find what is hidden there
  • Give nice documentation examples, don't forget to mention logging
  • document all API methods
  • make sure unit tests cover all important code
  • generalize getting device info + give constants (low priority)
  • subscribing to color sensor disables LED operating in run_away_game.py. Why?
  • can we subscribe to LED?

Some things around visual programming:

Description
No description provided
Readme 1.3 MiB
Languages
Python 100%