Skip to content

Commit

Permalink
Per port power limiting (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisruk authored Mar 31, 2023
1 parent 1ac33cf commit eeffd9d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion buildhat/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion buildhat/colordistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions buildhat/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down
4 changes: 2 additions & 2 deletions buildhat/motors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eeffd9d

Please sign in to comment.