diff options
| author | Selene ToyKeeper | 2019-09-29 00:02:14 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-09-29 00:02:14 -0600 |
| commit | 259b8a4fd4311720733d4da352f66dcf789cfd53 (patch) | |
| tree | f498c5072dd0f32424ef979dcd12bdab78827a18 /bin/level_calc.py | |
| parent | remapped D1S V2 pins to match new driver (diff) | |
| parent | after safety ramp-down, if the button remains stuck, lock the light (diff) | |
| download | anduril-259b8a4fd4311720733d4da352f66dcf789cfd53.tar.gz anduril-259b8a4fd4311720733d4da352f66dcf789cfd53.tar.bz2 anduril-259b8a4fd4311720733d4da352f66dcf789cfd53.zip | |
merged from fsm branch to get safety ramp-down and version check functions, among other updates
Diffstat (limited to '')
| -rwxr-xr-x | bin/level_calc.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/level_calc.py b/bin/level_calc.py index 59b75ee..a780405 100755 --- a/bin/level_calc.py +++ b/bin/level_calc.py @@ -16,7 +16,7 @@ def main(args): """ # Get parameters from the user questions_main = [ - (str, 'ramp_shape', 'cube', 'Ramp shape? [cube, square, fifth, seventh, ninth, log]'), + (str, 'ramp_shape', 'cube', 'Ramp shape? [cube, square, fifth, seventh, ninth, log, N.NN]'), (int, 'num_channels', 1, 'How many power channels?'), (int, 'num_levels', 4, 'How many total levels do you want?'), ] @@ -191,11 +191,19 @@ shapes = dict( ) def power(x): - return shapes[ramp_shape][0](x) + try: + factor = float(ramp_shape) + return math.pow(x, factor) + except ValueError: + return shapes[ramp_shape][0](x) def invpower(x): - return shapes[ramp_shape][1](x) + try: + factor = float(ramp_shape) + return math.pow(x, 1.0 / factor) + except ValueError: + return shapes[ramp_shape][1](x) def input_text(): |
