From 5e9c7f11e6fd6a95f198daec014826d74ed00ba6 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Tue, 13 Jul 2021 10:51:46 -0400 Subject: some generators have getSweepDirection function --- funcGenerator.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'funcGenerator.py') diff --git a/funcGenerator.py b/funcGenerator.py index 54a3b1b..cd33f0b 100644 --- a/funcGenerator.py +++ b/funcGenerator.py @@ -72,6 +72,15 @@ class SawGen(RampGen): if sweeper.getRelPos() < self.duty_cycle: return self.start + sweeper.getRelPos()/self.duty_cycle*(self.stop - self.start) return self.start + (1-sweeper.getRelPos())/(1-self.duty_cycle)*(self.stop - self.start) + def getSweepDirection(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() < self.duty_cycle: + return 1; # increasing value direction + return 0; # decreasing value direction class TriangleGen(SawGen): # monotonically goes from start to stop, once reaches stop goes back to start -- cgit v1.2.3