aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-04-03 22:52:45 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-04-03 22:52:45 -0400
commit50dc3026943b90cdb9228a1502a905b10dd10ea6 (patch)
tree4339f61ed3343e6c4fcfb7059450e829d38f9011
parent89b4ca088d7ee9c7d077f198043f273a78030bd0 (diff)
downloadpyExpControl-50dc3026943b90cdb9228a1502a905b10dd10ea6.tar.gz
pyExpControl-50dc3026943b90cdb9228a1502a905b10dd10ea6.zip
added triangle generator
-rw-r--r--panel.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/panel.py b/panel.py
index 6b55681..6acf119 100644
--- a/panel.py
+++ b/panel.py
@@ -42,6 +42,22 @@ class RampGen:
sweeper = self.sweeper
return self.start + sweeper.getRelPos()*(self.stop - self.start)
+class TriangleGen:
+ # monotonically goes from start to stop, once reaches stop goes back to start
+ def __init__(self, start=0, stop=0, sweeper=None):
+ self.start = start
+ self.stop = stop
+ self.sweeper = sweeper
+
+ def getValue(self, sweeper=None):
+ if sweeper is None and self.sweeper is None:
+ print("Error: generator needs sweeper")
+ return 0
+ if sweeper is None:
+ sweeper = self.sweeper
+ if sweeper.getRelPos() < 0.5:
+ return self.start + 2*sweeper.getRelPos()*(self.stop - self.start)
+ return self.start + 2*(1-sweeper.getRelPos())*(self.stop - self.start)
class Sweeper:
def __init__(self, widget, start, stop, Npoints, SweepTime, onTicCallbacks=[]):