diff options
-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=[]): |