~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to bin/level_calc.py

Merge from TK's main A2 branch thru Rev 647 which includes several patches for the Sofirn SP10 Pro after TK merge that branch in

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
            dpwm_steps = int(parts[1])
66
66
            dpwn_max = int(parts[2])
67
67
            dpwn_min = int(parts[3])
 
68
            dpwm_shape = 'linear'
 
69
            if parts[4]:
 
70
                dpwm_shape = float(parts[4])
68
71
            max_pwms = [dpwn_min] * answers.num_levels
69
72
            for i in range(dpwm_steps):
70
73
                span = dpwn_max - dpwn_min
71
 
                x = dpwn_min + (span * (float(dpwm_steps - i) / dpwm_steps))
 
74
                if dpwm_shape == 'linear':
 
75
                    x = dpwn_min + (span * (float(dpwm_steps - i) / dpwm_steps))
 
76
                else:  # variable curve
 
77
                    x = dpwn_min + (span * ((float(dpwm_steps - i) / dpwm_steps) ** dpwm_shape))
72
78
                max_pwms[i] = int(x)
73
79
            max_pwm = dpwn_min
74
80