From 44a0c0f0ff41eea469b31ef24cdea8d09df69a3f Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Tue, 6 Apr 2021 23:03:28 -0400 Subject: added pulse generator --- panel.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'panel.py') diff --git a/panel.py b/panel.py index f96c751..07a1362 100644 --- a/panel.py +++ b/panel.py @@ -61,6 +61,22 @@ class TriangleGen: return self.start + 2*sweeper.getRelPos()*(self.stop - self.start) return self.start + 2*(1-sweeper.getRelPos())*(self.stop - self.start) +class PulseGen: + # monotonically goes from start to stop, once reaches stop goes back to start + def __init__(self, ampl=1, sweeper=None): + self.ampl = ampl + 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.ampl + return 0 + class Sweeper: def __init__(self, widget, Npoints, SweepTime, onTicCallbacks=[]): # walk from start to stop with Npoints -- cgit v1.2.3