diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-04-03 22:52:45 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-04-03 22:52:45 -0400 |
commit | 50dc3026943b90cdb9228a1502a905b10dd10ea6 (patch) | |
tree | 4339f61ed3343e6c4fcfb7059450e829d38f9011 /panel.py | |
parent | 89b4ca088d7ee9c7d077f198043f273a78030bd0 (diff) | |
download | pyExpControl-50dc3026943b90cdb9228a1502a905b10dd10ea6.tar.gz pyExpControl-50dc3026943b90cdb9228a1502a905b10dd10ea6.zip |
added triangle generator
Diffstat (limited to 'panel.py')
-rw-r--r-- | panel.py | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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=[]): |