diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-07-13 10:51:46 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-07-13 10:51:46 -0400 |
commit | 5e9c7f11e6fd6a95f198daec014826d74ed00ba6 (patch) | |
tree | f5077fed3dd986a497318f9f07c772bafdaa2858 | |
parent | 1797335c4fd0e97e4caedd387575fb1dcb387dfe (diff) | |
download | qolab-5e9c7f11e6fd6a95f198daec014826d74ed00ba6.tar.gz qolab-5e9c7f11e6fd6a95f198daec014826d74ed00ba6.zip |
some generators have getSweepDirection function
-rw-r--r-- | funcGenerator.py | 9 |
1 files changed, 9 insertions, 0 deletions
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 |