From d1019ac9f42be89050ed0221c9692c58fe4a3041 Mon Sep 17 00:00:00 2001 From: laurentchar <59374859+laurentchar@users.noreply.github.com> Date: Thu, 30 Jan 2020 20:03:33 +0100 Subject: [PATCH] peripheral:Motor: fixed _speed_abs for END_STATE_BRAKE (#48) --- pylgbst/peripherals.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pylgbst/peripherals.py b/pylgbst/peripherals.py index cfa1cf7..48609f8 100644 --- a/pylgbst/peripherals.py +++ b/pylgbst/peripherals.py @@ -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")