aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/level_calc.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/bin/level_calc.py b/bin/level_calc.py
index de52998..4dc1356 100755
--- a/bin/level_calc.py
+++ b/bin/level_calc.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import math
interactive = False
@@ -41,6 +43,9 @@ def main(args):
chan = Empty()
chan.pwm_max = 255
ask(questions_per_channel, chan)
+ chan.type = chan.type.upper()
+ if chan.type not in ('7135', 'FET'):
+ raise ValueError('Invalid channel type: %s' % (chan.type,))
channels.append(chan)
# calculate total output of all previous channels
@@ -54,8 +59,8 @@ def main(args):
multi_pwm(answers, channels)
if interactive: # Wait on exit, in case user invoked us by clicking an icon
- print 'Press Enter to exit:'
- raw_input()
+ print('Press Enter to exit:')
+ input_text()
class Empty:
@@ -72,7 +77,7 @@ def multi_pwm(answers, channels):
lm_max = channels[-1].lm_max
else:
# this would be a stupid driver design
- raise ValueError, "FET channel isn't the most powerful?"
+ raise ValueError("FET channel isn't the most powerful?")
visual_min = invpower(lm_min)
visual_max = invpower(lm_max)
@@ -96,7 +101,7 @@ def multi_pwm(answers, channels):
# This shouldn't happen, the FET is assumed to be the highest channel
if channel.type == 'FET':
# this would be a stupid driver design
- raise ValueError, "FET channel isn't the most powerful?"
+ raise ValueError("FET channel isn't the most powerful?")
# Handle FET turbo specially
if (i == (answers.num_levels - 1)) \
@@ -149,8 +154,8 @@ def get_value(text, default, args):
else:
global interactive
interactive = True
- print text, '(%s)' % (default),
- result = raw_input()
+ print(text + ' (%s) ' % (default), end='')
+ result = input_text()
result = result.strip()
return result
@@ -171,6 +176,14 @@ def invpower(x):
#return math.log(x, 2.0)
+def input_text():
+ try:
+ value = raw_input() # python2
+ except NameError:
+ value = input() # python3
+ return value
+
+
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.