From 89b4ca088d7ee9c7d077f198043f273a78030bd0 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Sat, 3 Apr 2021 22:44:52 -0400 Subject: added ramp generator --- panel.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/panel.py b/panel.py index e9cafe3..6b55681 100644 --- a/panel.py +++ b/panel.py @@ -27,6 +27,21 @@ class SinGen: sweeper = self.sweeper return self.ampl * np.sin( 2*np.pi*sweeper.getRelPos()) + self.offset +class RampGen: + # monotonically goes from start to stop, at final point move 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 + return self.start + sweeper.getRelPos()*(self.stop - self.start) + class Sweeper: def __init__(self, widget, start, stop, Npoints, SweepTime, onTicCallbacks=[]): -- cgit v1.2.3