* It's HUB ID * Rename file * Working with official doc * Some progress * AttachedIO msg * device action impl * some better device alert impl * restructuring * Some port commands handled * Some command feedback waiting * Some more request-reply things * Some more request-reply things * Reworked msg classes * Getting back to UTs * Getting back to UTs * Facing sync lock problems * Facing sync lock problems * Testing it * Covering more with tests * handle actions * Hub class is almost covered * done coverage for Hub * done coverage for MoveHub * Button is tested * remove debug server from examples * Current and voltage tested * color sensor basic test * cover tilt sensor * motor sensor tested * constant motor * motor is tested * hold_speed impl for motor * motor commands recorded * some cleanup * some cleanup * some cleanup * debug * debug * FIX a bug * acc/dec profiles figured out * UT motor ops * UT motor ops * Get rid of weird piggyback * fix UT * Fix encoding? * fix test mb * More robust * Checked demo works * cosmetics * cosmetics * Maybe better test * fetching and decoding some device caps * describing devs * describing devs works * Applying modes we've learned * Simple and extensible dev attach * Reworking peripherals based on modes * Applying modes we've learned * implemented getting sensor data * fixed port subscribe * Added led out cmds on vision sensor * Worked on color-distance sensor * Introduce some locking for consistency * Improved it all * Travis flags * improve * improve * improve docs
1.7 KiB
Move Hub
MoveHub
is extension of generic Powered Up Hub class. MoveHub
class delivers specifics of MoveHub brick, such as internal motor port names. Apart from specifics listed below, all operations on Hub are done as usual.
Devices Detecting
As part of instantiating process, MoveHub
waits up to 1 minute for builtin devices to appear, such as motors on ports A and B, tilt sensor, LED and battery. This not guarantees that external motor and/or color sensor will be present right after MoveHub
instantiated. Usually, time.sleep(1.0)
for couple of seconds gives it enough time to detect everything.
MoveHub provides motors via following fields:
motor_A
- port A motormotor_B
- port B motormotor_AB
- combined motors A+B manipulated togethermotor_external
- external motor attached to port C or D
MoveHub's internal tilt sensor is available through tilt_sensor
field.
Field named vision_sensor
holds instance of VisionSensor
, if one is attached to MoveHub.
Fields named current
and voltage
present corresponding sensors from Hub.
Push Button
MoveHub
class has field button
to subscribe to button press and release events.
Note that Button
class is not real Peripheral
, as it has no port and not listed in peripherals
field of Hub. For convenience, subscribing to button is still done usual way:
from pylgbst.hub import MoveHub
def callback(is_pressed):
print("Btn pressed: %s" % is_pressed)
hub = MoveHub()
hub.button.subscribe(callback)