aboutsummaryrefslogtreecommitdiff
path: root/panel.py
diff options
context:
space:
mode:
Diffstat (limited to 'panel.py')
-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=[]):