diff options
| author | Selene ToyKeeper | 2018-06-25 02:41:41 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2018-06-25 02:41:41 -0600 |
| commit | 668d84adb72c12d069efc6764c1bd176d954beb8 (patch) | |
| tree | 55a8fd0f2ba14509f361d7dd714fd90751098fb9 /bin | |
| parent | Added some README info from Ratus: cheaper flashing hardware. (diff) | |
| download | anduril-668d84adb72c12d069efc6764c1bd176d954beb8.tar.gz anduril-668d84adb72c12d069efc6764c1bd176d954beb8.tar.bz2 anduril-668d84adb72c12d069efc6764c1bd176d954beb8.zip | |
Made it easier to change ramp shape in bin/level_calc.py .
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/level_calc.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/bin/level_calc.py b/bin/level_calc.py index 4dc1356..2aa8727 100755 --- a/bin/level_calc.py +++ b/bin/level_calc.py @@ -5,6 +5,8 @@ from __future__ import print_function import math interactive = False +# supported shapes: ninth, fifth, cube, square, log_e, log_2 +ramp_shape = 'cube' def main(args): @@ -160,20 +162,21 @@ def get_value(text, default, args): return result +shapes = dict( + ninth = (lambda x: x**9, lambda x: math.pow(x, 1/9.0)), + fifth = (lambda x: x**5, lambda x: math.pow(x, 1/5.0)), + cube = (lambda x: x**3, lambda x: math.pow(x, 1/3.0)), + square = (lambda x: x**2, lambda x: math.pow(x, 1/2.0)), + log_e = (lambda x: math.e**x, lambda x: math.log(x, math.e)), + log_2 = (lambda x: 2.0**x, lambda x: math.log(x, 2.0)), + ) + def power(x): - #return x**5 - return x**3 - #return x**2 - #return math.e**x - #return 2.0**x + return shapes[ramp_shape][0](x) def invpower(x): - #return math.pow(x, 1/5.0) - return math.pow(x, 1/3.0) - #return math.pow(x, 1/2.0) - #return math.log(x, math.e) - #return math.log(x, 2.0) + return shapes[ramp_shape][1](x) def input_text(): |
