aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSelene ToyKeeper2015-10-07 21:36:32 -0600
committerSelene ToyKeeper2015-10-07 21:36:32 -0600
commit2f74b1bcd0e514f25a4c8efc21c7a354f091f854 (patch)
tree12cae65293ea0e47ebe69b9ffcb69f928a35cbbb /bin
parentmerged Tido's BLF-VLD code (diff)
parentReplaced how USE_FILE_DELAY works. (diff)
downloadanduril-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 '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:])
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.