aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSelene ToyKeeper2015-10-05 16:57:11 -0600
committerSelene ToyKeeper2015-10-05 16:57:11 -0600
commit58e82f12f2ac26c764439cbb06e2d7ffb5396c6b (patch)
treef2a1dab74241f69bb3ce7646fad518186312ced9 /bin
parentmerged trunk (diff)
parentAdded volts+tenths and 8-bar battery check styles. (diff)
downloadanduril-58e82f12f2ac26c764439cbb06e2d7ffb5396c6b.tar.gz
anduril-58e82f12f2ac26c764439cbb06e2d7ffb5396c6b.tar.bz2
anduril-58e82f12f2ac26c764439cbb06e2d7ffb5396c6b.zip
merged tiny25 branch
Diffstat (limited to 'bin')
-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:])