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

peripheral:Motor: fixed _speed_abs for END_STATE_BRAKE (#48)

This commit is contained in:
laurentchar 2020-01-30 20:03:33 +01:00 committed by GitHub
parent dff312534f
commit d1019ac9f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -254,10 +254,11 @@ class Motor(Peripheral):
END_STATE_FLOAT = 0
def _speed_abs(self, relative):
if relative is None:
if relative == Motor.END_STATE_BRAKE \
or relative == Motor.END_STATE_HOLD:
# special value for BRAKE
# https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#output-sub-command-startpower-power
return 127
return relative
if relative < -1:
log.warning("Speed cannot be less than -1")