changeset 22:7b14d4b31f33

Add a trim parameter for exact trimming
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Tue, 01 Jul 2014 22:15:21 +0200
parents 441acc81edca
children 4f3ebfe4bdee
files maestro.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/maestro.py	Wed Jun 25 16:31:24 2014 +0200
+++ b/maestro.py	Tue Jul 01 22:15:21 2014 +0200
@@ -80,7 +80,7 @@
     max_position = 8064
 
     def __init__(self, maestro, index, center=None,
-                 max_degrees=90, reverse=False):
+                 max_degrees=90, reverse=False, trim=0):
         self.maestro = maestro
         self.index = index
         self.reverse = reverse
@@ -90,13 +90,14 @@
             self.center = self.min_position + self.width / 2
         else:
             self.center = center
+        self.trim = 0
 
     def move_degrees(self, degrees):
         self._angle = degrees
         position = (self.width * degrees) / self.max_degrees
         if self.reverse:
             position = -position
-        target = self.center + position
+        target = self.center + position + self.trim
         target = min(self.max_position, max(self.min_position, target))
         self.maestro.set_target(self.index, target)
 
@@ -109,7 +110,7 @@
 
     def get_degrees(self):
         target = self.get_position(self.index)
-        position = target - self.center
+        position = target - self.center - self.trim
         if self.reverse:
             position = -position
         return (self.max_degrees * position) / self.width