aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSelene ToyKeeper2015-09-30 02:31:14 -0600
committerSelene ToyKeeper2015-09-30 02:31:14 -0600
commit0e1a7cc81847f62074ab809efdac1cff88327137 (patch)
tree51cf9508957f81a9a722a4cdd5052fe8e2628c4a /bin
parentOops, delay_s() should delay for 1000 ms, not BOGOMIPS ms. (diff)
downloadanduril-0e1a7cc81847f62074ab809efdac1cff88327137.tar.gz
anduril-0e1a7cc81847f62074ab809efdac1cff88327137.tar.bz2
anduril-0e1a7cc81847f62074ab809efdac1cff88327137.zip
made visually-linear curve function configurable in level_calc.py
Diffstat (limited to '')
-rwxr-xr-xbin/level_calc.py28
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:])