From 00a26788717c53c84ece16058fd4e80b0b6c5f13 Mon Sep 17 00:00:00 2001 From: chrisruk Date: Thu, 16 Feb 2023 15:31:10 +0000 Subject: [PATCH] Per port power limiting --- buildhat/color.py | 2 +- buildhat/colordistance.py | 2 +- buildhat/devices.py | 4 ++-- buildhat/motors.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/buildhat/color.py b/buildhat/color.py index edf6030..5959263 100644 --- a/buildhat/color.py +++ b/buildhat/color.py @@ -210,4 +210,4 @@ def wait_for_new_color(self): def on(self): """Turn on the sensor and LED""" - self._write(f"port {self.port} ; plimit 1 ; set -1\r") + self.reverse() diff --git a/buildhat/colordistance.py b/buildhat/colordistance.py index da85c3a..3447e17 100644 --- a/buildhat/colordistance.py +++ b/buildhat/colordistance.py @@ -199,4 +199,4 @@ def wait_for_new_color(self): def on(self): """Turn on the sensor and LED""" - self._write(f"port {self.port} ; plimit 1 ; set -1\r") + self.reverse() diff --git a/buildhat/devices.py b/buildhat/devices.py index e8bf086..0db16b1 100644 --- a/buildhat/devices.py +++ b/buildhat/devices.py @@ -188,7 +188,7 @@ def isconnected(self): def reverse(self): """Reverse polarity""" - self._write(f"port {self.port} ; plimit 1 ; set -1\r") + self._write(f"port {self.port} ; port_plimit 1 ; set -1\r") def get(self): """Extract information from device @@ -253,7 +253,7 @@ def select(self): def on(self): """Turn on sensor""" - self._write(f"port {self.port} ; plimit 1 ; on\r") + self._write(f"port {self.port} ; port_plimit 1 ; on\r") def off(self): """Turn off sensor""" diff --git a/buildhat/motors.py b/buildhat/motors.py index 102a159..38786c0 100644 --- a/buildhat/motors.py +++ b/buildhat/motors.py @@ -71,7 +71,7 @@ def plimit(self, plimit): """ if not (plimit >= 0 and plimit <= 1): raise MotorError("plimit should be 0 to 1") - self._write(f"port {self.port} ; plimit {plimit}\r") + self._write(f"port {self.port} ; port_plimit {plimit}\r") def bias(self, bias): """Bias motor @@ -413,7 +413,7 @@ def plimit(self, plimit): """ if not (plimit >= 0 and plimit <= 1): raise MotorError("plimit should be 0 to 1") - self._write(f"port {self.port} ; plimit {plimit}\r") + self._write(f"port {self.port} ; port_plimit {plimit}\r") def bias(self, bias): """Bias motor