~toykeeper/flashlight-firmware/trunk

« back to all changes in this revision

Viewing changes to bin/level_calc.py

  • Committer: Selene Scriven
  • Date: 2020-07-06 20:24:28 UTC
  • mfrom: (188.1.294 fsm)
  • Revision ID: bzr@toykeeper.net-20200706202428-7pyen2ow9q2rtd9p
merged nearly a year of updates from the fsm branch, including the new product map

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
# supported shapes: ninth, seventh, fifth, cube, square, log
9
9
#ramp_shape = 'cube'
10
10
 
 
11
max_pwm = 255
 
12
 
11
13
 
12
14
def main(args):
13
15
    """Calculates PWM levels for visually-linear steps.
22
24
            (str, 'type', '7135', 'Type of channel - 7135 or FET:'),
23
25
            (int, 'pwm_min', 6, 'Lowest visible PWM level:'),
24
26
            (float, 'lm_min', 0.25, 'How bright is the lowest level, in lumens?'),
25
 
            #(int, 'pwm_max', 255, 'Highest PWM level:'),
 
27
            #(int, 'pwm_max', max_pwm, 'Highest PWM level:'),
26
28
            (float, 'lm_max', 1000, 'How bright is the highest level, in lumens?'),
27
29
            ]
28
30
 
48
50
        if not args:
49
51
            print('===== Channel %s =====' % (chan_num+1))
50
52
        chan = Empty()
51
 
        chan.pwm_max = 255
 
53
        chan.pwm_max = max_pwm
52
54
        ask(questions_per_channel, chan)
53
55
        chan.type = chan.type.upper()
54
56
        if chan.type not in ('7135', 'FET'):
152
154
                (cnum+1,
153
155
                 ','.join([str(int(round(i))) for i in channel.modes])))
154
156
 
 
157
    # Show highest level for each channel before next channel starts
 
158
    for cnum, channel in enumerate(channels[:-1]):
 
159
        prev = 0
 
160
        i = 1
 
161
        while (i < answers.num_levels) \
 
162
                and (channel.modes[i] >= channel.modes[i-1]) \
 
163
                and (channels[cnum+1].modes[i] == 0):
 
164
            i += 1
 
165
        print('Ch%i max: %i (%.2f/%s)' % (cnum, i, channel.modes[i-1], max_pwm))
 
166
 
155
167
 
156
168
def get_value(text, default, args):
157
169
    """Get input from the user, or from the command line args."""