diff options
| author | Selene ToyKeeper | 2015-10-07 21:36:32 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2015-10-07 21:36:32 -0600 |
| commit | 2f74b1bcd0e514f25a4c8efc21c7a354f091f854 (patch) | |
| tree | 12cae65293ea0e47ebe69b9ffcb69f928a35cbbb /bin | |
| parent | merged Tido's BLF-VLD code (diff) | |
| parent | Replaced how USE_FILE_DELAY works. (diff) | |
| download | anduril-2f74b1bcd0e514f25a4c8efc21c7a354f091f854.tar.gz anduril-2f74b1bcd0e514f25a4c8efc21c7a354f091f854.tar.bz2 anduril-2f74b1bcd0e514f25a4c8efc21c7a354f091f854.zip | |
merged TK refactoring effort and bistro project from sandbox:
- reworking how common code is shared (in headers)
- made battcheck output more values (and has more reference measurements too)
- added new 'bistro' project
- reworked blf-a6 to use new refactored base code
- reworked s7 to use new refactored base code, including volts+tenths battcheck
- made level_calc.py able to use several different curve shapes
Diffstat (limited to '')
| -rwxr-xr-x | bin/level_calc.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/bin/level_calc.py b/bin/level_calc.py index d45e5bc..63926ba 100755 --- a/bin/level_calc.py +++ b/bin/level_calc.py @@ -43,13 +43,13 @@ def main(args): def single_pwm(v): """Estimate the PWM levels for a one-channel driver.""" - visual_min = math.pow(v['lm_min'], 1.0/3) - visual_max = math.pow(v['lm_max'], 1.0/3) + visual_min = invpower(v['lm_min']) + visual_max = invpower(v['lm_max']) step_size = (visual_max - visual_min) / (v['num_levels']-1) modes = [] goal = visual_min for i in range(v['num_levels']): - goal_lm = goal**3 + goal_lm = power(goal) #pwm_float = ((goal_lm / v['lm_max']) * (256-v['pwm_min'])) + v['pwm_min'] - 1 pwm_float = (((goal_lm-v['lm_min']) / (v['lm_max']-v['lm_min'])) \ * (255-v['pwm_min'])) \ @@ -66,13 +66,15 @@ def dual_pwm(v): """Estimate the PWM levels for a two-channel driver. Assume the first channel is the brighter one, and second will be used for moon/low modes. """ - visual_min = math.pow(v['lm2_min'], 1.0/3) - visual_max = math.pow(v['lm_max'], 1.0/3) + #visual_min = math.pow(v['lm2_min'], 1.0/power) + #visual_max = math.pow(v['lm_max'], 1.0/power) + visual_min = invpower(v['lm2_min']) + visual_max = invpower(v['lm_max']) step_size = (visual_max - visual_min) / (v['num_levels']-1) modes = [] goal = visual_min for i in range(v['num_levels']): - goal_lm = goal**3 + goal_lm = power(goal) # Up to the second channel's limit, calculate things just like a # single-channel driver (first channel will be zero) if goal_lm <= v['lm2_max']: @@ -125,6 +127,20 @@ def get_value(text, default, args): result = result.strip() return result +def power(x): + #return x**5 + return x**3 + #return x**2 + #return math.e**x + #return 2.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) + if __name__ == "__main__": import sys main(sys.argv[1:]) |
